multiresponse_bootstrap_lm | R Documentation |
Performs block bootstrap resampling for multiresponse linear models, particularly useful for fMRI time series data where temporal dependencies exist. The function implements a block bootstrap approach to maintain the temporal correlation structure within the data.
multiresponse_bootstrap_lm(
form,
data_env,
conlist,
vnames,
fcon,
modmat = NULL,
block_size = 30,
boot_rows = FALSE,
nboot = 100,
event_indices
)
form |
Formula for the linear model. Required if modmat is NULL. |
data_env |
Environment containing the data for the linear model. |
conlist |
List of contrasts to be computed for each bootstrap sample. |
vnames |
Vector of variable names. |
fcon |
Contrasts for fixed effects. |
modmat |
Optional pre-computed model matrix. If provided, form is ignored. |
block_size |
Size of the blocks for the bootstrap (default: 30). Should be large enough to capture temporal dependencies but small enough to allow sufficient randomization. |
boot_rows |
Logical flag indicating whether to bootstrap rows (default: FALSE). |
nboot |
Number of bootstrap iterations (default: 100). |
event_indices |
Indices of events for computing beta covariances. |
The function performs the following steps:
Fits the original linear model
Implements block bootstrap resampling of residuals
Reconstructs response variables using fitted values and resampled residuals
Computes contrasts for each bootstrap sample
The block bootstrap approach helps preserve temporal dependencies in the data by resampling blocks of consecutive observations rather than individual observations.
A list containing:
original: The fitted original model with contrasts
con_cov: Covariance matrices for contrasts (if contrasts provided)
beta_cov: Covariance matrices for beta estimates
nboot: Number of bootstrap iterations performed
bootstrap: Logical indicating this is a bootstrap result
## Not run:
# Simple example with synthetic data
X <- model.matrix(~ x1 + x2, data = data.frame(x1 = rnorm(100), x2 = rnorm(100)))
y <- matrix(rnorm(100 * 3), 100, 3) # 3 response variables
result <- multiresponse_bootstrap_lm(modmat = X, data_env = list(.y = y),
nboot = 100, block_size = 20)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.