On Wed, 25 Feb 2004, ZABALZA-MEZGHANI Isabelle wrote:
> I am using the function "lm" to fit several responses at the same
time (100
> responses). At the end of the fit, I get an object of class
"mlm".
Actually of class c("mlm", "lm").
> I would like to know if there is a way to access to each of the 100
> underlying models separately (is it a list, ... ?). Which syntax should I
> use to see and use the 15th model (for instance) just like it is possible
> for classical "lm" objects.
You don't have 100 underlying fits. All the information is for one set
of x's and 100 sets of y, and that relating only to x is stored only once.
The following simple function will extract the i'th fit.
mlm2lm <- function(fit, i)
{
for(k in c("coefficients", "residuals",
"effects", "fitted.values"))
fit[[k]] <- fit[[k]][, i]
class(fit) <- "lm"
fit
}
albeit with the wrong call, so use carefully.
--
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