[R] as.formula(string) and augPred in lme

ripley@stats.ox.ac.uk ripley at stats.ox.ac.uk
Thu Jan 30 10:06:02 CET 2003


On Thu, 30 Jan 2003, Dieter Menne wrote:

> Using formulas constructed from strings only
> partially works for me in lme:
> 
> library(nlme)
> data(Orthodont)
> 
> fm2<-lme(as.formula("distance~age"),data=Orthodont,random=~1|Subject)
> summary(fm2) # works
> augPred(fm2) # fails
> #Error in inherits(object, "formula") : 
> #Argument "object" is missing, with no default
> 
> I assume that my use of as.formula is wrong, but what's the right way?
> Or at least a workaround?

The error is in predict.lme, I think.  That has

eval(as.call(mCall[["fixed"]][-2]))

and I think

eval(mCall[["fixed"]])[-2]

may be the intention.

Workaround:  use lme(distance ~ age, data=Orthodont,random=~1|Subject)
or if you need to construct a formula, use

form <- as.formula("distance ~ age")
fm2 <- eval(substitute(lme(form, data=Orthodont, random=~1|Subject), list(form=form)))

or alter predict.lme as indicated).

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list