Reputation: 91
I have fit the model below to my time series data. The xreg
consists of a time vector that goes from 1 through 1000 and of 12 indicator variables (1 or 0) that represent the month. The data that I'm dealing with has some strong weekly and monthly seasonal patterns.
fit <- arima(x, order = c(3, 0, 0),
seasonal = list(order = c(1, 0, 1), period = 7),
xreg = cbind(t, M1, M2, M3, M4, M5,
M6, M7, M8, M9, M10, M11, M12), include.mean = FALSE,
transform.pars = TRUE,
fixed = NULL, init = NULL,
method = c("CSS-ML", "ML", "CSS"),
optim.method = "BFGS",
optim.control = list(), kappa = 1e6)
At this time I'm trying to figure out how I can predict 14 values for the month of January (M1=1
).
So when I use the predict function in R, I think I need to specify in the newxreg portion that I want M1=1
and M2,...,M12=0
for my prediction - correct?
I've played around with the code, but I couldn't get it to work and I was not able to find very detailed information about the newxreg portion of the predict formula online.
Can anyone explain to me how I can get predictions for one partigular month, say January? And how do I need to note that in the newxreg part of the predict function?
Many thanks in advance!
Upvotes: 3
Views: 4843
Reputation: 91
I have finally found a way out and wanted to post it - in case it helps someone else. So basically, newxreg should be a matrix that contains values of the regressors that you want predictions for. So in my case, my regressors were all 1 or 0 (coded variables) to specify a particular month. So what I did is I created a matrix of 0's and 1's to be used as my newxreg. What I did is I defined a matrix mx, and then in the predict function I set newxreg=mx. I made sure that the number of rows of mx>= number of rows of n.ahead.
pred <- predict(fit,n.ahead=n, newxreg=mx)
Hope this is helpful for others as well!
Upvotes: 6