Hi,

Please could you tell me how do I simulate a random coefficient mixed poisson model?

How do I simulate the model below:

Code:
webuse epilepsy, clear

mepoisson seizures i.treat c.visit || subject: visit, irr
Is the following type of code correct in simulated a mixed random effects model poisson? [i don't think so]

Code:
clear
set obs 200

gen id=_n

expand 4

bysort id: gen visit=_n

gen treat = rbinomial(1,0.5)

gen re = sqrt(.80)*rnormal()
sum re
bysort id: replace re = re[1]

gen rc = sqrt(.50)*rnormal()
sum rc
bysort id: replace rc = rc[1]

gen xb=ln(6)+ln(.70)*visit+ln(.90)*treat + (re + rc*visit)

gen mu = exp(xb)
gen y = rpoisson(mu)

mepoisson y visit treat || id: visit, irr

Many thanks

A