Version 3.11.1
Version 3.11.1 is focused on addition of the predict
, forecast
, fitted
and residuals
functions along with plotting functions for the output. Documentation for these functions along with background literature and the derivation of the residuals algorithms have been updated. Residuals in state-space models are complex as there are two processes (observation and state), three types of conditioning (data to t-1, t or T), and four types of standardization used in the literature (none, marginal, Cholesky on the full variance matrix, and Cholesky on only model or state residual variance). The MARSS package computes all the variants of residuals. Many of the predict
changes are listed below for 3.10.13 release on GitHub. New chapters illustrating structural equation models using MARSS versus StructTS
and the KFAS package were added. The KFAS chapter compares the KFAS residuals functions to the MARSS residuals functions. The two packages use different algorithms and different semantics to compute the same residuals.
ENHANCEMENTS
ldiag()
convenience function added to make list diagonal matrices. This replaces having to do code likea <- matrix(list(0),2,2); diag(a) <- list(2,"a")
. Now you can callldiag(list(2,"a"))
.- Added
accurancy.marssMLE()
andaccuracy.marssPredict()
which returns accuracy metrics sensu the forecast package. - Added
is.unitcircle()
utility function and added tol so that it does not fail if abs(eigenvalue) is above 1 by machine tolerance. - Added ACF plots for model and state innovation residuals to
plot.marssMLE()
andautoplot.marssMLE()
. - Revamped
residuals.marssMLE()
. Got rid ofaugment.marssMLE()
and renamed itresiduals.marssMLE()
. The oldresiduals.marssMLE()
becameMARSSresiduals()
. There was too much duplication betweenresiduals.marssMLE()
andaugment.marssMLE()
and betweenaugment.marssMLE()
andfitted.marssMLE()
. Also I want to minimize dependency on other packages andaugment
is a class in the broom package. This required changes to theglance.marssMLE()
,plot.marssMLE()
andautoplot.marssMLE()
code. - Revamped
tidy.marssMLE
.tsSmooth.marssMLE
now returns the estimates from the Kalman filter or smoother whichtidy.marssMLE
had returned.tidy.marssMLE
only returns a data frame for the parameter estimates. - V0T was computed with an inverse of Vtt1[,,1]. This led to unstable numerics when V00 was like matrix(big, m, m). Changed to use
solve(t(Vtt1[,,1]), B%*%V00)
which should be faster and seems to have lower numerical error. predict.marssMLE
updated to return ytt1, ytt, ytt1.- Added state innovations and contemporaneous residuals to
MARSSresiduals.tt1
andMARSSresiduals.tt
but not returned byresiduals.marssMLE()
(unlessclean=FALSE
). Only returned byMARSSresiduals()
. - Added Block Cholesky standardized residuals.
BUGS
- This bug affected
residuals()
in cases where R=0. In v 3.10.12, I introduced a bug intoMARSSkfss()
for cases where R has 0s on diagonal. History: To limit propagation of numerical errors when R=0, the row/col of Vtt for the fully determined x need to be set to 0. In v 3.10.11 and earlier, my algorithm for finding these x was not robust and zero-d out Vtt row/cols when it should not have if Z was under-determined. This bug (in < 3.10.12) only affected underdetermined models (such as models with a stochastic trend and AR-1 errors). To fix I added a utility functionfully.spec.x()
. This returns the x that are fully determined by the data. There was a bug in these corrections which madeMARSSkfss()$xtT
wrong whenever there were 0s on diagonal of R. This would show up inresiduals()
since that was usingMARSSkfss()
(in order to get some output thatMARSSkfas()
doesn't provide.) The problem wasfully.spec.x()
. It did not recognize when Z.R0 (the Z for the R=0) was all 0 for an x and thus was not (could not be) fully specified by the data. Fix was simple check that colSums of Z.R0 was not all 0. - When computing the Cholesky standardized residuals, the lower triangle of the Cholesky decomposition should be used so that the residuals are standardized to a variance of 1.
base::chol()
returns the upper triangle. Thus the lines inMARSSresiduals.tT()
andMARSSresiduals.tt1()
that applied the standardization needt(chol())
. trace=1
would fail becauseMARSSapplynames()
did not recognize thatkf$xtt
andkf$Innov
were a message instead of a matrix. I had changed theMARSSkfas()
behavior to not return these due to some questions about the values returned by the KFAS function.is.validvarcov()
used eigenvalues >= 0 as passing positive-definite test. Should be strictly positive so > 0.MARSSkfas()
had bug on the line whereV0T
was computed whentinitx=0
. It was using*
instead of%*%
for the lastJ0
multiplication. It would affect models with a non-zeroV0
under certainB
matrices, such as structural models fit byStructTS()
.- The following bug was in
MARSSresiduals.tT()
andMARSSresiduals.tt1()
but was in the oldresiduals.marssMLE()
also. If MLE object had thekf
element,kf
was not assigned in code since there was nokf <- MLEobj$kf
line for that case. Normally MLE objects do not have thekf
element, but it could be added or is added for some settings ofcontrol$trace
. This causedresiduals()
to fail iftrace=2
.
DOCUMENTATION and MAN FILES
- Added covariates and example to
MARSS_dfa.Rd
- Added chapter on Structural time series models which compares
StructTS()
toMARSS()
output. - Removed all mention of
augment()
from documentation and manuals. Replaced withresiduals()
. predict.marssMLE.Rd
(help page) had bug in the examples. removeQ=Q
from the model list in the first example.- Cleaned-up the man pages for
predict()
andpredict.marssMLE()
. - In the chapter on structural breaks and outliers, Koopman et al (1998) use the marginal residuals in their example rather than the Cholesky standardized residuals. Changed to use marginal residuals to follow their example.
- In Covariates.Rnw I show the acf of residuals. This should use innovations instead of smoothations. Only the former are temporally independent.
- Added derivation for joint variance-covariance matrices for innovations model and state residuals.
OTHER
- Changed
fitted.marssMLE
to have column with .x which is conceptually the same as the y column for observations. It is the left-side of the x equation (with error term) while fitted is the right-side without the error term. - Changed the x0 estimation behavior for
predict.marssMLE()
when no data passed in. - Added x0 argument to
predict.marssMLE()
so that user can specify x0 if needed. - Removed the tibble class from the data frames returned by
residuals.marssMLE()
. The data frames are still in tibble form. Removed all reference to tibbles in the documentation. - When
trace = -1
some tests were still being done. I added a test fortrace = -1
to a few more test lines inMARSS.R
andMARSS_marxss.R
. - Changed the default behavior of
residuals.marssMLE()
to return innovations instead of smoothations. - Columns of model estimated values in
fitted.marssMLE
,residuals.marssMLE
, andtsSmooth.marssMLE
have a leading ".".