boottest.ivreg
is a S3 method that allows for fast wild cluster
bootstrap inference for objects of class ivreg by implementing
the fast wild bootstrap algorithm developed in Roodman et al., 2019
for instrumental variable models (WRE, Davidson & McKinnon, 2010)
# S3 method for ivreg
boottest(
object,
clustid,
param,
B,
bootcluster = "max",
conf_int = TRUE,
seed = NULL,
R = NULL,
r = 0,
sign_level = 0.05,
type = "rademacher",
impose_null = TRUE,
p_val_type = "two-tailed",
tol = 1e-06,
floattype = "Float64",
getauxweights = FALSE,
t_boot = FALSE,
maxmatsize = NULL,
bootstrapc = FALSE,
liml = FALSE,
fuller = NULL,
kappa = NULL,
arubin = FALSE,
ssc = boot_ssc(adj = TRUE, fixef.K = "none", cluster.adj = TRUE, cluster.df =
"conventional"),
...
)
An object of class lm
A character vector or rhs formula containing the names of the cluster variables
A character vector or rhs formula of length one. The name of the regression coefficient for which the hypothesis is to be tested
Integer. The number of bootstrap iterations. When the number of clusters is low, increasing B adds little additional runtime
A character vector or rhs formula of length 1. 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 clustid
argument,
even though that is not necessarily recommended (see the paper by Roodman et al cited below, section 4.2).
Other options include "min", where bootstrapping is clustered by the cluster variable with the fewest clusters.
Further, the subcluster bootstrap (MacKinnon & Webb, 2018) is supported - see the vignette("fwildclusterboot", package = "fwildclusterboot")
for details.
A logical vector. If TRUE, boottest computes confidence intervals by test inversion. If FALSE, only the p-value is returned.
An integer. Allows to set a random seed. For details, see below.
Hypothesis Vector giving linear combinations of coefficients. Must be either NULL or a vector of the same length as param
. If NULL, a vector of ones of length param.
A numeric. Shifts the null hypothesis H0: param = r vs H1: param != r
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.
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 boottest()
will use each possible combination once (enumeration).
Logical. Controls if the null hypothesis is imposed on
the bootstrap dgp or not. Null imposed (WCR)
by default.
If FALSE, the null is not imposed (WCU)
Character vector of length 1. Type of p-value. By default "two-tailed". Other options include "equal-tailed", ">" and "<".
Numeric vector of length 1. The desired accuracy (convergence tolerance) used in the root finding procedure to find the confidence interval. Relative tolerance of 1e-6 by default.
Float64 by default. Other option: Float32. Should floating point numbers in Julia be represented as 32 or 64 bit?
Logical. FALSE by default. Whether to save auxilliary weight matrix (v)
Logical. Should bootstrapped t-statistics be returned?
NULL by default = no limit. Else numeric scalar to set the maximum size of auxilliary weight matrix (v), in gigabytes
Logical scalar, FALSE by default. TRUE to request bootstrap-c instead of bootstrap-t
Logical scalar. False by default. TRUE for liml or fuller liml
NULL by default. Numeric scalar. fuller liml factor
Null by default. fixed <U+03BA> for k-class estimation
False by default. Logical scalar. TRUE for Anderson-Rubin Test.
An object of class boot_ssc.type
obtained with the function boot_ssc
. Represents how the small sample adjustments are computed. The defaults are adj = TRUE, fixef.K = "none", cluster.adj = "TRUE", cluster.df = "conventional"
.
You can find more details in the help file for boot_ssc()
. The function is purposefully designed to mimic fixest's ssc
function.
Further arguments passed to or from other methods.
An object of class boottest
The bootstrap p-value.
The bootstrap confidence interval.
The tested parameter.
Sample size. Might differ from the regression sample size if the cluster variables contain NA values.
Number of Bootstrap Iterations.
Names of the cluster Variables.
Dimension of the cluster variables as used in boottest.
Significance level used in boottest.
Distribution of the bootstrap weights.
Whether the null was imposed on the bootstrap dgp or not.
The vector "R" in the null hypothesis of interest Rbeta = r.
The scalar "r" in the null hypothesis of interest Rbeta = r.
R'beta. A scalar: the constraints vector times the regression coefficients.
All t-statistics calculated while calculating the confidence interval.
All p-values calculated while calculating the confidence interval.
The 'original' regression test statistics.
All bootstrap t-statistics.
The regression object used in boottest.
Function call of boottest.
The employed bootstrap algorithm.
The number of threads employed.
The integer value -inherited from set.seed() - used within boottest() to set the random seed in either R or Julia. If NULL, no internal seed was created.
To guarantee reproducibility, you can either use boottest()'s
seed
function argument, or
set a global random seed via
set.seed()
when using
the lean algorithm (via boot_algo = "R-lean"
) including the heteroskedastic wild bootstrap
the wild cluster bootstrap via boot_algo = "R"
with Mammen weights or
boot_algo = "WildBootTests.jl"
dqrng::dqset.seed()
when using boot_algo = "R"
for Rademacher, Webb or Normal weights
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(ivreg)
library(fwildclusterboot)
# drop all NA values from SchoolingReturns
SchoolingReturns <- SchoolingReturns[rowMeans(sapply(SchoolingReturns, is.na)) == 0, ]
ivreg_fit <- ivreg(log(wage) ~ education + age +
ethnicity + smsa + south + parents14 |
nearcollege + age + ethnicity + smsa
+ south + parents14,
data = SchoolingReturns
)
boot_ivreg <- boottest(
object = ivreg_fit,
B = 999,
param = "education",
clustid = "kww",
type = "mammen",
impose_null = TRUE
)
summary(boot_ivreg)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab