• We are pleased to announce that the winner of our Feedback Prize Draw for the Winter 2024-25 session and winning £150 of gift vouchers is Zhao Liang Tay. Congratulations to Zhao Liang. If you fancy winning £150 worth of gift vouchers (from a major UK store) for the Summer 2025 exam sitting for just a few minutes of your time throughout the session, please see our website at https://www.acted.co.uk/further-info.html?pat=feedback#feedback-prize for more information on how you can make sure your name is included in the draw at the end of the session.
  • Please be advised that the SP1, SP5 and SP7 X1 deadline is the 14th July and not the 17th June as first stated. Please accept out apologies for any confusion caused.

Time Series in R

GeorgeFS

Keen member
I am trying Q13-14.10 from the PBOR, and I'm getting an error when trying to run the arima() function. The error is as follows:

Error in arima(Xt, order = c(p, d, q)) :
only implemented for univariate time series

I think this is R potentially saying it doesn't recognise Xt as a time series, I have tried using as.ts(Xt) but I'm still getting the error when trying to run.

 
#Q13-14.10#

Xt <- read.table("Xt.csv", sep = ",", header = TRUE)
Xt <- ts(Xt, 1990, frequency = 12)


#(i)

answer <- numeric(4)
for (p in 0:2) for (d in 0:2) for (q in 0:2){
aic <- arima(Xt, order = c(p,d,q))$aic
row <- c(p,d,q,aic)
answer <- rbind(answer, row)

}

The text in red is copied from the question and it uses Xt.csv from the PBOR.
 
Your code runs fine for me. Could you try running it in a fresh R session and see if you get the same error?

What version of R are you using?

Andy
 
That works and gives me results - they aren't the same as the results in the solutions - but for the purpose of the exercise and setting up the loop I think I'm ok with that.

Thanks for your help!!
 
No problem. Yes you're right, I should have been clearer about that. The code wasn't to recreate the same time series, just to check the arima() function is working for you with another time series.

Strange that this works but you can't get it to work with the data in the file. What output do you get if you run:

Xt <- read.table("Xt.csv", sep = ",", header = TRUE)
Xt <- ts(Xt, 1990, frequency = 12)
str(Xt)
head(Xt)
 
Back
Top