Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

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

From |
"Nick Cox" <n.j.cox@durham.ac.uk> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: RE: How to retrieve parameter estimates from an ML program, so they can be used in estimation of expected values, variances, etc... |

Date |
Mon, 29 Mar 2010 13:52:48 +0100 |

I am surprised you need to do this at all, unless your version of generalised gamma is incompatible with Stata's (which is possible, just as there are various different generalised exponentials). With a token -stset-, even if it is insincere, you can use Stata's version of this in -streg- without needing to reinvent it. Nick n.j.cox@durham.ac.uk SLG Brilleman I have recently written a program for ml estimation using the generalized Gamma distribution. The estimation routine seems to run fine and will produce estimates of the coefficients for the linear predictor (mu), and estimates of the two shape parameters (sigma and kappa). My problem is that I want to estimate the expected value of yi (i.e. the individual predictions) - an equation involving estimates of all three parameters (mu, sigma, kappa). I am reasonably new to STATA and cannot figure out the syntax to retrieve and store the estimates of mu, sigma, and kappa, so that I can generate the new variable yi. I have tried 'ereturn', 'scalar' and 'gen' statements both within the program and externally after ml maximise (when outside the program I have the additional problem of distinguishing between the two shape parameters currently both _cons in the output). Any help would be much appreciated! My code is currently along the lines of... /* Full log-likelihood */ program ggm, eclass version 10 args todo b lnf /* Define parameters of GGM */ tempvar mu sigma kappa mleval `mu' = `b', eq(1) mleval `sigma' = `b', eq(2) mleval `kappa' = `b', eq(3) /* Temporary variables to be used in likelihood */ tempvar n sumlny A B quietly gen double `n' = _N quietly egen double `sumlny' = total(ln($ML_y1)) quietly gen double `A' = abs(`kappa')^(-2) quietly egen double `B' = total(exp((((abs(`kappa'))*(sign(`kappa'))/(`sigma'))*(ln($ML_y1)-`mu')) )) /* Log-likelihood */ mlsum `lnf' = (`n'*(`A'-0.5)*ln(`A'))-(`n'*ln(`sigma'))-(`n'*lngamma(`A'))-`sumlny'+ /// ((sign(`kappa')*(sqrt(`A'))/(`sigma'))*(`sumlny'-`n'*`mu'))-(`A'*`B') /* Some of the attempts at extracting sigma */ scalar __sigma =_b[`sigma':_cons] gen __sigma =_b[`sigma':_cons] ereturn scalar sigma = _b[sigma:_cons] end * * 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/

**References**:**st: How to retrieve parameter estimates from an ML program, so they can be used in estimation of expected values, variances, etc...***From:*SLG Brilleman <sam.brilleman@bristol.ac.uk>

- Prev by Date:
**Re: Re: Re: st: How to graph means with correct SE after repeated ANOVA?** - Next by Date:
**st: Re: endogeneity in seemingly unrelated regression** - Previous by thread:
**st: How to retrieve parameter estimates from an ML program, so they can be used in estimation of expected values, variances, etc...** - Next by thread:
**Re: st: How to retrieve parameter estimates from an ML program, so they can be used in estimation of expected values, variances, etc...** - Index(es):