Accumulates a running mean vector and covariance matrix over one or more chunks of
multivariate data, mirroring the C# RunningCovarianceMatrix class. The accumulator state
travels in the return value, so a chunked run holds no C++ state.
Arguments
- x
a numeric matrix (or an object coercible to one via
as.matrix()), observations in rows and variables in columns.- state
a
corehydro_running_covarianceobject from a previous call, orNULL(the default) to start a fresh accumulator.
Value
a corehydro_running_covariance list with n, mean (length-ncol(x)), and the
covariance, sample_covariance, sample_correlation, population_covariance, and
population_correlation matrices (each ncol(x) by ncol(x)). covariance is unadjusted
by sample size; sample_*/population_* are the N-1- and N-normalized variants. The C#
accumulator seeds covariance at the identity matrix before the first push (a stability
prior for its other consumer, adaptive MCMC), so every derived matrix carries a small
diagonal-only bias that only fades as n grows – do not expect an exact match to
stats::cov()/stats::cor() on the same data at small n.