Generic function for residuals check analysis, these methods are inspired in the check.residuals
function
provided by the forecast
package.
# S3 method for ts
check_residuals(
y,
normality = "epps",
unit_root = NULL,
seasonal = NULL,
arch = NULL,
alpha = 0.05,
plot = FALSE,
...
)
The function does not return any value
Either a time series model,the supported classes are arima0
, Arima
, sarima
,
fGarch
, or a time series (assumed to be residuals).
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.
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.
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.
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.
Level of the test, possible values range from 0.01 to 0.1. By default alpha = 0.05
is used
A boolean value. If TRUE
, will produce produces a time plot of the residuals,
the corresponding ACF, and a histogram.
Other testing parameters
Asael Alonzo Matamoros
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.
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.
# Generating an stationary arma process
y = arima.sim(100,model = list(ar = 0.3))
check_residuals(y,unit_root = "adf")
Run the code above in your browser using DataLab