[Rd] update.formula gotcha (PR#8462)

p.dalgaard@biostat.ku.dk p.dalgaard at biostat.ku.dk
Wed Jan 4 18:34:24 CET 2006


(Reported by Søren Højsgaard)

Looks like update.formula is stripping of parentheses in cases where
they shouldn't be

> update.formula (Reaction ~ Days + (Days | Subject), . ~ . + I(Days^2))
Reaction ~ Days + Days | Subject + I(Days^2)

Notice that the right hand side is interpreted with the bar at the root
of the parse tree, as in
(Days + Days) | (Subject + I(Days^2)):

> f <- update.formula (Reaction ~ Days + (Days | Subject), . ~ . + I(Days^2))
> f[[3]]
Days + Days | Subject + I(Days^2)
> f[[3]][[1]]
`|`

This confuses lmer() rather badly:

library(lme4)
example(lmer)
update(fm1,formula = . ~ . + I(Days^2))

   ------>

Error in x[[2]] : object is not subsettable
Error in model.matrix(eval(substitute(~T, list(T = x[[2]]))), frm) :
        unable to find the argument 'object' in selecting a method for function 'model.matrix'


-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907



More information about the R-devel mailing list