Skip to content

sidResidual

Python equivalent: sid.residual

Compute model residuals and perform diagnostic tests.

result = sidResidual(model, y, u)
result = sidResidual(model, y, u, 'MaxLag', M)
sidResidual(model, y, u, 'Plot', true)

Computes residuals from an estimated model and performs whiteness and independence tests to assess model quality.

Inputs

Name Description
model Result struct from any sid estimator (see sidResultTypes).
Freq-domain (§1): requires .Response, .Frequency, .SampleTime
State-space (§4/§5): requires .A, .B, .StateDim, .InputDim,
.DataLength
y (N x ny) measured output (or (N+1 x p x L) state data for COSMIC)
u (N x nu) input, or [] for time-series models

Name-value options

Name Description
'MaxLag' Maximum lag for correlation tests (default: min(25, floor(N/5)))
'Plot' Display diagnostic plot (default: true if nargout==0)

Outputs

Name Description
result.Residual (N x ny) residual time series e(t)
result.AutoCorr (M+1 x 1) normalised autocorrelation r_ee(tau)
result.CrossCorr (2M+1 x 1) normalised cross-corr r_eu(tau), or []
result.ConfidenceBound scalar, 99% bound 2.58/sqrt(N)
result.WhitenessPass logical, true if autocorrelation test passes
result.IndependencePass logical, true if cross-correlation test passes
result.DataLength N

Examples

% Residual analysis for a frequency-domain model
G = sidFreqBT(y, u);
result = sidResidual(G, y, u);
% Visual diagnostic plot
sidResidual(G, y, u, 'Plot', true);

Specification

(Model residual analysis — not yet in SPEC.md)

See also

sidCompare, sidFreqBT, sidLTVdisc

Changelog

  • 2026-03-29: First version by Pedro Lourenço.