Modified Functions for Summarizing Linear, Generalized Linear, and Some Other Models
car package replacements for the summary
(S
) and confint
(Confint
) functions for lm
, glm
, multinom
, and polr
objects, with additional arguments but the same defaults as the original functions. The Confint
method for "polr"
objects profiles the likelihood to get confidence intervals for the regression parameters but uses Wald intervals for the thresholds.
Default methods that call the standard R summary
and confint
functions are provided for the S
and Confint
generics, so the car functions should be safe to use in general. The default method for Confint
also assumes that there is an appropriate coef
method. For briefer model summaries, see brief
.
S(object, brief, ...) ## S3 method for class 'lm' S(object, brief=FALSE, correlation = FALSE, symbolic.cor = FALSE, vcov. = vcov(object, complete=FALSE), header = TRUE, resid.summary = FALSE, adj.r2 = FALSE, ...) ## S3 method for class 'glm' S(object, brief=FALSE, exponentiate, dispersion, correlation = FALSE, symbolic.cor = FALSE, vcov. = vcov(object, complete=FALSE), header = TRUE, resid.summary = FALSE, ...) ## S3 method for class 'multinom' S(object, brief=FALSE, exponentiate=FALSE, ...) ## S3 method for class 'polr' S(object, brief=FALSE, exponentiate=FALSE, ...) ## S3 method for class 'lme' S(object, brief=FALSE, correlation=FALSE, ...) ## S3 method for class 'lmerMod' S(object, brief=FALSE, KR=FALSE, correlation=FALSE, ...) ## S3 method for class 'glmerMod' S(object, brief=FALSE, correlation=FALSE, exponentiate, ...) ## S3 method for class 'data.frame' S(object, brief=FALSE, ...) ## Default S3 method: S(object, brief, ...) ## S3 method for class 'S.lm' print(x, digits = max(3, getOption("digits") - 3), symbolic.cor = x$symbolic.cor, signif.stars = getOption("show.signif.stars"), ...) ## S3 method for class 'S.glm' print(x, digits = max(3L, getOption("digits") - 3L), symbolic.cor = x$symbolic.cor, signif.stars = getOption("show.signif.stars"), ...) ## S3 method for class 'S.multinom' print(x, digits = max(3, getOption("digits") - 3), signif.stars = getOption("show.signif.stars"), ...) ## S3 method for class 'S.polr' print(x, digits = max(3, getOption("digits") - 3), signif.stars = getOption("show.signif.stars"), ...) ## S3 method for class 'S.lme' print(x, digits=max(3, getOption("digits") - 3), signif.stars = getOption("show.signif.stars"), ...) ## S3 method for class 'S.lmerMod' print(x, digits=max(3, getOption("digits") - 3), signif.stars = getOption("show.signif.stars"), ...) ## S3 method for class 'S.glmerMod' print(x, digits=max(3, getOption("digits") - 3), signif.stars = getOption("show.signif.stars"), ...) Confint(object, ...) ## S3 method for class 'lm' Confint(object, estimate=TRUE, parm, level=0.95, vcov.=vcov(object, complete=FALSE), ...) ## S3 method for class 'glm' Confint(object, estimate=TRUE, exponentiate=FALSE, vcov., dispersion, type=c("LR", "Wald"), ...) ## S3 method for class 'polr' Confint(object, estimate=TRUE, exponentiate=FALSE, thresholds=!exponentiate, ...) ## S3 method for class 'multinom' Confint(object, estimate=TRUE, exponentiate=FALSE, ...) ## S3 method for class 'lme' Confint(object, estimate=TRUE, level=0.95, ...) ## S3 method for class 'lmerMod' Confint(object, estimate=TRUE, level=0.95, ...) ## S3 method for class 'glmerMod' Confint(object, estimate=TRUE, level=0.95, exponentiate=FALSE, ...) ## Default S3 method: Confint(object, estimate=TRUE, level=0.95, vcov., ...)
object |
a model or other object, e.g., of class |
exponentiate |
for a |
correlation, symbolic.cor |
see |
x, digits, signif.stars |
see |
dispersion |
see |
vcov. |
either a matrix giving the estimated covariance matrix of the estimates, or a function that
when called with |
header |
if |
resid.summary |
if |
adj.r2 |
if |
brief |
if |
KR |
if |
parm, level |
see |
estimate |
show the estimated coefficients in the confidence-interval table; default is |
thresholds |
show confidence intervals for the estimated thresholds in the |
type |
if |
... |
additional arguments to be passed down, for consistency with |
All these functions mimic functions in the stats and other standard R packages for summarizing aspects of linear, generalized linear, and some other statistical models. The
S
function also provides an alterntive to summary
for data frames, treating character variables as if they were factors.
The S
and Confint
functions add support for the vcov.
argument for linear models, which allows specifying a covariance matrix for the regression coefficients other than the usual covariance matrix returned by the function vcov
. This argument may be either the name of a function, so that the call to vcov.(object)
returns a covariance matrix, or else vcov.
is set equal to a covariance matrix. For example, setting vcov.=hccm
uses 'proposal 3' described by Long and Ervin (2000) for a sandwich coefficient-variance estimator that may be robust against nonconstant variance (see hccm
). Setting vcov. = hccm(object, type = "hc2")
would use the matrix returned by the hccm
function using proposal 2. For use with a bootstrap, see the examples below. The overall F-test in the S.lm
output uses the supplied covariance matrix in a call to the linearHypothesis
function.
The supplied print
method for S.lm
(and for other S
methods) has additional arguments to customize the standard summary.lm
output. Standard output is obtained by setting resid.summary=TRUE, adj.r2=TRUE
.
Using a heterscedasticy-corrected covariance matrix computed using hccm
with GLMs other than Gaussian is not justified; see the article by Freedman (2006).
The Summary.glm
method for models fit with the log or logit link by default prints a table of exponentiated coefficients and their confidence limits; Summary.multinom
and Summary.polr
optionally print tables of exponentiated coefficients.
The S.lm
and S.glm
functions return a list with all the elements shown at summary.lm
and summary.glm
. The S.multinom
and S.polr
functions return a list with all the elements shown at summary.multinom
and summary.polr
plus potentially a table of exponentiated coefficients and confidence bounds.
The Confint.lm
function returns either the output from confint.lm
if
vcov. = vcov
or Wald-type confidence intervals using the supplied covariance matrix for any other choice of vcov.
.
Finally, Confint
applied to any object that does not inherit from "lm"
, "multinom"
, or "polr"
simply calls confint
, along with, by default, using coef
to add a column of estimates to the confidence limits.
Sanford Weisberg sandy@umn.edu
Freedman, David A. (2006). On the so-called Huber sandwich estimator and robust standard errors. The American Statistician, 60, 299-302.
Long, J. S. and Ervin, L. H. (2000) Using heteroscedasity consistent standard errors in the linear regression model. The American Statistician 54, 217–224.
White, H. (1980) A heteroskedastic consistent covariance matrix estimator and a direct test of heteroskedasticity. Econometrica 48, 817–838.
brief
, summary
, confint
, coef
,
summary.lm
, confint
, vcov.lm
, hccm
,
Boot
, linearHypothesis
mod.prestige <- lm(prestige ~ education + income + type, Prestige) S(mod.prestige, vcov.=hccm) S(mod.prestige, brief=TRUE) Confint(mod.prestige, vcov.=hccm) # A logit model mod.mroz <- glm(lfp ~ ., data=Mroz, family=binomial) S(mod.mroz) # use for data frames vs. summary() Duncan.1 <-Duncan Duncan.1$type <- as.character(Duncan$type) summary(Duncan.1) S(Duncan.1) ## Not run: # Using the bootstrap for standard errors b1 <- Boot(mod.prestige) S(mod.prestige, vcov.= vcov(b1)) Confint(b1) # run with the boot object to get corrected confidence intervals ## End(Not run)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.