From p.dalgaard at biostat.ku.dk  Wed Jan  4 18:34:24 2006
From: p.dalgaard at biostat.ku.dk (p.dalgaard@biostat.ku.dk)
Date: Wed,  4 Jan 2006 18:34:24 +0100 (CET)
Subject: [Rd] update.formula gotcha (PR#8462)
Message-ID: <20060104173424.B5A0419FE8@slim.kubism.ku.dk>


(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



[Rd] update.formula gotcha (PR#8462)
p.dalgaard@biostat.ku.dk