Calculates the standardized (or auxiliary) one-step-ahead residuals, aka the innovations residuals and their variance. Not exported. Access this function with residuals(object, conditioning="t-1")
.
MARSSresiduals.tt1(object, method=c("SS"), normalize=FALSE, silent=FALSE)
An object of class marssMLE
.
Algorithm to use. Currently only "SS".
TRUE/FALSE
If TRUE, don't print inversion warnings.
A list with the following components
The model residuals conditioned on the data up to time \(t-1\) and the set of model parameters. Called the innovations. Residuals associated with missing data will appear as NA.
The variance of the model residuals as a n x n x T matrix. The variance exists for all t values including missing data.
The Cholesky standardized model residuals as a n x T matrix. This is residuals
multiplied by the inverse of the Cholesky decomposition of var.residuals
.
The marginal standardized model residuals as a n x T matrix. This is residuals
multiplied by the inverse of the diagonal matrix formed by the square-root of the diagonal of var.residuals
.
Any warning messages. This will be printed unless Object$control$trace = -1 (suppress all error messages).
This function returns the conditional expected value (mean) and variance of the model one-step-ahead residuals. 'conditional' means in this context, conditioned on the observed data up to time \(t-1\) and a set of parameters.
Model residuals
\(\mathbf{v}_t\) is the difference between the data and the predicted data at time \(t\) given \(\mathbf{x}_t\):
$$ \mathbf{v}_t = \mathbf{y}_t - \mathbf{Z} \mathbf{x}_t - \mathbf{a} $$
The observed model residuals \(\hat{\mathbf{v}}_t\) are the difference between the observed data and the predicted data at time \(t\) using the fitted model. MARSSresiduals.tt1
fits the model using the data up to time \(t-1\). So
$$ \hat{\mathbf{v}}_t = \mathbf{y}_t - \mathbf{Z}\tilde{\mathbf{x}}_t^{t-1} - \mathbf{a} $$
where \(\tilde{\mathbf{x}}_t^{t-1}\) is the expected value of \(\mathbf{X}_t\) conditioned on the data from 1 to \(t-1\) from the Kalman filter. \(\mathbf{y}_t\) are your data and missing values will appear as NA. These will be returned in residuals
.
var.residuals
returned by the function is the conditional variance of the residuals conditioned on the data up to \(t-1\) and the parameter set \(\Theta\). The conditional variance is
$$ \hat{\Sigma}_t = \mathbf{R}+\mathbf{Z}_t \mathbf{V}_t^{t-1} \mathbf{Z}_t^\top $$
where \(\mathbf{V}_t^{t-1}\) is the variance of \(\mathbf{X}_t\) conditioned on the data up to time \(t-1\). This is returned by MARSSkf
in Vtt1
.
Standardized residuals
std.residuals
are Cholesky standardized residuals. These are the residuals muliplied by the inverse of the Cholesky decomposition of the variance matrix of the residuals:
$$ \hat{\Sigma}_t^{-1/2} \hat{\mathbf{v}}_t$$
These residuals are uncorrelated.
The interpretation of the Cholesky standardized residuals is not straight-forward when the Q and R variance-covariance matrices are non-diagonal. The residuals which were generated by a non-diagonal variance-covariance matrices are transformed into orthogonal residuals in MVN(0,I) space. For example, if v is 2x2 correlated errors with variance-covariance matrix R. The transformed residuals (from this function) for the i-th row of v is a combination of the row 1 effect and the row 1 effect plus the row 2 effect. So in this case, row 2 of the transformed residuals would not be regarded as solely the row 2 residual but rather how different row 2 is from row 1, relative to expected. If the errors are highly correlated, then the Cholesky standardized residuals can look rather non-intuitive.
mar.residuals
are the marginal standardized residuals. These are the residuals muliplied by the inverse of the diagonal matrix formed from the square-root of the diagonal of the variance matrix of the residuals:
$$ \textrm{dg}(\hat{\Sigma}_t)^{-1/2} \hat{v}_t$$, where 'dg(A)' is the square matrix formed from the diagonal of A, aka diag(diag(A))
. These residuals will be correlated if the variance matrix is non-diagonal.
Normalized residuals
If normalize=FALSE
, the unconditional variance of \(V_t\) and \(W_t\) are R and Q and the model is assumed to be written as
$$ y_t = Z x_t + a + v_t$$
$$ x_t = B x_{t-1} + u + w_t$$
If normalize=TRUE, the model is assumed to be written
$$ y_t = Z x_t + a + Hv_t$$
$$ x_t = B x_{t-1} + u + Gw_t$$
with the variance of \(V_t\) and \(W_t\) equal to I (identity).
residuals.marssMLE
returns the residuals defined as in the first equations. To get the residuals defined as Harvey et al. (1998) define them (second equations), then use normalize=TRUE
. In that case the unconditional variance of residuals will be I instead of R and Q. Note, that the `normalized' residuals are not the same as the `standardized' residuals. In former, the unconditional residuals have a variance of I while in the latter it is the conditional residuals that have a variance of I.
R. H. Shumway and D. S. Stoffer (2006). Section on the calculation of the likelihood of state-space models in Time series analysis and its applications. Springer-Verlag, New York.
Holmes, E. E. 2014. Computation of standardized residuals for (MARSS) models. Technical Report. arXiv:1411.0045.
# NOT RUN {
dat <- t(harborSeal)
dat <- dat[c(2,11),]
MLEobj <- MARSS(dat)
residuals(MLEobj, conditioning="t-1")$std.residuals
# }
Run the code above in your browser using DataLab