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 |
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 |
Sun, 5 Jun 2011 13:15:01 +1200 |

Thank you Paul, all you said makes sense to me, and very helpful. Ari On 4/06/2011 2:27 a.m., E. Paul Wileyto wrote:

I've never used predict with the ir option, but I assume it predicts amean incidence rate GIVEN that class membership is not an inflatedzero. I suspect that it will not include the natural variability ofthe outcome, let alone zero-inflation. What our simulation does istake those predicted linear model, adds in the natural variability fornegative binomial, and then adds zero-inflation on top of it, all toreflect the natural variation you would see.In order to gauge whether the estimate is working well, you shouldsimulate the data multiple times, and generate means for the pointestimates, and coverage probabilities. What we did was to take ouroriginal model, assumed the estimated parameters are true, and thenused them to simulate only one more data set. Repeat that last step200x, and see how often your CI includes your true value.Looking at the script again. This first part grabs the estimates fromfitting your data:zinb cignums drug week, inf(drug week) predict p1 , pr predict p2 , xb predict lnalpha , xb eq(#3) gen alph=exp(lnalpha) This next part simulates the data and should be repeated many times. 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)There are many ways to collect the parameter estimates and CI's fromthe simulations. I'll leave that to you.P On 6/3/2011 1:03 AM, Ari Samaranayaka wrote:Dear PaulThank you very much for the great help. Your are the first person toanswer my question. Your answer works, and I understood the logic youused in your codes. Simulated random variates goes quite closely withobserved data. I interpret this as a reasonable model fit. Great.Thank you.I expected whenever the ZINB model fit is reasonably good, if we usethe 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, irthen distribution of resultant values in "expec" should have similardistribution to observed data (because we do not specify an"exposure" in our model). However those 2 distributions quitedifferent. Did I misinterpret the result from predict command.Thank you again Ari

* * 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: simulating random numbers from zero inflated negative binomial estimates***From:*Ari Samaranayaka <ari.samaranayaka@ipru.otago.ac.nz>

**Re: st: simulating random numbers from zero inflated negative binomial estimates***From:*"E. Paul Wileyto" <epw@mail.med.upenn.edu>

**Re: st: simulating random numbers from zero inflated negative binomial estimates***From:*Ari Samaranayaka <ari.samaranayaka@ipru.otago.ac.nz>

**Re: st: simulating random numbers from zero inflated negative binomial estimates***From:*"E. Paul Wileyto" <epw@mail.med.upenn.edu>

- Prev by Date:
**Re: st: More elegant code . . .?** - Next by Date:
**Re: st: More elegant code . . .?** - Previous by thread:
**Re: st: simulating random numbers from zero inflated negative binomial estimates** - Next by thread:
**st: Saving Inter-item Correlations or Alphas as New Variables** - Index(es):