When I fit a multivariate linear model, and the formula is defined

outside the call to lm(), the method summary.mlm() fails.

This works well:

> y <- matrix(rnorm(20),nrow=10)

> x <- matrix(rnorm(10))

> mod1 <- lm(y~x)

> summary(mod1)

...

But this does not:

> f <- y~x

> mod2 <- lm(f)

> summary(mod2)

Error en object$call$formula[[2L]] <- object$terms[[2L]] <-

as.name(ynames[i]) :

objeto de tipo 'symbol' no es subconjunto

I would say that the problem is in the following difference:

> class(mod1$call$formula)

[1] "call"

> class(mod2$call$formula)

[1] "name"

As far as I understand, summary.mlm() creates a list of .lm objects

from the individual columns of the matrices in the .mlm object, and then

it tries to change the second element of object$call$formula, to present

the name of the corresponding column as the response variable. But if

the formula has been defined outside the call to lm(), that element

cannot be modifed that way.

A bug, perhaps?

> sessionInfo()

R version 2.13.0 (2011-04-13)

Platform: i386-pc-mingw32/i386 (32-bit)

locale:

[1] LC_COLLATE=Spanish_Spain.1252 LC_CTYPE=Spanish_Spain.1252

[3] LC_MONETARY=Spanish_Spain.1252 LC_NUMERIC=C

[5] LC_TIME=Spanish_Spain.1252

attached base packages:

[1] stats graphics grDevices utils datasets methods base

--

Helios de Rosario MartÃnez

Researcher

______________________________________________

[hidden email] mailing list

https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide

http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.