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)