Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

# st: R: negative variance after gb2fit

 From "Lucia R.Latino" To Subject st: R: negative variance after gb2fit Date Thu, 5 Jul 2012 10:39:10 +0200

```Dear Stephen and Michal,

thanks so much for your help.

I fitted again my data using Michal's suggestion and now the variance is not
anymore negative.

Thanks!
Lucia

-----Messaggio originale-----
Da: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Per conto di
S.Jenkins@lse.ac.uk
Inviato: mercoledì 4 luglio 2012 11:58
A: statalist@hsphsun2.harvard.edu
Oggetto: st: negative variance after gb2fit

Many thanks to Michal Brzezinski for spotting this little bug. I'll send a
corrected version of -gb2fit- to Kit Baum to replace the existing one on SSC

Stephen
------------------------------

Date: Tue, 3 Jul 2012 23:41:34 +0200
From: Michal Brzezinski <michalbrzez@gmail.com>
Subject: Re: st: negative variance after gb2fit

I think that there is a typo in gb2fit in calculating variance for the
fitted model.
Lines 236-239 of gb2fit are:
eret scalar var = `b'*`b'*exp(lngamma(1+2/`a')) ///
*exp(lngamma(`q'-2/`a'))
///
/(
exp(lngamma(`p'))*exp(lngamma(`q')) ) 	///
- (`e(mean)'*`e(mean)')

"1" in the first line should be replaced with "p", so that the correct
expression for variance is:

eret scalar var =
`b'*`b'*exp(lngamma(`p'+2/`a')) 		///
*exp(lngamma(`q'-2/`a'))
///
/(
exp(lngamma(`p'))*exp(lngamma(`q')) ) 	///
- (`e(mean)'*`e(mean)')

I hope that this helps with your problem.

Michal Brzezinski

-------------------------------------
Professor Stephen P. Jenkins <s.jenkins@lse.ac.uk> Department of Social
Policy London School of Economics and Political Science Houghton Street,
London WC2A 2AE, U.K.
Tel: +44 (0)20 7955 6527
Changing Fortunes: Income Mobility and Poverty Dynamics in Britain, OUP
2011, http://ukcatalogue.oup.com/product/9780199226436.do
Survival Analysis using Stata:
http://www.iser.essex.ac.uk/survival-analysis
Downloadable papers and software: http://ideas.repec.org/e/pje7.html

Please access the attached hyperlink for an important electronic
communications disclaimer: http://lse.ac.uk/emailDisclaimer

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index