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]

From |
"Brent McSharry" <brent@focused-light.net> |

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

Subject |
Re: st: Fw: appling a gamma distribution random effects model. SAS to Stata |

Date |
Thu, 8 Dec 2011 10:53:56 +1300 |

Thanks for the suggestion. the entire SAS code is: proc nlmixed data=LOS_2009;

mu=exp(eta); b=mu/a; model los_days ~ gamma(a,b); random u ~ normal(0,s2u) subject=PCODE out=random; predict mu out=predout; run;

It has more of a flavour of fitting a model than of generating randomdeviates

To: <statalist@hsphsun2.harvard.edu> Sent: Thursday, December 08, 2011 12:30 AM

I suspect that Brent would be better off showing the whole of the SAS codeso that someone bilingual (emphatically not me) can translate. It has moreof a flavour of fitting a model than of generating random deviates to me,but no amount of speculation can replace expertise.Nick n.j.cox@durham.ac.uk Maarten Buis On Wed, Dec 7, 2011 at 10:31 AM, Brent McSharry wrote:I have some SAS code to apply a model to patient data, and I would liketoapply this to our local data (the model is externally validated topredictlength of ICU stay in days). Unfortunately I have no idea about SAS syntax, and exclusively use stata. the first part of the SAS code obviously generates a linear coefficient & applies an exp link ie in Stata: scalar s2u = 1 scalar a = 2 generate linCoef = 0.2 + varA * 0.4 + varB*-0.02 ... generate mu= exp(linCoef) gen b = mu/a and then i am affraid I am lost (particularly as the = signs stop and the tildas ~ begin) model los_days ~ gamma(a,b); random u ~ normal(0,s2u) subject=varY out=random; predict mu out=predout; run;I have no idea about the syntax in Some Alternative Software either, but the tilde is often used for "distributed as", which makes sense in your case. I guess you want to create a random variables from that validated model. Now you need to figure out where exactly the random term enters the model. I guess it is added to the linear predictor, but you need to check that in the documentation of that model. You also need to check the exact parameterization of the gamma distribution used in that model and possibly translate that to the parameterization used in -rgamma()-. After that it will be a couple of -generate- commands calling the -normal()- and -rgamma()- functions, see -help random_number_functions-.

* * 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: Fw: appling a gamma distribution random effects model. SAS to Stata***From:*"Brent McSharry" <brent@focused-light.net>

**Re: st: Fw: appling a gamma distribution random effects model. SAS to Stata***From:*Maarten Buis <maartenlbuis@gmail.com>

**RE: st: Fw: appling a gamma distribution random effects model. SAS to Stata***From:*Nick Cox <n.j.cox@durham.ac.uk>

- Prev by Date:
**Re: st: London meeting 2012 will be September 13-14** - Next by Date:
**Re: st: RE: how to store the statistics calculated in a loop as a table?** - Previous by thread:
**RE: st: Fw: appling a gamma distribution random effects model. SAS to Stata** - Next by thread:
**st: Query about bootstrapping and R-squared** - Index(es):