Skip to content
Prev 44836 / 398506 Next

structure of mlm objects ?

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.