5.13 Problems
For these problems, use the catch landings from Greek waters (greeklandings
) and the Chinook landings (chinook
) in Washington data. Load the data as follows:
data(greeklandings, package = "atsalibrary")
<- greeklandings
landings data(chinook, package = "atsalibrary")
<- chinook.month chinook
Augmented Dickey-Fuller tests in R.
What is the null hypothesis for the Dickey-Fuller and Augmented Dickey-Fuller tests?
How do the Dickey-Fuller and Augmented Dickey-Fuller tests differ?
For
adf.test()
, does the test allow the data to have a non-zero level? Does the test allow the data to be stationarity around a trend (a linear slope)?For
ur.df()
, what does type = “none,” “drift,” and “trend” mean? Which one gives you the same result asadf.test()
? What do you have to set the lags equal to get the default lags inadf.test()
?For
ur.df()
, how do you determine if the null hypothesis is rejected?For
ur.df()
, how do you determine if there is a significant trend in the data? How do you determine if the intercept is different than zero?
KPSS tests in R.
What is the null hypothesis for the KPSS test?
For
kpss.test()
, what does setting null equal to “Level” versus “Trend” change?
Repeat the stationarity tests for sardine 1964-1987 in the landings data set. Here is how to set up the data for another species.
<- subset(landings, Species == "Sardine") datdf <- ts(datdf$log.metric.tons, start = 1964) dat <- window(dat, start = 1964, end = 1987) dat
Do a Dickey-Fuller (DF) test using
ur.df()
andadf.test()
. You will have to set the lags. What does the result tell you? Note forur.df()
usesummary(ur.df(...))
and look at the bottom of the summary information for the test statistics and critical values. The first test statistic is the one you want, labeledtau
(ortau3
).Do an Augmented Dickey-Fuller (ADF) test using
ur.df()
. How did you choose to set the lags? How is the ADF test different than the DF test?Do a KPSS test using
kpss.test()
. What does the result tell you?
Use the anchovy 1964-2007 data [Corrected 1/20. If you did the HW with 1964-1987, that’s fine but part b won’t have any models within 2 of the best for the shorter series.]. Fit this time series using
auto.arima()
withtrace=TRUE
.::auto.arima(anchovy, trace = TRUE) forecast
Fit each of the models listed using
Arima()
and show that you can produce the same AICc value that is shown in the trace table.What models are within \(\Delta\)AICc of 2 of the best model (model with lowest AICc)? What is different about these models?
Repeat the stationarity tests and differencing tests for anchovy using the following two time ranges: 1964-1987 and 1988-2007. The following shows you how to subset the data:
<- subset(landings, Species == "Anchovy") datdf <- ts(datdf$log.metric.tons, start = 1964) dat .87 <- window(dat, start = 1964, end = 1987) dat64
Plot the time series for the two time periods. For the
kpss.test()
, which null is appropriate, “Level” or “Trend?”Do the conclusions regarding stationarity and the amount of differencing needed change depending on which time period you analyze? For both time periods, use
adf.test()
with default values andkpss.test()
with null=“Trend.”Fit each time period using
auto.arima()
. Do the selected models change? What do the coefficients mean? Coefficients means the mean and drifts terms and the AR and MA terms.Discuss the best models for each time period. How are they different?
You cannot compare the AIC values for an Arima(0,1,0) and Arima(0,0,1). Why do you think that is? Hint when comparing AICs, the data being fit must be the same for each model.
For the anchovy 1964-2007 data, use
auto.arima()
withstepwise=FALSE
to fit models.find the set of models within \(\Delta AICc=2\) of the top model.
Use
Arima()
to fit the models with Inf or -Inf in the list. Does the set of models within \(\Delta AICc=2\) change?Create a 5-year forecast for each of the top 3 models according to AICc.
How do the forecasts differ in trend and size of prediction intervals?
Using the
chinook
data set,Set up a monthly time series object for the Chinook log metric tons catch for Jan 1990 to Dec 2015.
Fit a seasonal model to the Chinook Jan 1990 to Dec 1999 data using
auto.arima()
.Create a forecast through 2015 using the model in part b.
Plot the forecast with the 2014 and 2015 actual landings added as data points.
The model from part b has drift. Fit this model using
Arima()
without drift and compare the 2015 forecast with this model.