Title: Cluster Estimated Standard Errors
Version: 1.0.0
Description: Implementation of the Cluster Estimated Standard Errors (CESE) proposed in Jackson (2020) <doi:10.1017/pan.2019.38> to compute clustered standard errors of linear coefficients in regression models with grouped data.
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
URL: https://github.com/DiogoFerrari/ceser
BugReports: https://github.com/DiogoFerrari/ceser/issues
Depends: R (≥ 2.10)
Imports: magrittr, purrr, dplyr, tibble, lmtest
RoxygenNote: 7.0.2
Suggests: knitr, rmarkdown
VignetteBuilder: knitr
NeedsCompilation: yes
Packaged: 2020-11-04 18:20:22 UTC; diogo
Author: Diogo Ferrari [aut, cre], John Jackson [aut]
Maintainer: Diogo Ferrari <diogoferrari@gmail.com>
Repository: CRAN
Date/Publication: 2020-11-09 20:20:03 UTC

Sample data set

Description

A dataset relating the effective number of parties to the number of presidential candidates and presidential power.

Usage

dcese

Format

A data frame with rows and 9 variables:

country

name of the country

enep

Effective number of legislative parties

enpc

Number of presidential candidates

fapres

Presidential power

proximity

Proximity of the presidential and legislative elections

eneg

Eeffective number of ethnic groups

logmag

log of average district magnitudes

enpcfapres

Interaction between enpc and fapres

logmag_eneg

Interaction between logmag and eneg

...

Source

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

References

Elgie, Robert, Bueur, C., Dolez, B. & Laurent, A. (2014). “Proximity, Candidates, and Presidential Power: How Directly Elected Presidents Shape the Legislative Party System.” Political Research Quarterly. 67(3): 467 - 477.


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.

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)).

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')