knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(fwildclusterboot) set.seed(12312)
fwildclusterboot
provides an R binding to the WildBootTests.jl implementation of the "fast" wild cluster bootstrap.
We recommend to install Julia from its official website https://julialang.org/downloads/.
The JuliaConnectoR.utils
packages helps you to link R and Julia and to install WildBootTests.jl
from within R.
devtools::install_github("s3alfisc/JuliaConnectoR.utils") library(JuliaConnectoR.utils) connect_julia_r() # instructions to connect Julia and R install_julia_packages("WildBootTests.jl") # install WildBootTests.jl
By default, the functions above install the most recent stable releases of WildBootTests.jl
.
If Julia
and WildBootTests.jl
are already installed, you can check if the installed versions match the SystemRequirements
by running
check_julia_system_requirements("fwildclusterboot")
To set the number of threads for use in Julia, you can run
set_julia_nthreads() # instructions to set nthreads for Julia
and follow the provided instructions.
engine
function argumentYou can run the wild cluster bootstrap through WildBootTests.jl
via the engine
function argument:
# load data set voters included in fwildclusterboot data(voters) # estimate the regression model via lm lm_fit <- lm( proposition_vote ~ treatment + ideology1 + log_income + Q1_immigration , data = voters )
The first function call of boottest()
will JIT-compile all required Julia code - this will take around 10-30 seconds. Note that if you re-start your R session, all Julia code will have to be re-compiled.
boot_lm <- boottest( lm_fit, clustid = "group_id1", param = "treatment", B = 9999, engine = "WildBootTests.jl" )
If you decide that all your analyses should run through WildBootTests.jl
, you can set a global variable via
setBoottest_engine("WildBootTests.jl")
All subsequent calls of boottest()
will then automatically run WildBootTests.jl
(unless you explicitly specify engine = "R"
).
# after setting setBoottest_engine("WildBootTests.jl"), # the code below runs WildBootTests.jl without # specifying 'engine = "WildBootTests.jl"' boottest( lm_fit, clustid = "group_id1", param = "treatment", B = 9999 )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.