[R] using variables in obj$model
Prof Brian Ripley
ripley at stats.ox.ac.uk
Mon Oct 27 13:03:44 CET 2003
Model frames do not contain interactions, they contain variables.
`a:b' is not the name of a variable whereas A is.
On Mon, 27 Oct 2003, Vito Muggeo wrote:
> dear all,
> for some reason I am intersted in updating a glm taking variables from its
> model argument, namely:
>
> > dati<-data.frame(y=runif(10),x=1:10)
> > obj<-glm(y~x,data=dati)
> > obj$model[,c("A","a:b")]<-cbind(rnorm(10),runif(10))
> > names(obj$model)
> [1] "y" "x" "A" "a:b"
> > update(obj,.~.+A,data=obj$model) #it works
>
> Call: glm(formula = y ~ x + A, data = obj$model)
> ............[SNIP]
>
> > update(obj,.~.+A+a:b,data=obj$model) #it does not work
> Error in eval(expr, envir, enclos) : Object "a" not found
--
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