s-news
[Top] [All Lists]

substitution in call to lme

To: <s-news@lists.biostat.wustl.edu>
Subject: substitution in call to lme
From: "Doug Bolgiano" <DougB@psbc.org>
Date: Fri, 1 Jun 2007 16:48:59 -0700
In-reply-to: <20070528102006.BB45C127BA4@smtp.biostat.wustl.edu>
References: <20070528102006.BB45C127BA4@smtp.biostat.wustl.edu>
Thread-index: AcehEcUJ+LTCjrLSRVuVjncV98hQ4QCzUifw
Thread-topic: substitution in call to lme
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.
*****************************************************************

<Prev in Thread] Current Thread [Next in Thread>
  • substitution in call to lme, Doug Bolgiano <=