Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: simulating random numbers from zero inflated negative binomial estimates


From   Ari Samaranayaka <ari.samaranayaka@ipru.otago.ac.nz>
To   <statalist@hsphsun2.harvard.edu>
Subject   Re: st: simulating random numbers from zero inflated negative binomial estimates
Date   Fri, 3 Jun 2011 17:03:58 +1200

Dear Paul
Thank you very much for the great help. Your are the first person to answer my question. Your answer works, and I understood the logic you used in your codes. Simulated random variates goes quite closely with observed data. I interpret this as a reasonable model fit. Great. Thank you.

I expected whenever the ZINB model fit is reasonably good, if we use the ZINB postestimation predict command to produce predicted numbers, those predicted numbers also should goes closely with observed data.
For example, if I use the command
predict expec, ir
then distribution of resultant values in "expec" should have similar distribution to observed data (because we do not specify an "exposure" in our model). However those 2 distributions quite different. Did I misinterpret the result from predict command.
Thank you again
Ari



On 3/06/2011 2:56 a.m., E. Paul Wileyto wrote:
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/



*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index