[R-sig-ME] Loops lme4

David Duffy David.Duffy at qimr.edu.au
Wed Apr 11 07:17:21 CEST 2012


Your example data has very few of the variables in your example model. 
But anyway, I guess you need to look at the results from

> str(m126)

and work out which bits you want to pull out, eg

summary(m126)@coefs[,1:2] contains the beta and SE from the fixed effects 
bit, so

#
# No, not tested
#
se <- beta <- matrix(NA, nr=Nmodels, nc=Nfixef)
all.xvars <-  c("elev",  "Sobs", etc )
colnames(se) <- colnames(beta) <- c("(Intercept)", all.xvars)

for(i in seq(1, Nmodels)) {
   xvars <- make.list.of.xvars(i, all.xvars)
   form <- make.formula(i, xvars, zvars)
   mod <- lmer(form, data=x)
   fixed <- summary(mod)@coefs[,1:2])
   beta[i, xvars] <- fixed[,1]
   se[i, xvars] <- fixed[,2]
}

-- 
| David Duffy (MBBS PhD)                                         ,-_|\
| email: davidD at qimr.edu.au  ph: INT+61+7+3362-0217 fax: -0101  /     *
| Epidemiology Unit, Queensland Institute of Medical Research   \_,-._/
| 300 Herston Rd, Brisbane, Queensland 4029, Australia  GPG 4D0B994A v



More information about the R-sig-mixed-models mailing list