mixAR_diag {mixAR} | R Documentation |
Diagnostic checks for mixture autoregressive models
Description
Carry out diagnostic checks and tests on fitted mixAR models.
Usage
## S3 method for class 'MixAR'
tsdiag(object, gof.lag = NULL, y, ask = interactive(), ...,
plot = interactive(), std.resid = FALSE)
mixAR_diag(model, y, ...)
Arguments
model , object |
the model on which to perform the checks, an object from class
|
gof.lag |
Goodness of fit lag(s) for the Ljung-Box tests. Vector containing
one or more positive integers. how many lags to compute for acf and pacf? The default is as that of
|
y |
a time series, currently a |
ask |
if |
plot |
if |
std.resid |
if |
... |
for |
Details
It is recommended to use tsdiag
. mixAR_diag
is
essentially deprecated and is still here for compatibility with old
code. Moreover, the tsdiag
method is more flexible. The only
advantage of mixAR_diag
is that it accepts also a list for
argument model
but this is equivalent to calling tsdiag
with object = model$model
.
The function calculates several types of residuals, provides diagnostic plots for each of them, and returns numerical results. The following choices are currently available:
ACF/PACF of residuals,
ACF/PACF of U_residuals,
ACF/PACF of tau_residuals,
ACF/Histogram of tau_residuals.
In interactive sessions the user is presented with a menu to select
plot(s) from the available ones. The choice can be restricted to a
subset of them by giving argument plot
a vector of integers.
This is most useful to select a particular plot, with somethinng like
plot = 2
in the call to tsdiag
. plot
is used as
an index vector, so plot = -1
would remove the first item
listed above from the offered alternatives.
Transformations on the data are performed, as described in Smith (1985).
Four types of residuals are computed:
- ordinary residuals
-
difference (possibly scaled) between observed values and point predictions.
- U_residuals/PIT residuals
-
probability integral transform of the data using the CDF of the conditional distributions implied by the fitted model. For a good model these should resemble an IID sequence uniformly distributed on (0,1).
- V_residuals
-
set of transformed
U_residuals
with the quantile function of the standard normal distribution (qnorm
). For a good model these should resemble an IID sequence from N(0,1). - tau_residuals
-
These residuals are calculated as the component specific residual
e_tk
divided by its corresponding scalesigma_k
, according to under which component y_t has largest density. Under correct model specification, these should be jointly Normal. Shapiro-Wilk test is performed on this set of residual to assess the hypothesis.
For all types of residual results for the Ljung-Box test are provided. This test is particularly relevant for the V- and tau-residuals.
Kolmogorov-Smirnov test is carried out for the U_residuals to assess the hypothesis of uniform distribution.
Shapiro-Wilk test of normality is applied to V- and tau-residuals.
Value
returns invisibly a list with class "tsdiagMixAR"
, currently
containing the following components:
residuals |
ordinary residuals, |
U_residuals |
see Details, |
V_residuals |
see Details, |
tau_residuals |
see Details, |
BIC |
the value of the BIC criterion, a number. |
Each component, except BIC
, is a list containing the residuals
in component value
, Ljung-Box test in "Ljung-Box"
and
possibly other tests suitable for the corresponding type of
residuals.
Note
This function should be used for diagnostic checking of MixARGaussian
objects only.
Author(s)
Davide Ravagli and Georgi N. Boshnakov
References
Smith JQ (1985). “Diagnostic checks of non-standard time series models.” Journal of Forecasting, 4(3), 283-291. doi:10.1002/for.3980040305, https://onlinelibrary.wiley.com/doi/pdf/10.1002/for.3980040305, https://onlinelibrary.wiley.com/doi/abs/10.1002/for.3980040305.
Wong CS, Li WK (2000). “On a mixture autoregressive model.” J. R. Stat. Soc., Ser. B, Stat. Methodol. , 62(1), 95-115.
See Also
Examples
model1 <- new("MixARGaussian", prob = c(0.5, 0.5), scale = c(1, 2),
arcoef = list(-0.5, 1.1))
set.seed(123)
y <- mixAR_sim(model1, 400, c(0,0,0), nskip = 100)
fit1 <- fit_mixAR(y, model1)
d <- tsdiag(fit1$model, c(10, 20, 50), y)
d
## This will put each plot in a separate file (mydiag01.pdf, ..., mydiag04.pdf)
## pdf("mydiag%02d.pdf", onefile = FALSE)
## d <- tsdiag(fit1$model, c(10, 20, 50), y, ask = FALSE)
## dev.off()