resample_resid {NRejections} | R Documentation |
Resample residuals for OLS
Description
Implements the residual resampling OLS algorithm described in Mathur & VanderWeele (in preparation). Specifically, the design matrix is fixed while the resampled outcomes are set equal to the original fitted values plus a vector of residuals sampled with replacement.
Usage
resample_resid(
d,
X,
C = NA,
Ys,
alpha,
resid,
bhat.orig,
B = 2000,
cores = NULL
)
Arguments
d |
Dataframe |
X |
Single quoted name of covariate of interest |
C |
Vector of quoted covariate names |
Ys |
Vector of quoted outcome names |
alpha |
Alpha level for individual tests |
resid |
Residuals from original sample (W X B matrix) |
bhat.orig |
Estimated coefficients for covariate of interest in original sample (W-vector) |
B |
Number of resamples to generate |
cores |
Number of cores available for parallelization |
Value
Returns a list containing the number of rejections in each resample, a matrix of p-values in the resamples, and a matrix of t-statistics in the resamples.
References
Mathur, M.B., & VanderWeele, T.J. (in preparation). New metrics for multiple testing with correlated outcomes.
Examples
samp.res = dataset_result( X = "complaints",
C = c("privileges", "learning"),
Ys = c("rating", "raises"),
d = attitude,
center.stats = FALSE,
bhat.orig = NA, # bhat.orig is a single value now for just the correct Y
alpha = 0.05 )
resamps = resample_resid( X = "complaints",
C = c("privileges", "learning"),
Ys = c("rating", "raises"),
d = attitude,
alpha = 0.05,
resid = samp.res$resid,
bhat.orig = samp.res$b,
B=20,
cores = 2)