lm.object

Linear Least Squares Model Object

These are objects of classes
"lm" and
"mlm". They represent the fit of a linear model.
The "mlm" class is for multiple response models.

The residuals, fitted values, coefficients, and effects should be extracted
by the generic functions of the same name,
rather than by the \$ operator.
These functions do other handy things, like insert NAs where
na.action=na.exclude removed them.

Generation

This class of objects is returned from the lm function
to represent a fitted linear model.

Methods

The "lm" class of objects has methods for the following generic
functions:

- add1
- alias
- anova
- coef
- deviance
- drop1
- dummy.coef
- effects
- effects
- family
- formula
- hatvalues
- influence
- labels
- logLik
- model.frame
- model.matrix
- nobs
- predict
- print.summary
- proj
- qr
- residuals
- rstandard
- rstudent
- simulate
- step
- summary
- terms
- variable.names
- vcov

- add1
- case.names
- deviance
- drop1
- estVar
- predict
- summary
- vcov

Inheritance

The class "mlm" inherits from "lm".

Some of the fitted model objects inherit from "lm" and/or "mlm".
These include:

- "aov"
- "glm"
- "gam" (which inherits from "glm")

Structure

The following components must be included in a legitimate lm object.
For a multivariate response, the object returned has class "mlm",
and the coefficients, effects, fitted values, and residuals are all
matrices whose columns correspond to the response variables.

coefficients

the coefficients of the least-squares fit of the response to the
columns of the model matrix.
The names of the coefficients are the names of the
single-degree-of-freedom effects (the columns of the model matrix).
If the model is over-determined and singular.ok is set to TRUE,
the result contains missing values in the coefficients
corresponding to inestimable coefficients.

residuals

the residuals from the fit.
If weights are used, then the residuals are the raw residuals;
the weights are not taken into account.
If you need residuals that all have the same variance,
then use the residuals function with type="pearson".

effects

orthogonal, single-degree-of-freedom effects.
There are as many of these as observations.
The first rank of them correspond to degrees of freedom in the model
and are named accordingly;
their squares give the reduction in sum of squared residuals
due to each column in the model matrix.
The sum of the squares of the remaining effects equals
the sum of squared residuals in the fitted model.

rank

the computed rank (number of linearly independent columns in the model matrix).

fitted.values

the fitted values from the fit.
If weights are used, then the fitted values are not adjusted for the weights.

assign

an integer vector the length of the coefficients component.
The i'th element tells which term in attr(lm.object$terms, "term.labels")
the i'th coefficient corresponds to. (Zero indicates the intercept term).
Note that several coefficients can refer to the same term if the term involves
a factor or a call to a function like poly or splines::ns.

qr

optionally, the qr decomposition object.
See qr for its structure.
This depends on using method "qr", and the qr argument.

df.residual

the number of degrees of freedom for residuals.

contrasts

a list containing sufficient information to construct the contrasts
used to fit any factors occurring in the model.
The list contains entries that are either matrices or character vectors.
When a factor is coded by contrasts, the corresponding contrast matrix
is stored in this list.
Factors that appear only as dummy variables and variables in the model
that are matrices correspond to character vectors in the list.
The character vector has the level names for a factor or the column
labels for a matrix.

xlevels

a list with an component named for each predictor variable which is a factor
listing the levels thereof that are actually used in the model.

call

the call that produces the object, but with all of the arguments named.

terms

an object of class terms summarizing the formula: the result of
calling terms(formula).

model

a data frame with the columns from the original data that were
used in the model (both response and predictors).
Only included if model = TRUE.

x

optionally the model matrix, if x=TRUE.

y

optionally the response, if y=TRUE.

See Also