Title: | Cluster Estimated Standard Errors |
---|---|
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. |
Authors: | Diogo Ferrari [aut, cre] |
Maintainer: | Diogo Ferrari <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.0 |
Built: | 2025-01-31 03:53:56 UTC |
Source: | https://github.com/diogoferrari/ceser |
A dataset relating the effective number of parties to the number of presidential candidates and presidential power.
dcese
dcese
A data frame with rows and 9 variables:
name of the country
Effective number of legislative parties
Number of presidential candidates
Presidential power
Proximity of the presidential and legislative elections
Eeffective number of ethnic groups
log of average district magnitudes
Interaction between enpc and fapres
Interaction between logmag and eneg
...
Jackson, John (2019) Corrected Standard Errors with Clustered Data. Political Analysis.
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 (CESE)
vcovCESE(mod, cluster = NULL, type = NULL)
vcovCESE(mod, cluster = NULL, type = NULL)
mod |
a model object. It can be the output of the functions |
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 |
type |
string with either |
The data frame must be ordered by the clustering variables before
estimating the model with lm
, etc.
The function returns a variance-covariace matrix of the coefficient estimates using the Cluster Estimated Standard Error (CESE) method.
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.
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')
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')