Last data update: 2014.03.03

R: Linear Model Summary with Sandwich Standard Errors
summarySandwichR Documentation

Linear Model Summary with Sandwich Standard Errors

Description

summarySandwich creates a summary of a "lm" object similar to the standard one, with sandwich estimates of the coefficient standard errors in the place of the usual OLS standard errors, also modifying as a consequence the reported t-tests and p-values for the coefficients. Standard errors may be computed from a heteroscedasticity-consistent ("HC") covariance matrix for the coefficients (of several varieties), or from a heteroscedasticity-and-autocorrelation-consistent ("HAC") covariance matrix.

Usage

summarySandwich(model, ...)
    
## S3 method for class 'lm'
summarySandwich(model, 
  type=c("hc3", "hc0", "hc1", "hc2", "hc4", "hac"), ...)

Arguments

model

a linear-model object.

type

type of sandwich standard errors to be computed; see hccm in the car package, and vcovHAC in the sandwich package, for details.

...

arguments to be passed to hccm or vcovHAC

Value

an object of class "summary.lm", with sandwich standard errors substituted for the usual OLS standard errors; the omnibus F-test is similarly adjusted.

Author(s)

John Fox jfox@mcmaster.ca

See Also

hccm, vcovHAC.

Examples

    mod <- lm(prestige ~ income + education + type, data=Prestige)
    summary(mod)
    summarySandwich(mod)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(RcmdrMisc)
Loading required package: car
Loading required package: sandwich
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/RcmdrMisc/summarySandwich.Rd_%03d_medium.png", width=480, height=480)
> ### Name: summarySandwich
> ### Title: Linear Model Summary with Sandwich Standard Errors
> ### Aliases: summarySandwich summarySandwich.lm
> ### Keywords: misc
> 
> ### ** Examples
> 
>     mod <- lm(prestige ~ income + education + type, data=Prestige)
>     summary(mod)

Call:
lm(formula = prestige ~ income + education + type, data = Prestige)

Residuals:
     Min       1Q   Median       3Q      Max 
-14.9529  -4.4486   0.1678   5.0566  18.6320 

Coefficients:
              Estimate Std. Error t value Pr(>|t|)    
(Intercept) -0.6229292  5.2275255  -0.119    0.905    
income       0.0010132  0.0002209   4.586 1.40e-05 ***
education    3.6731661  0.6405016   5.735 1.21e-07 ***
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 error: 7.095 on 93 degrees of freedom
  (4 observations deleted due to missingness)
Multiple R-squared:  0.8349,	Adjusted R-squared:  0.8278 
F-statistic: 117.5 on 4 and 93 DF,  p-value: < 2.2e-16

>     summarySandwich(mod)

Call:
lm(formula = prestige ~ income + education + type, data = Prestige)

Residuals:
     Min       1Q   Median       3Q      Max 
-14.9529  -4.4486   0.1678   5.0566  18.6320 

Coefficients:
              Estimate Std.Err(hc3) t value Pr(>|t|)    
(Intercept) -0.6229292    5.2381025  -0.119 0.905593    
income       0.0010132    0.0002672   3.793 0.000265 ***
education    3.6731661    0.6982758   5.260 9.16e-07 ***
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 error: 7.095 on 93 degrees of freedom
  (4 observations deleted due to missingness)
Multiple R-squared:  0.8349,	Adjusted R-squared:  0.8278 
F-statistic: 120.2 on 4 and 93 DF,  p-value: < 2.2e-16

> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>