Skip to content

structure of mlm objects ?

2 messages · ZABALZA-MEZGHANI Isabelle, Brian Ripley

#
Hello,

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".
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.

Thanks in advance,

Isabelle Zabalza.
#
On Wed, 25 Feb 2004, ZABALZA-MEZGHANI Isabelle wrote:

            
Actually of class c("mlm", "lm").
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.