Carry out diagnostic checks and tests on fitted mixAR models.
# S3 method for MixAR
tsdiag(object, gof.lag = NULL, y, ask = interactive(), ...,
plot = interactive(), std.resid = FALSE)mixAR_diag(model, y, ...)
returns invisibly a list with class "tsdiagMixAR"
, currently
containing the following components:
ordinary residuals,
see Details,
see Details,
see Details,
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.
the model on which to perform the checks, an object from class
MixAR
. model
can also be the output list from
fit_mixAR
.
Goodness of fit lag(s) for the Ljung-Box tests. Vector containing
one or more positive integers. max(gof.lag)
is the maximal
lag in the acf and pacf plots.
how many lags to compute for acf and pacf? The default is as that of
lag.max
for acf
.
a time series, currently a numeric
vector.
if TRUE
, ask (using a menu) which plot to present. Otherwise
just plot the selected plots. ask
is ignored if only one plot
is selected with argument plot
.
if TRUE
, the default, produce diagnostic plots. If
FALSE
don't produce plots. Otherwise, a numeric vector of
integers defining a subset of plots to consider, see Details.
if TRUE
standardise the ordinary residuals using
the conditional standard deviations. NOTE: the default is
currently FALSE
but it may soon be changed to TRUE
.
for mixAR_diag
, passed on to tsdiag
.
Davide Ravagli and Georgi N. Boshnakov
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:
difference (possibly scaled) between observed values and point predictions.
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).
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).
These residuals are calculated as the component specific residual
e_tk
divided by its corresponding scale sigma_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.
Smith1985mixAR
WongLi2000mixAR
mixAR_BIC
,
tsdiag
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()
Run the code above in your browser using DataLab