In: Statistics and Probability
ANSWER: I have attached the below code. I have added the observations in the last.
##################### R CODE ####################################
rm(list=ls(all=TRUE))
set.seed(12345)
X = arima.sim(n=100,model=list(ar=c(0.5,0.2)))
summary(X)
ar(X,aic=TRUE) # AR2 as a result
ar(X,aic=TRUE,method = "mle") # AR2 as a result
ar(X,aic=TRUE,method = "ols") # AR17 as a result
ar(X,aic=TRUE,method = "yule-walker") # AR2 as a result
ar(X,aic=FALSE,order.max = 1)
ar(X,aic=FALSE,method = "mle",order.max = 1)
ar(X,aic=FALSE,method = "ols",order.max = 1)
ar(X,aic=FALSE,method = "yule-walker",order.max = 1)
ar(X,aic=FALSE,order.max = 3)
ar(X,aic=FALSE,method = "mle",order.max = 3)
ar(X,aic=FALSE,method = "ols",order.max = 3)
ar(X,aic=FALSE,method = "yule-walker",order.max = 3)
ar(X,aic=FALSE,order.max = 5)
ar(X,aic=FALSE,method = "mle",order.max = 5)
ar(X,aic=FALSE,method = "ols",order.max = 5)
ar(X,aic=FALSE,method = "yule-walker",order.max = 5)
arima(X,order=c(2,0,0))
arima(X,order=c(1,0,1))
arima(X,order=c(2,0,1))
############## END OF R CODE #############################################
OBSERVATIONS:
(1)
Method Used | Order Selected |
Default | 2 |
MLE | 2 |
OLS | 17 |
Yule Walker | 2 |
(3)
Order Selected | AIC |
p=2, q=0 | 312.36 |
p=1, q=1 | 312.21 |
p=2, q=1 | 314.18 |