Short Time Series Program

Read lab function.pdf and do the following.
Write a function called masim to generate an MA(q) series of length T. Make sure
that your function works. Simulate a path with σ2 = 1, θ1 = 0.8 and θ2 = 0.3 with
T =2,000. Make an ACF plot. Is this consistent with the model that you generated?
Try generating a model with the same parameters but only 50 observations. Make an
ACF plot. Repeat this 3 times, what do you notice about the autocorrelations and the
dotted blue lines?
Download the DAILY data of apple (ticker AAPL) from Jan. 2016 todate using
QUANTMOD package. Use the ”adjusted closing” price and dailyReturn function
to compute the daily return.
getSymbols(“AAPL”,from=’2017-01-01’,source=”yahoo”)
d1=AAPL$AAPL.Adjusted
rtn=dailyReturn(d1)
d1rtn=rtn[2:length(rtn)]
1. Perform analysis to check if the log return series is white noise using both acf plot
and Box.test.
2. Run ar() on the log return data. It will return a proper order p for the AR process.
Use this p to fit the AR model using the arima command. For instance if p = 2,
use model=arima(yourstock, order=c(2,0,0)). Please note that we just use ar()
to find the optimal p, then the data is fitted using the arima command.