S.Rdcar 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., ...)a model or other object, e.g., of class "lm" as produced by a call to lm.
for a "glm" or "glmerMod" model using the log or logit link, or a
"polr" or "multinom" model, show exponentiated coefficient estimates and confidence bounds.
see summary.lm
see summary.lm
see summary.glm
either a matrix giving the estimated covariance matrix of the estimates, or a function that
when called with object as an argument returns an estimated covariance matrix of the estimates.
The default of vcov. = vcov uses the usual estimated covariance matrix. Other choices include
the functions documented at hccm. See example below for using a bootstrap to estimate the
covariance matrix.
Note that arguments supplied to ... are not passed to vcov. when it's a function; in this case either use an anonymous function in which the
additional arguments are set, or supply the coefficient covariance matrix directly.
For the glm methods of Confint and S, if the vcov. or
dispersion argument is specified, then Wald-based confidence limits are computed;
otherwise the reported confidence limits are computed by profiling the likelihood.
NOTE: The dispersion and vcov. arguments may not both be specified.
if TRUE, print the header for the summary output, default is TRUE
if TRUE, print the five-number summary of the residuals in the summary, defaults to FALSE
if TRUE, print the adjusted r-squared in the summary, default is FALSE
if TRUE, set header, resid.summary and adj.r.squared to FALSE, and suppress exponeniated coefficients for GLMs with log or logit link. For a data frame, equivalent to use of brief.
if TRUE (default is FALSE), compute Kenward-Roger standard errors and
Satterthwaite degrees of freedom for t-tests. Warning: This computation can be very time-consuming.
see confint
show the estimated coefficients in the confidence-interval table; default is TRUE.
show confidence intervals for the estimated thresholds in the "polr" model.
if "LR" (the default) compute confidence intervals based on the LR statistics by profiling the likelihood; if "Wald" base confidence intervals on the Wald statistic using the coefficient standard error and the normal distribution.
additional arguments to be passed down, for consistency with summary and confint methods
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.
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)
#> Call: lm(formula = prestige ~ education + income + type, data = Prestige)
#> Standard errors computed by hccm
#>
#> Coefficients:
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) -0.6229292 5.2381025 -0.119 0.905593
#> education 3.6731661 0.6982758 5.260 9.16e-07 ***
#> income 0.0010132 0.0002672 3.793 0.000265 ***
#> typeprof 6.0389707 3.7951209 1.591 0.114948
#> typewc -2.7372307 2.4384681 -1.123 0.264531
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Residual standard deviation: 7.095 on 93 degrees of freedom
#> (4 observations deleted due to missingness)
#> Multiple R-squared: 0.8349
#> F-statistic: 120.2 on 4 and 93 DF, p-value: < 2.2e-16
#> AIC BIC
#> 669.02 684.52
#>
S(mod.prestige, brief=TRUE)
#> Coefficients:
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) -0.6229292 5.2275255 -0.119 0.905
#> education 3.6731661 0.6405016 5.735 1.21e-07 ***
#> income 0.0010132 0.0002209 4.586 1.40e-05 ***
#> typeprof 6.0389707 3.8668551 1.562 0.122
#> typewc -2.7372307 2.5139324 -1.089 0.279
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Residual standard deviation: 7.095 on 93 degrees of freedom
#> (4 observations deleted due to missingness)
#> Multiple R-squared: 0.8349
#> F-statistic: 117.5 on 4 and 93 DF, p-value: < 2.2e-16
#> AIC BIC
#> 669.02 684.52
#>
Confint(mod.prestige, vcov.=hccm)
#> Standard errors computed by hccm
#> Estimate 2.5 % 97.5 %
#> (Intercept) -0.622929165 -1.102476e+01 9.778904256
#> education 3.673166052 2.286529e+00 5.059803411
#> income 0.001013193 4.826801e-04 0.001543706
#> typeprof 6.038970651 -1.497387e+00 13.575328718
#> typewc -2.737230718 -7.579545e+00 2.105083723
# A logit model
mod.mroz <- glm(lfp ~ ., data=Mroz, family=binomial)
S(mod.mroz)
#> Call: glm(formula = lfp ~ ., family = binomial, data = Mroz)
#>
#> Coefficients:
#> Estimate Std. Error z value Pr(>|z|)
#> (Intercept) 3.182140 0.644375 4.938 7.88e-07 ***
#> k5 -1.462913 0.197001 -7.426 1.12e-13 ***
#> k618 -0.064571 0.068001 -0.950 0.342337
#> age -0.062871 0.012783 -4.918 8.73e-07 ***
#> wcyes 0.807274 0.229980 3.510 0.000448 ***
#> hcyes 0.111734 0.206040 0.542 0.587618
#> lwg 0.604693 0.150818 4.009 6.09e-05 ***
#> inc -0.034446 0.008208 -4.196 2.71e-05 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> (Dispersion parameter for binomial family taken to be 1)
#>
#> Null deviance: 1029.75 on 752 degrees of freedom
#> Residual deviance: 905.27 on 745 degrees of freedom
#>
#> logLik df AIC BIC
#> -452.63 8 921.27 958.26
#>
#> Number of Fisher Scoring iterations: 4
#>
#> Exponentiated Coefficients and Confidence Bounds
#> Estimate 2.5 % 97.5 %
#> (Intercept) 24.0982799 6.9377228 87.0347916
#> k5 0.2315607 0.1555331 0.3370675
#> k618 0.9374698 0.8200446 1.0710837
#> age 0.9390650 0.9154832 0.9625829
#> wcyes 2.2417880 1.4347543 3.5387571
#> hcyes 1.1182149 0.7467654 1.6766380
#> lwg 1.8306903 1.3689201 2.4768235
#> inc 0.9661401 0.9502809 0.9814042
#>
# use for data frames vs. summary()
Duncan.1 <-Duncan
Duncan.1$type <- as.character(Duncan$type)
summary(Duncan.1)
#> type income education prestige
#> Length:45 Min. : 7.00 Min. : 7.00 Min. : 3.00
#> Class :character 1st Qu.:21.00 1st Qu.: 26.00 1st Qu.:16.00
#> Mode :character Median :42.00 Median : 45.00 Median :41.00
#> Mean :41.87 Mean : 52.56 Mean :47.69
#> 3rd Qu.:64.00 3rd Qu.: 84.00 3rd Qu.:81.00
#> Max. :81.00 Max. :100.00 Max. :97.00
S(Duncan.1)
#> type income education prestige
#> bc :21 Min. : 7.00 Min. : 7.00 Min. : 3.00
#> prof:18 1st Qu.:21.00 1st Qu.: 26.00 1st Qu.:16.00
#> wc : 6 Median :42.00 Median : 45.00 Median :41.00
#> Mean :41.87 Mean : 52.56 Mean :47.69
#> 3rd Qu.:64.00 3rd Qu.: 84.00 3rd Qu.:81.00
#> Max. :81.00 Max. :100.00 Max. :97.00
if (FALSE) # generates an error, which can then be corrected to run example
# Using the bootstrap for standard errors
b1 <- Boot(mod.prestige)
S(mod.prestige, vcov.= vcov(b1))
#> Error: object 'b1' not found
Confint(b1) # run with the boot object to get corrected confidence intervals
#> Error: object 'b1' not found
# \dontrun{}