Sunday, July 18, 2010

Npmlreg and Flexmix

In my attempt to estimate a mixture regression model for the long-term impact of prenatal famine exposure, I compared results obtained from NPMLREG and Flexmix using the "rainfall" data set came with the package "forward" and was able to achieve identical results from:
m.np <- allvc(cbind(Cases, Total-Cases) ~ Rain, random= ~1|ID, data=rainfall, k=2, family=binomial(logit))
and 
m.mix <- stepFlexmix(cbind(Cases, Total-Cases) ~ 1|ID, model=FLXMRglmfix(family="binomial", fixed=~Rain), k=2, nrep=5, data=rainfall)
To test the random effect model, I created the new variable ID by:
rainfall$ID <- seq(from=1, to=34, by=1)
With Flexmix, it is possible to go a step further and let the treatment variable to vary between latent groups by: 
m.mix <- stepFlexmix(cbind(Cases, Total-Cases) ~ Rain|ID, model=FLXMRglmfix(family="binomial"), k=2, nrep=5, data=rainfall)

No comments:

Counter