2
$\begingroup$

I want to estimate an ARIMA(1,0,X) model. The MA(X) in the model is selected to minimize BIC. I have the following code employing the function auto.arima from "forecast" package in R:

 auto.arima(logret$appl, d=0, max.p=1, max.q=10,
 max.order=NA, max.d=0,start.p=1, start.q=0,
 stationary=FALSE, seasonal=FALSE,
 ic=c("bic"), stepwise=TRUE, trace=TRUE,
 allowdrift=TRUE, allowmean=TRUE, lambda=NULL, parallel=FALSE, num.cores=NULL)

The following is the result of the above code

 ARIMA(1,0,0) with non-zero mean : -6592.886
 ARIMA(0,0,0) with non-zero mean : -6597.561
 ARIMA(1,0,0) with non-zero mean : -6592.886
 ARIMA(0,0,1) with non-zero mean : -6592.48
 ARIMA(0,0,0) with zero mean     : -6604.679
 ARIMA(1,0,1) with non-zero mean : -6586.55

Best model: ARIMA(0,0,0) with non-zero mean 

Series: logreturns$REL.CP 
ARIMA(0,0,0) with non-zero mean 

Coefficients:
      intercept
          0e+00
s.e.      5e-04

sigma^2 estimated as 0.0002818:  log likelihood=3305.9
AIC=-6607.81   AICc=-6607.8   BIC=-6597.56

My problem requires to keep AR(1) and d=0 in all the models where I test MA lags. Is there a way to fix AR lags? What I really want is MA(1) coefficient out of this arima(1,0, X) model. Thanks

$\endgroup$
1
$\begingroup$

You can do it manually. Let x be the data series. The code below considers all moving-average lag orders between 0 and max.q and prints out the BIC-minimizing lag order and the corresponding estimated model:

m=list() # I will save estimated ARIMA(1,0,q) models here
BIC=c()  # I will save the corresponding BIC values here
max.q=10 # the maximum MA order you want to consider
n=length(x)
for(q in 0:max.q){
 m[[q+1]]=arima(x,order=c(1,0,q),method="ML")
 BIC[q+1]=AIC(m[[q+1]],k=log(n))
}
print(paste("BIC-optimal MA order is",which.min(BIC)-1)) # info message
print(m[[which.min(BIC)]]) # print the estimated BIC-optimal model

Edit:

To respond to a request in the comments, I am including a function that returns the estimated MA1 coefficient:

MA1fromARIMA10q=function(x,max.q=10,...){
 # x is a data vector (a time series)
 # max.q is the maximum MA order to be considered
 m=list() # I will save estimated ARIMA(1,0,q) models here
 BIC=c()  # I will save the corresponding BIC values here
 n=length(x)
 for(q in 0:max.q){
  m[[q+1]]=arima(x,order=c(1,0,q),...)
  BIC[q+1]=AIC(m[[q+1]],k=log(n))
 }
 q=which.min(BIC)-1
 if(q>0) MA1=coef(m[[q+1]])[2] else(MA1=NA) # if MA order is 0, assign NA
 return(MA1)
}
$\endgroup$
  • $\begingroup$ Thank you very much @Richard Hardy. Would you please form a single function with this loop you have written that when applied to time series "x" gives the ma[1] coefficient for the arima(1, 0, x). $\endgroup$ – Polar Bear Apr 24 '16 at 10:04
  • 1
    $\begingroup$ Once you have run the function and assigned its result to variable z, the ma1 coefficient can now be extracted as z$MAcoeffs[1] or z[[3]][1]. $\endgroup$ – Richard Hardy Apr 24 '16 at 10:21
  • 1
    $\begingroup$ Is it better now? The function selects an optimal ARIMA(1,0,q) model and just returns the MA1 coefficient directly. $\endgroup$ – Richard Hardy Apr 24 '16 at 11:00
  • 1
    $\begingroup$ If you want AR1 coefficient, replace [2] with [1] in MA1=coef(m[[q+1]])[2] (then the function name and the variable name MA1 in the function will not make sense, but that is not so important.) $\endgroup$ – Richard Hardy Apr 24 '16 at 11:33
  • 1
    $\begingroup$ Try supplying the argument method=ML when calling my function. Also, you could try function Arima from "forecast" package instead of the standard arima function. Arima is a slightly more robust version of arima. Just replace arima with Arima in the code. $\endgroup$ – Richard Hardy Apr 24 '16 at 11:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.