check_residuals: Generic functions for checking residuals in time series...

Description Usage Arguments Details Value Author(s) References Examples

View source: R/check_residuals.R

Description

Generic function for residuals check analysis, these methods are inspired in the check.residuals function provided by the forecast package.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## S3 method for class 'ts'
check_residuals(
  y,
  normality = "epps",
  unit_root = NULL,
  seasonal = NULL,
  arch = NULL,
  alpha = 0.05,
  plot = FALSE,
  ...
)

Arguments

y

Either a time series model,the supported classes are arima0, Arima, sarima, fGarch, or a time series (assumed to be residuals).

normality

A character string naming the desired test for checking gaussian distribution. Valid values are "epps" for the Epps, "lobato" for Lobato and Velasco's,"vavras" for the Psaradakis and Vavra, "rp" for the random projections, "jb" for the Jarque and Beras, "ad" for Anderson Darling test, and "shapiro" for the Shapiro-Wilk's test. The default value is "epps" test.

unit_root

A character string naming the desired unit root test for checking stationarity. Valid values are "adf" for the Augmented Dickey-Fuller, "pp" for the Phillips-Perron, and "kpss" for Kwiatkowski, Phillips, Schmidt, and Shin. The default value is "adf" for the Augmented Dickey-Fuller test.

seasonal

A character string naming the desired unit root test for checking seasonality. Valid values are "ocsb" for the Osborn, Chui, Smith, and Birchenhall, "ch" for the Canova and Hansen, and "hegy" for Hylleberg, Engle, Granger, and Yoo. The default value is "ocsb" for the Osborn, Chui, Smith, and Birchenhall test.

arch

A character string naming the desired test for checking stationarity. Valid values are "box" for the Ljung-Box, and "Lm" for the Lagrange Multiplier test. The default value is "box" for the Augmented Ljung-Box test.

alpha

Level of the test, possible values range from 0.01 to 0.1. By default alpha = 0.05 is used

plot

A boolean value. If TRUE, will produce produces a time plot of the residuals, the corresponding ACF, and a histogram.

...

Other testing parameters

Details

The function performs a residuals analysis, it prints a unit root and seasonal test to check stationarity, and a normality test for checking Gaussian distribution. In addition, if the plot option is TRUE a time plot, ACF, and histogram of the series are presented.

Value

The function does not return any value

Author(s)

Asael Alonzo Matamoros

References

Dickey, D. & Fuller, W. (1979). Distribution of the Estimators for Autoregressive Time Series with a Unit Root. Journal of the American Statistical Association. 74, 427-431.

Epps, T.W. (1987). Testing that a stationary time series is Gaussian. The Annals of Statistic. 15(4), 1683-1698.http://www.jstor.org/stable/2336512. doi:10.1214/aos/1176350618

Osborn, D., Chui, A., Smith, J., & Birchenhall, C. (1988). Seasonality and the order of integration for consumption. Oxford Bulletin of Economics and Statistics. 50(4), 361-377.

Examples

1
2
3
# Generating an stationary arma process
y = arima.sim(100,model = list(ar = 0.3))
check_residuals(y,unit_root = "adf")

nortsTest documentation built on Aug. 16, 2021, 5:06 p.m.