coefficients
Extract Information from a Model

Description

Functions that extract the coefficients, residuals, and fitted values from a fitted model.

Usage

coefficients(object, ...)
coef(object, ...)
## Default S3 method:
coef(object, ...)
## S3 method for class 'listof':
coef(object, ...)

residuals(object, ...) resid(object, ...)

fitted.values(object, ...) fitted(object, ...)

Arguments

object any object that represents a fitted model, or, by default any object with a component named by the name of the extractor function.
... additional arguments to pass to the function defined in the object.
Value
returns the the coefficients, residuals, or fitted values defined by the model in object. While for some models the return values are identical to the component of the object with the same name, we recommend that you use the extractor functions, since these will call the appropriate method for this class of object. For example, residuals from generalized linear models come in four flavors, and the most useful one is typically not the component.
Methods
The following table displays the available methods for each function.
Function: "coef" "residuals" "fitted"
aov x
arima x x x
default x x
discrim x
factanal x x
glm x
listof x
lm x x
lmList x x x
nls x x x
Note: To encourage you to use the extractor function rather than the component, there are three abbreviated versions of these functions: coef(); resid(); and fitted().
Singular models
When a model is over-specified, the standard fitting method permutes the columns of the model matrix, which therefore also permutes the corresponding coefficients and effects. This is another case where the components for these quantities behave a little differently from the values of the corresponding functions. If fit is a fitted, over-determined model, then coef(fit) only returns the full-rank part of the coefficients, while fit\$coef returns coefficients for all the columns in the original model matrix. In the latter case, elements that are aliased with earlier degrees of freedom are returned as missing values (NAs). In breaking down the coefficients or effects by terms, the distinction is also present. The component assign refers to the original model matrix, so it defines the degrees of freedom in fit\$coef. Another component, R.assign is produced in the singular case to index terms in the R matrix, and also in coef(fit). For more details, see lm.object.
See Also
effects, lm.object, predict.
Examples
kyph.glm1 <- glm(Kyphosis ~ Age + Start + Number, family=binomial,
    data=Sdatasets::kyphosis)

coef(kyph.glm1) ## (Intercept) Age Start Number ## -2.036932 0.01093048 -0.20651 0.410601

residuals(kyph.glm1) ## 1 2 3 4 5 ## -0.7707923 -0.5111615 1.189314 -1.106713 -0.2461915 ## . ## . ## .

Package stats version 6.1.1-7
Package Index