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.
This class of objects is returned from the lm function to represent a fitted linear model.
The "lm" class of objects has methods for the following generic functions:
The generic functions that have methods for "mlm" are:
The class "mlm" inherits from "lm".
Some of the fitted model objects inherit from "lm" and/or "mlm". These include:
The following components must be included in a legitimate lm object.
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.
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".
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.
the computed rank (number of linearly independent columns in the model matrix).
the fitted values from the fit. If weights are used, then the fitted values are not adjusted for the weights.
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.
optionally, the qr decomposition object. See qr for its structure. This depends on using method "qr", and the qr argument.
the number of degrees of freedom for residuals.
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.
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.
the call that produces the object, but with all of the arguments named.
an object of class terms summarizing the formula: the result of calling terms(formula).
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.
optionally the model matrix, if x=TRUE.
optionally the response, if y=TRUE.
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.
See Also
lm, coefficients.
Package stats version 6.0.0-69
Package Index