[R] R vs Stata on generalized linear mixed models: glmer and xtmelogit

Antonio.Gasparrini at lshtm.ac.uk Antonio.Gasparrini at lshtm.ac.uk
Tue Aug 19 02:55:44 CEST 2008


Hello,
I have compared the potentials of R and Stata about GLMM, analysing the dataset 'ohio' in the package 'faraway' (the same dataset is analysed with GEE in the book 'Extending the linear model with R' by Julian Faraway).
Basically, I've tried the 2 commands 'glmmPQL' and 'glmer' of R and the command 'xtmelogit' of Stata. If I'm not wrong, 'glmer' uses the Laplacian approximation as default, corresponding to adaptive Gauss-Hermite approximation with only 1 point, while 'xtmelogit' uses 7 points. In order to compare them, I tried also to change the corresponding parameters.
 
This is the code for R:
 
rm(list=ls())
library(faraway); library(lme4); library(MASS)
data <- ohio
pql  <- glmmPQL(resp~smoke+factor(age), random=~1|id, family=binomial,data)
summary(pql)$tTable["smoke",1:2]
lap <- glmer(resp~smoke+factor(age)+(1|id), family=binomial,data)
attributes(summary(lap))$coefs["smoke",1:2]
agq7 <- glmer(resp~smoke+factor(age)+(1|id),nAGQ=7,family=binomial,data)
write.csv(data,file="data.csv")
 
This is the code for Stata:
 
clear
insheet using data.csv
xi: xtmelogit resp smoke i.age, || id:, covariance(independent) laplace
xi: xtmelogit resp smoke i.age, || id:, covariance(independent)
 
Results:
- Both the point estimate and the standard error for the fixed effect, and the standard deviation for random effect of 'glmmPQL' are lower than 'glmer'
- 'glmer' and 'xtmelogit' with Laplacian approximation give very similar results. 'xtmelogit' with 7 points gives similar point estimates for fixed effects, but a different (lower) estimate for the standard deviation of the random effect (as expected)
- glmer doesn't work with the parameter 'nAGO' (number of points) set to 7, returning 'Code not yet written'
 
My questions:
1) Is the difference between 'glmmPQL' and 'glmer' expected? Which is more reliable?
2) Is there a way to set the parameter 'nAGO' to 7 or perform the same analysis in another way?
3) Is there a tutorial on the use of lme4, especially to handle the results (summary, coef, etc.)?
 
Thank you for your time

Antonio Gasparrini
Public and Environmental Health Research Unit (PEHRU)
London School of Hygiene & Tropical Medicine
Keppel Street, London WC1E 7HT, UK
Office: 0044 (0)20 79272406 - Mobile: 0044 (0)79 64925523
http://www.lshtm.ac.uk/people/gasparrini.antonio ( http://www.lshtm.ac.uk/pehru/ )



More information about the R-help mailing list