MARSSresiduals.tt {MARSS} | R Documentation |
MARSS Contemporaneous Residuals
Description
Calculates the standardized (or auxiliary) contemporaneous residuals, aka the residuals and their variance conditioned on the data up to time . Contemporaneous residuals are only for the observations. Not exported. Access this function with
MARSSresiduals(object, type="tt")
.
Usage
MARSSresiduals.tt(object, method = c("SS"), normalize = FALSE,
silent = FALSE, fun.kf = c("MARSSkfas", "MARSSkfss"))
Arguments
object |
An object of class |
method |
Algorithm to use. Currently only "SS". |
normalize |
TRUE/FALSE See details. |
silent |
If TRUE, don't print inversion warnings. |
fun.kf |
Can be ignored. This will change the Kalman filter/smoother function from the value in object$fun.kf if desired. |
Details
This function returns the conditional expected value (mean) and variance of the model contemporaneous residuals. 'conditional' means in this context, conditioned on the observed data up to time and a set of parameters.
Model residuals
is the difference between the data and the predicted data at time
given
:
The observed model residuals are the difference between the observed data and the predicted data at time
using the fitted model.
MARSSresiduals.tt
fits the model using the data up to time . So
where is the expected value of
conditioned on the data from 1 to
from the Kalman filter.
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 and the parameter set
. The conditional variance is
where is the variance of
conditioned on the data up to time
. This is returned by
MARSSkfss
in Vtt
.
Standardized residuals
std.residuals
are Cholesky standardized residuals. These are the residuals multiplied by the inverse of the lower triangle of the Cholesky decomposition of the variance matrix of the residuals:
. These residuals are uncorrelated unlike marginal residuals.
The interpretation of the Cholesky standardized residuals is not straight-forward when the and
variance-covariance matrices are non-diagonal. The residuals which were generated by a non-diagonal variance-covariance matrices are transformed into orthogonal residuals in
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 multiplied by the inverse of the diagonal matrix formed from the square-root of the diagonal of the variance matrix of the residuals:
, 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 and
are
and
and the model is assumed to be written as
If normalize=TRUE, the model is assumed to be written
with the variance of and
equal to
(identity).
MARSSresiduals()
returns the residuals defined as in the first equations. To get normalized residuals (second equation) as used in Harvey et al. (1998), then use normalize=TRUE
. In that case the unconditional variance of residuals will be instead of
and
. Note, that the normalized residuals are not the same as the standardized residuals. In former, the unconditional residuals have a variance of
while in the latter it is the conditional residuals that have a variance of
.
Value
A list with the following components
model.residuals |
The observed contemporaneous model residuals: data minus the model predictions conditioned on the data 1 to t. A n x T matrix. NAs will appear where the data are missing. |
state.residuals |
All NA. There are no contemporaneous residuals for the states. |
residuals |
The residuals. |
var.residuals |
The joint variance of the residuals conditioned on observed data from 1 to t-. This only has values in the 1:n,1:n upper block for the model residuals. |
std.residuals |
The Cholesky standardized residuals as a n+m x T matrix. This is |
mar.residuals |
The marginal standardized residuals as a n+m x T matrix. This is |
bchol.residuals |
Because state residuals do not exist, this will be equivalent to the Cholesky standardized residuals, |
E.obs.residuals |
The expected value of the model residuals conditioned on the observed data 1 to t. Returned as a n x T matrix. |
var.obs.residuals |
The variance of the model residuals conditioned on the observed data. Returned as a n x n x T matrix. For observed data, this will be 0. See |
msg |
Any warning messages. This will be printed unless Object$control$trace = -1 (suppress all error messages). |
Author(s)
Eli Holmes, NOAA, Seattle, USA.
References
Holmes, E. E. 2014. Computation of standardized residuals for (MARSS) models. Technical Report. arXiv:1411.0045.
See Also
MARSSresiduals.tT()
, MARSSresiduals.tt1()
, fitted.marssMLE()
, plot.marssMLE()
Examples
dat <- t(harborSeal)
dat <- dat[c(2,11),]
fit <- MARSS(dat)
# Returns a matrix
MARSSresiduals(fit, type="tt")$std.residuals
# Returns a data frame in long form
residuals(fit, type="tt")