| acorr_diagnostics | R Documentation |
Autocorrelation diagnostics for residuals
acorr_diagnostics(
resid,
runs = NULL,
max_lag = 20L,
aggregate = c("mean", "median", "none")
)
resid |
Numeric matrix (time x voxels), typically whitened residuals. |
runs |
Optional run labels. |
max_lag |
Maximum lag to evaluate. |
aggregate |
Aggregation across voxels: "mean", "median", or "none". |
List of autocorrelation values and nominal confidence interval.
# Generate example residuals with some autocorrelation
n_time <- 200
n_voxels <- 50
resid <- matrix(rnorm(n_time * n_voxels), n_time, n_voxels)
# Add some AR(1) structure
for (v in 1:n_voxels) {
resid[, v] <- filter(resid[, v], filter = 0.3, method = "recursive")
}
# Check autocorrelation
acorr_check <- acorr_diagnostics(resid, max_lag = 10, aggregate = "mean")
# Examine lag-1 autocorrelation
lag1_acorr <- acorr_check$acf[2] # First element is lag-0 (always 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.