[R] bug in predict.lme?

Arne.Muller@sanofi-aventis.com Arne.Muller at sanofi-aventis.com
Wed Jun 8 13:43:34 CEST 2005


Dear All,

I've come across a problem in predict.lme. Assigning a model formula to a  variable and then using this variable in lme (instead of typing the formula into the formula part of lme) works as expect. However, when performing a predict on the fitted model I gan an error messag - predict.lme (but not predictlm) seems to expect a 'properly' typed in formula and a cannot extract the formula from the variable. THe code below demonstrates this.

Is this a known or expected behavour of predict.lme or is this a bug?

	kind regards,

	Arne

(R-2.1.0)
> library(nlme)
...
> mod <- distance ~ age + Sex # example from ?lme
> mod
distance ~ age + Sex
> fm2 <- lme(mod, data = Orthodont, random = ~ 1)
> anova(fm2)
            numDF denDF  F-value p-value
(Intercept)     1    80 4123.156  <.0001
age             1    80  114.838  <.0001
Sex             1    25    9.292  0.0054
> fm2
Linear mixed-effects model fit by REML
  Data: Orthodont 
  Log-restricted-likelihood: -218.7563
  Fixed: mod 
         ^^^^
...

> predict(fm2,  Orthodont)
Error in mCall[["fixed"]][-2] : object is not subsettable

> fm2 <- update(fm2, . ~ .) # this replaces "mod" by the contents of variable mod
> fm2
Linear mixed-effects model fit by REML
  Data: Orthodont 
  Log-restricted-likelihood: -218.7563
  Fixed: distance ~ age + Sex 
  ...

> predict(fm2,  Orthodont)
     M01      M01      M01      M01  ... 
    25.39237 26.71274 28.03311 29.35348 21.61052 ...
 

> fm2 <- lm(mod, data = Orthodont)
> predict(fm2,  Orthodont)
       1        2        3        4 ...
22.98819 24.30856 25.62894 26.94931 ...




More information about the R-help mailing list