diagnostic_plot {sstvars}R Documentation

Residual diagnostic plot for a STVAR model

Description

diagnostic_plot plots a multivariate residual diagnostic plot for either autocorrelation, conditional heteroskedasticity, or distribution, or simply draws the residual time series.

Usage

diagnostic_plot(
  stvar,
  type = c("all", "series", "ac", "ch", "dist"),
  resid_type = c("standardized", "raw"),
  maxlag = 12
)

Arguments

stvar

object of class "stvar"

type

which type of diagnostic plot should be plotted?

  • "all" all below sequentially.

  • "series" the residual time series.

  • "ac" the residual autocorrelation and cross-correlation functions.

  • "ch" the squared residual autocorrelation and cross-correlation functions.

  • "dist" the residual histogram with theoretical density (dashed line) and QQ-plots.

resid_type

should standardized or raw residuals be used?

maxlag

the maximum lag considered in types "ac" and "ch".

Details

Auto- and cross-correlations (types "ac" and "ch") are calculated with the function acf from the package stats and the plot method for class 'acf' objects is employed. If cond_dist == "Student", the estimate of the degrees of freedom parameter is used in theoretical densities and quantiles.

Value

No return value, called for its side effect of plotting the diagnostic plot.

References

See Also

Portmanteau_test, profile_logliks, fitSTVAR, STVAR, LR_test, Wald_test, Rao_test

Examples

## Gaussian STVAR p=1, M=2 model, with weighted relative stationary densities
# of the regimes as the transition weight function:
theta_122relg <- c(0.734054, 0.225598, 0.705744, 0.187897, 0.259626, -0.000863,
  -0.3124, 0.505251, 0.298483, 0.030096, -0.176925, 0.838898, 0.310863, 0.007512,
  0.018244, 0.949533, -0.016941, 0.121403, 0.573269)
mod122 <- STVAR(data=gdpdef, p=1, M=2, params=theta_122relg)

# Autocorelation function of raw residuals for checking remaining autocorrelation:
diagnostic_plot(mod122, type="ac", resid_type="raw")

# Autocorelation function of squared standardized residuals for checking remaining
# conditional heteroskedasticity:
diagnostic_plot(mod122, type="ch", resid_type="standardized")

# Below, ACF of squared raw residuals, which is not very informative for evaluating
# adequacy to capture conditional heteroskedasticity, since it doesn't take into account
# the time-varying conditional covariance matrix of the model:
diagnostic_plot(mod122, type="ch", resid_type="raw")

# Similarly, below the time series of raw residuals first, and then the
# time series of standardized residuals. The latter is more informative
# for evaluating adequacy:
diagnostic_plot(mod122, type="series", resid_type="raw")
diagnostic_plot(mod122, type="series", resid_type="standardized")

# Also similarly, histogram and Q-Q plots are more informative for standardized
# residuals when evaluating model adequacy:
diagnostic_plot(mod122, type="dist", resid_type="raw") # Bad fit for GDPDEF
diagnostic_plot(mod122, type="dist", resid_type="standardized") # Good fit for GDPDEF

## Linear Gaussian VAR p=1 model:
theta_112 <- c(0.649526, 0.066507, 0.288526, 0.021767, -0.144024, 0.897103,
  0.601786, -0.002945, 0.067224)
mod112 <- STVAR(data=gdpdef, p=1, M=1, params=theta_112)
diagnostic_plot(mod112, resid_type="standardized") # All plots for std. resids
diagnostic_plot(mod112, resid_type="raw") # All plots for raw residuals

[Package sstvars version 1.0.1 Index]