Estimates the autocovariance of fMRI noise directly, without fitting an AR model first. Lag products never cross a run boundary or a censoring gap, and the mean is removed per run rather than per fragment, so scrubbed data does not have its autocorrelation destroyed by the centering.
Usage
noise_acvf(
resid,
runs = NULL,
censor = NULL,
max_lag = 20L,
pooling = c("global", "run", "parcel"),
parcels = NULL,
design = NULL,
correction_max_lag = 25L
)Arguments
- resid
Numeric matrix of residuals (timepoints x voxels).
- runs
Optional run labels, length
nrow(resid). Each label must occupy one contiguous block and may not be missing.- censor
Optional indices of censored timepoints (1-based).
- max_lag
Highest lag to return.
- pooling
"global"for one autocovariance over all runs,"run"for one per run,"parcel"for one per parcel.- parcels
Parcel labels (length
ncol(resid)), required whenpooling = "parcel".- design
Optional design matrix whose projection produced
resid. When supplied the residual bias is corrected; seeacvf_bias_matrix().- correction_max_lag
Lag budget used to estimate and undo residual projection bias when
designis supplied. This is independent ofmax_lag: correction needs enough tail information even when only a few output lags are requested.
Value
An object of class fmriAR_acvf: a list with
acvf: named list of autocovariance vectors, lags 0 upward.pairs: matching list of the pair count behind each lag, so a consumer can tell an estimate backed by thousands of pairs from one backed by three.n_segments,segment_lengths: the segmentation actually used.max_lag,pooling,corrected.
Lags with no surviving pairs are dropped rather than reported as zero.
Details
This is the estimator fit_noise() uses internally, exposed so consumers can
get the covariance itself. For a run-stationary process with autocovariance
gamma, the covariance of any linear contrast L factors as
sum_h gamma_h * L T_h L' with T_h the lag-h indicator, so gamma plus
a design is enough to compute exact contrast variances without refitting.
Unlike acorr_diagnostics(), which returns normalized autocorrelation for
inspection, this returns covariances on the scale of the data.