Compute Influence and Leverage Metrics for objects of type fixest
Source: R/summclust_fixest.R
summclust.fixest.Rd
Compute influence and leverage metrics for clustered inference
based on the Cluster Jackknife as described in MacKinnon, Nielsen & Webb
(2022) for objects of type fixest
.
Usage
# S3 method for fixest
summclust(
obj,
cluster,
params,
absorb_cluster_fixef = TRUE,
type = "CRV3",
...
)
Arguments
- obj
An object of type fixest
- cluster
A clustering vector
- params
A character vector of variables for which leverage statistics should be computed. If NULL, leverage statistics will be computed for all k model covariates
- absorb_cluster_fixef
TRUE by default. Should the cluster fixed effects be projected out? This increases numerical stability and decreases computational costs
- type
"CRV3" or "CRV3J" following MacKinnon, Nielsen & Webb
- ...
other function arguments passed to 'vcov'
Value
An object of type summclust
, including
a CRV3 variance-covariance estimate as described in
MacKinnon, Nielsen & Webb (2022)
- coef_estimates
The coefficient estimates of the linear model.
- vcov
A CRV3 or CRV3J variance-covariance matrix estimate as described in MacKinnon, Nielsen & Webb (2022)
- leverage_g
A vector of leverages.
- leverage_avg
The cluster leverage.
- partial_leverage
The partial leverages.
- coef_var_leverage_avg
Coefficient of Variation for the leverage statistic
- coef_var_leverage_g
Coefficient of Variation for the Partial Leverage Statistics
- coef_var_N_G
Coefficient of Variation for the Cluster Sizes.
- beta_jack
The jackknifed' leave-on-cluster-out regression coefficients.
- params
The input parameter vector 'params'.
- N_G
The number of clusters-
- call
The
summclust()
function call.- cluster
The names of the clusters.
References
MacKinnon, James G., Morten Ørregaard Nielsen, and Matthew D. Webb. "Leverage, influence, and the jackknife in clustered regression models: Reliable inference using summclust." arXiv preprint arXiv:2205.03288 (2022).
Examples
# \donttest{
if(requireNamespace("summclust")
&& requireNamespace("haven")
&& requireNamespace("fixest")){
library(summclust)
library(haven)
library(fixest)
nlswork <- read_dta("http://www.stata-press.com/data/r9/nlswork.dta")
# drop NAs at the moment
nlswork <- nlswork[, c("ln_wage", "grade", "age", "birth_yr", "union", "race", "msp", "ind_code")]
nlswork <- na.omit(nlswork)
feols_fit <- lm(
ln_wage ~ union + race + msp + as.factor(birth_yr) + as.factor(age) + as.factor(grade),
data = nlswork)
res <- summclust(
obj = feols_fit,
params = c("msp", "union"),
cluster = ~ind_code,
)
summary(res)
tidy(res)
plot(res)
}
#> Loading required namespace: fixest
#> Error in eval(mf, parent.frame()): object 'nlswork' not found
# }