Stat 3504, Fall 2021 take-home midterm
Name:
Instructions:
1. You need to work alone on this take-home midterm. You can ask
questions for clarification from me, but you can not discuss any part of
this exam with anyone else.
2. Show all of your work to receive full credit; you must attach all R code
and output to receive credit.
3. Please keep problems separate (e.g., do not log all R code at the end of
your solutions). Also, please pay special attention to neatness and or-
ganization. Please don’t make me to have to “look for” your solutions.
4. This exam is due at 11:59pm on Monday, Nov 1; you must submit
your work in a SINGLE file to Canvas.
1
1. (10 points) The time series object beer in the fma package contains
monthly Australian beer production from January 1991 through August
1995. To see the data, you need to first download it from Canvas (\exam\
dataset\beer.rda), and then type
load(’beer.rda’)
print(beer)
a) Plot the time series. What basic pattern do you see from the plot?
b) Fit a linear time trend model using least squares. Give the plot of the
linear trend overlain on the data, and give the estimated regression equation.
c) Fit a quadratic time trend model using least squares. Give the plot of
the quadratic trend overlain on the data, and give the estimated regression
equation.
d) Fit a harmonic regression model using least squares, including one pair of
harmonic functions AND a linear time trend as predictors. Give the plot of
the harmonic regression overlain on the data, and give the estimated regres-
sion equation.
e) Plot the standardized residuals over time from the linear model you fit in
a). Comment on any notable pattern.
f) Perform a runs test on the standardized residuals from the linear model.
What is your conclusion?
g) Plot the autocorrelation function for the standardized residuals from the
linear model. What do you conclude about the standardized residuals?
h) Investigate the normality of the standardized residuals (error terms) from
the linear model. What is your conclusion?
i) Repeat parts e) to h) but with the “linear model” replaced by the ”quadratic
model” you fit in part c).
j) Repeat parts e) to h) but with the “linear model” replaced by the ”har-
monic model” you fit in part d).
2
2. (4 points) Simulate an AR(1) time series of length n = 150 with φ =
−0.75. (hint: the following command may be helpful
arima.sim(model=list(ar=c(-0.75)),n=150)
a) Calculate and plot the theoretical autocorrelation function for this model.
Plot sufficient lags until the correlations are negligible. (hint: you can com-
pute the ACF by hand, or use the function ARMAacf in R to justify the
theoretical ACF or PACF values from your calculation)
b) Calculate and plot the sample ACF for your simulated series. How well
do the values and patterns match the theoretical ACF from part (a)? the
c) What are the theoretical partial autocorrelations for this model?
d) Calculate and plot the sample PACF for your simulated series. How well
do the values and patterns match the theoretical PACF from part (c)?
3. (3 points) The file named gold contains the daily price of gold (in dollars
per troy ounce). Type
library(TSA); data(gold); print(gold)
to see the data.
a) Display the time series plot of these data. Interpret the plot.
b) Display the time series plot of the differences of the logarithms of these
data. Interpret this plot.
c) Calculate and display the sample ACF for the differences of the logarithms
of these data and argue that the logarithms appear to follow a random walk
model.
(hint: apparently there are some missing values in the data; so you may need
to include na.action = na.pass as an option in the acf command)
3
4. (6 points) Simulate a mixed ARMA(1, 1) model of length n = 200 with
φ = 0.3 and θ = 0.5.
(hint: the following command may be helpful
arima.sim(model=list(ar=0.3,ma=-0.5),n=200)
)
a) Calculate and plot the theoretical autocorrelation function for this model.
Plot sufficient lags until the correlations are negligible.
b) Calculate and plot the sample ACF for your simulated series. How well
do the values and patterns match the theoretical ACF from part (a)? (hint:
you can again use the function ARMAacf)
c) Calculate and interpret the sample EACF for this series. Does the EACF
help you specify the correct orders for the model?
d) Repeat parts (b) and (c) with a new simulation using the same parameter
values and sample size.
e) Repeat parts (b) and (c) with a new simulation using the same parameter
values but sample size n = 50.
f) Repeat parts (b) and (c) with a new simulation using the same parameter
values but sample size n = 500.
5. (3 points) Simulate a nonstationary time series with n = 300 according
to the model ARIMA(0, 1, 1) with θ = 0.8.
(hint: the following command may be helpful
arima.sim(list(order = c(0,1,1), ma = -0.8), n = 300)
)
a) Perform the Dickey-Fuller test on the series with k = 0. Comment on the
results.
b) Perform the augmented Dickey-Fuller test on the series with k chosen by
the software; that is, the “best” value for k. Comment on the results.
c) Repeat parts a) and b) but use the differences of the simulated series.
Comment on the results.
4