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]
Re: st: simulating random numbers from zero inflated negative binomial estimates
From 
 
"E. Paul Wileyto" <[email protected]> 
To 
 
[email protected] 
Subject 
 
Re: st: simulating random numbers from zero inflated negative binomial estimates 
Date 
 
Thu, 02 Jun 2011 10:56:50 -0400 
I'm not sure whether anyone has answered this yet.
First, read the help on zinb post-estimation commands.  There are many 
flavors of "predict" listed there.  You will need three of them before 
you start generating random numbers.  The first one you will need is:
predict p1, pr
That will generate a new variable, p1, which will be the predicted 
probability of an inflated zero.  All the work is done for you.
The second predicted quantity you will need is:
predict lp, xb
That will generate the linear combination of predictor variables 
weighted by coefficients for the negative binomial part of the model.  
Finally, you will need:
predict alpha, xb eq(#3)
which will generate a variable containing the overdispersion parameter 
for the negative binomial.  With those three bits, you can get on to 
simulating.
Here's my script:
zinb cignums drug  week, inf(drug  week)
predict p1 , pr
predict p2 , xb
predict lnalpha , xb eq(#3)
gen alph=exp(lnalpha)
gen xg=rgamma(1/alph, alph*p2)
gen pg=rpoisson(xg)
gen zi=runiform()>p1
gen newcigs=zi*pg
zinb newcigs drug  week, inf(drug  week)
Paul
On 6/1/2011 7:13 PM, Ari Samaranayaka wrote:
Deaf statalist members
Can some one help me with this question with regards to zero-inflated 
negative binomial regression (ZINB command) . I need to see how good 
the fitted model by comparing model outputs with observations. For 
this, I aim to simulate random numbers from fitted model to compare 
with observed numbers.
Can some one tell me how to simulate random numbers from the fitted 
model please? Is there any post estimation command for this? if not, 
is it possible to use estimated regression coefficients?
Thank you
Ari-Sam
*
*   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/
--
E. Paul Wileyto, Ph.D.
Senior Research Investigator, Department of Biostatistics&  Epidemiology
Director of Biostatistics, Tobacco Use Research Center
School of Medicine, U. of Pennsylvania
3535 Market Street, Suite 4100
Philadelphia, PA  19104-3309
215-746-7147
Fax: 215-746-7140
[email protected]
*
*   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/