boot_samples {robmed} | R Documentation |
Draw bootstrap samples
Description
Draw bootstrap samples to be used for (fast-and-robust) bootstrap tests for mediation analysis. Note that this function is intended for use in simulation studies by experienced users.
Usage
boot_samples(n, R)
Arguments
n |
an integer giving the number of observations in the original data set. |
R |
an integer giving the number of bootstrap samples to be generated. |
Value
An object of class "boot_samples"
with the following
components:
indices |
an integer matrix in which each column contains the indices of the corresponding bootstrap sample. |
seed |
the state of the random number generator before the bootstrap samples were drawn |
Author(s)
Andreas Alfons
See Also
Examples
# control parameters
n <- 100
a <- b <- c <- 0.4
# generate data
set.seed(20200309)
x <- rnorm(n)
m <- a * x + rnorm(n)
y <- b * m + c * x + rnorm(n)
simulated_data <- data.frame(x, y, m)
# perform boostrap tests
indices <- boot_samples(n, R = 5000)
robust_boot <- test_mediation(simulated_data,
x = "x", y = "y", m = "m",
robust = TRUE,
indices = indices)
summary(robust_boot)
ols_boot <- test_mediation(simulated_data,
x = "x", y = "y", m = "m",
robust = FALSE,
indices = indices)
summary(ols_boot)
[Package robmed version 1.0.2 Index]