I'm trying to write a function that allows me to automate the fitting of
a series of lmes. The data that I want to fit is in a S data frame with
the dependent variable, fixed effects and random effects all being
variables in the data frame.
The model can be written y = X1b1 + X2b2 + Zu + e. For my purposes,
X1 doesn't change, but I want to vary X2 (in a predictable fashion) over
subsets of the variables in the data frame.
Here's my (non-functioning) function. Apparently arguments are being
evaluated incorrectly. Any suggestions would be appreciated.
multLME <- function(data.fr,dep,fxdRet,fxdChg,grps)
{
nf <- length(fxdChg)
LMEs <- vector("list",nf)
rndm <- paste("~ 1 | ",substitute(grps))
dfrm <- paste(substitute(data.fr))
for(i in 1:nf) {
colChg <- fxdChg[i]
fxd <- paste(substitute(dep), " ~ ",
substitute(fxdRet), " + ", colChg)
LMEs[i] <- do.call("lme", list(fixed = fxd, data = dfrm,
random = rndm, na.action = na.exclude))
}
return(LMEs)
}
Thanks,
Doug Bolgiano
Biostatistician
Puget Sound Blood Center
Seattle, WA 98104
*****************************************************************
This e-mail and any attachments may contain confidential and
privileged information. It has been scanned for viruses. If you
are not the intended recipient, please notify the sender
immediately by return e-mail, delete this e-mail and destroy any
copies. Any dissemination, use, review, disclosure, or
distribution of this information by a person other than the
intended recipient is unauthorized and may be illegal.
*****************************************************************
|