View source: R/boottest_felm.R
boottest.felm | R Documentation |
boottest.felm
is a S3 method that allows for fast wild cluster
bootstrap inference for objects of class felm by implementing
the fast wild bootstrap algorithm developed in Roodman et al., 2019 and
implemented in the STATA package boottest
.
## S3 method for class 'felm' boottest( object, param, B, clustid, bootcluster = "max", fe = NULL, conf_int = NULL, rng = NULL, R = NULL, beta0 = 0, sign_level = 0.05, type = "rademacher", impose_null = TRUE, p_val_type = "two-tailed", tol = 1e-06, na_omit = TRUE, floattype = "Float32", fedfadj = TRUE, fweights = FALSE, getauxweights = FALSE, t_boot = FALSE, turbo = FALSE, maxmatsize = NULL, bootstrapc = FALSE, ssc = boot_ssc(adj = TRUE, fixef.K = "none", cluster.adj = TRUE, cluster.df = "conventional"), ... )
object |
An object of class felm |
param |
A character vector of length one. The name of the regression coefficient for which the hypothesis is to be tested |
B |
Integer. The number of bootstrap iterations. When the number of clusters is low, increasing B adds little additional runtime. |
clustid |
A character vector containing the names of the cluster variables |
bootcluster |
A character vector. Specifies the bootstrap clustering variable or variables. If more
than one variable is specified, then bootstrapping is clustered by the intersections of
clustering implied by the listed variables. To mimic the behavior of stata's boottest command,
the default is to cluster by the intersection of all the variables specified via the |
fe |
A character vector of length one which contains the name of the fixed effect to be projected out in the bootstrap. Note: if regression weights are used, fe needs to be NULL. |
conf_int |
A logical vector. If TRUE, boottest computes confidence intervals by p-value inversion. If FALSE, only the p-value is returned. |
rng |
An integer. Controls the random number generation, which is handled via the |
R |
Hypothesis Vector giving linear combinations of coefficients. Must be either NULL or a vector of the same length as |
beta0 |
A numeric. Shifts the null hypothesis H0: param = beta0 vs H1: param != beta0 |
sign_level |
A numeric between 0 and 1 which sets the significance level of the inference procedure. E.g. sign_level = 0.05 returns 0.95% confidence intervals. By default, sign_level = 0.05. |
type |
character or function. The character string specifies the type
of boostrap to use: One of "rademacher", "mammen", "norm", "gamma"
and "webb". Alternatively, type can be a function(n) for drawing
wild bootstrap factors. "rademacher" by default.
For the Rademacher and Mammen distribution, if the number of replications B exceeds
the number of possible draw ombinations, 2^(#number of clusters), then |
impose_null |
Logical. Controls if the null hypothesis is imposed on
the bootstrap dgp or not. Null imposed |
p_val_type |
Character vector of length 1. Type of p-value. By default "two-tailed". Other options include "equal-tailed", ">" and "<". |
tol |
Numeric vector of length 1. The desired accuracy (convergence tolerance) used in the root finding procedure to find the confidence interval. 1e-6 by default. |
na_omit |
Logical. If TRUE, |
floattype |
Float32 by default. Other optio: Float64. Should floating point numbers in Julia be represented as 32 or 64 bit? |
fedfadj |
Logical. TRUE by default. Should the small-sample adjustment reflect number of fixed effects? |
fweights |
Logical. FALSE by default, TRUE for frequency weights. |
getauxweights |
Logical. FALSE by default. Whether to save auxilliary weight matrix (v) |
t_boot |
Logical. Should bootstrapped t-statistics be returned? |
turbo |
Logical scalar, FALSE by default. Whether to exploit acceleration of the LoopVectorization package: slower on first use in a session, faster after |
maxmatsize |
NULL by default = no limit. Else numeric scalar to set the maximum size of auxilliary weight matrix (v), in gigabytes |
bootstrapc |
Logical scalar, FALSE by default. TRUE to request bootstrap-c instead of bootstrap-t |
ssc |
An object of class |
... |
Further arguments passed to or from other methods. |
An object of class boottest
p_val |
The bootstrap p-value. |
conf_int |
The bootstrap confidence interval. |
param |
The tested parameter. |
N |
Sample size. Might differ from the regression sample size if the cluster variables contain NA values. |
B |
Number of Bootstrap Iterations. |
clustid |
Names of the cluster Variables. |
N_G |
Dimension of the cluster variables as used in boottest. |
sign_level |
Significance level used in boottest. |
type |
Distribution of the bootstrap weights. |
p_test_vals |
All p-values calculated while calculating the confidence interval. |
t_stat |
The original test statistics - either imposing the null or not - with small sample correction |
test_vals |
All t-statistics calculated while calculating the confidence interval. |
t_boot |
All bootstrap t-statistics. |
regression |
The regression object used in boottest. |
call |
Function call of boottest. |
getauxweights |
The bootstrap auxiliary weights matrix v. Only returned if getauxweights = TRUE. |
t_boot |
The bootstrapped t-statistics. Only returned if t_boot = TRUE. |
Roodman et al., 2019, "Fast and wild: Bootstrap inference in STATA using boottest", The STATA Journal. (https://journals.sagepub.com/doi/full/10.1177/1536867X19830877)
Cameron, A. Colin, Jonah B. Gelbach, and Douglas L. Miller. "Bootstrap-based improvements for inference with clustered errors." The Review of Economics and Statistics 90.3 (2008): 414-427.
MacKinnon, James G., and Matthew D. Webb. "The wild bootstrap for few (treated) clusters." The Econometrics Journal 21.2 (2018): 114-135.
MacKinnon, James. "Wild cluster bootstrap confidence intervals." L'Actualite economique 91.1-2 (2015): 11-33.
Webb, Matthew D. Reworking wild bootstrap based inference for clustered errors. No. 1315. Queen's Economics Department Working Paper, 2013.
## Not run: library(wildboottestjlr) library(lfe) data(voters) felm_fit <- felm(proposition_vote ~ treatment + ideology1 + log_income | Q1_immigration, data = voters) boot1 <- boottest(felm_fit, B = 9999, param = "treatment", clustid = "group_id1") boot2 <- boottest(felm_fit, B = 9999, param = "treatment", clustid = c("group_id1", "group_id2")) boot3 <- boottest(felm_fit, B = 9999, param = "treatment", clustid = c("group_id1", "group_id2"), fe = "Q1_immigration") boot4 <- boottest(felm_fit, B = 999, param = "treatment", clustid = c("group_id1", "group_id2"), fe = "Q1_immigration", sign_level = 0.2, rng = 8, beta0 = 2) # test treatment + ideology1 = 2 boot5 <- boottest(felm_fit, B = 9999, clustid = c("group_id1", "group_id2"), param = c("treatment", "ideology1"), R = c(1, 1), beta0 = 2) summary(boot1) #plot(boot1) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.