Multiple Linear Models

Share:

Description

Fits multiple linear models.

Usage

1
    mlm(formula, data, vars, save.residuals=FALSE)

Arguments

formula

an object of class formula (or one that can be coerced to that class): a symbolic description of the models to be fitted.

data

an optional data frame, list or environment (or object coercible by as.data.frame to a data frame) containing the variables in the model.

vars

a character vector of variables of interest.

save.residuals

whether model residuals should be stored and returned.

Value

A list with elements:

coefficients

if 'vars' is missing or non-empty, an array (or data frame, if vars contains a single element) of regression coefficient estimates (coef), standard errors (coef.se), and corresponding p-values (pval).

residuals

if save.residuals is TRUE, a matrix of model residuals.

See Also

lm

Examples

1
2
3
4
5
6
    coefs <- matrix(runif(6*10), 6, 10)
    X <- matrix(rnorm(100*5), 100, 5)
    Y <- cbind(1, X) 

    models <- mlm(Y ~ X)
    str(models)