vcovCESE: Cluster Estimated Standard Errors

vcovCESER Documentation

Cluster Estimated Standard Errors

Description

Cluster Estimated Standard Errors (CESE)

Usage

vcovCESE(mod, cluster = NULL, type = NULL)

Arguments

mod

a model object. It can be the output of the functions lm, glm, or other regression function that returns compatible objects. Important: See details

cluster

either a string vector with the name of the variables that will be used to cluster the standard errors, or a formula - e.g., ~ rhs, with a summation of the variables that will be used to cluster the standard errors replacing the rhs -, or a vector, matrix, or data.frame with the clustering data.

type

string with either HC0, HC1, HC2, HC3, or HC4. It specifies the type of heteroskedasticity correction to use (see Davidson and MacKinnon (1993) and Hayes and Cai (2007)).

Details

The data frame must be ordered by the clustering variables before estimating the model with lm, etc.

Value

The function returns a variance-covariace matrix of the coefficient estimates using the Cluster Estimated Standard Error (CESE) method.

References

Jackson, John (2019) Corrected Standard Errors with Clustered Data. Political Analysis.

Hayes, A. F., & Cai, L., (2007) Using heteroskedasticity-consistent standard error estimators in ols regression: an introduction and software implementation, Behavior research methods, 39(4), 709–722.

Davidson, R., & MacKinnon, J. G., (2004) Econometric theory and methods: Oxford University Press New York.

Examples


mod  = lm(enep ~  enpc + fapres + enpcfapres + proximity + eneg + logmag + logmag_eneg , data=dcese)

## --------------------------------------
## Getting the variance covariance matrix
## -------------------------------------- 
## Original variance-covariance matrix (no clustered std. errors)
## vcov(mod)

## Variance-covariance matrix using CRSE (sandwish package)
## sandwich::vcovCL(mod, cluster = ~ country)
## sandwich::vcovCL(mod, cluster = ~ country, type="HC3")

## Variance-covariance matrix using CESE
## ceser::vcovCESE(mod, cluster = ~ country)
## ceser::vcovCESE(mod, cluster = ~ country, type="HC3") # HC3 correction

## ---------
## Summaries
## ---------
## no robust SE 
summary(mod)                                                                          

## summary table using CRSE (sandwich package)
## lmtest::coeftest(mod, vcov = sandwich::vcovCL, cluster = ~ country)                   

## summary using CESE
## lmtest::coeftest(mod, vcov = ceser::vcovCESE, cluster = ~ country, type='HC3')



DiogoFerrari/ceser documentation built on June 10, 2025, 12:47 a.m.