# R - ARIMA model with long seasonal periods - Error: “length of x and xreg does not match”

i want to use an ARIMA model in R for predicting an electrical load on a minutely basis. By examining the ACF I figured out which model could suit. The ACF has shown that the value one day ahead has a periodic autocorrelation. Therefore I'd like to implement a seasonal difference with a lag of 1440 (min/day).

Thus, I found this page (http://robjhyndman.com/hyndsight/longseasonality/) describing how to deal with long seasonal periods in R.

However, by applying that method, I experienced the following problem in R:

>Arima(x,order=c(2,0,2),xreg=fourier1(1:length(x),4,1440))

Error in stats::arima(x = x, order = order, seasonal = seasonal, xreg = xreg,  :
lengths of 'x' and 'xreg' do not match


x is the dataset as a zoo-Object with the following structure (it's just an example, I do not have access to the real structure at the moment; main difference: much more data!):

> str(x)
‘zoo’ series from 2010-01-01 00:00:00 to 2010-01-01 00:06:00
Data: num [1:7] 1 2 3 4 5 6 7
Index:  chr [1:7] "2010-01-01 00:00:00" "2010-01-01 00:01:00" ...


Since the number of rows in xreg should be exactly the same as in x, they are apparently not.

Does anyone has any suggestions about or experiecend this?

I'll appreciate any hints!

Marc

• For a start, what exactly is fourier1(1:length(x),4,1440) outputting? – Affine Jan 8 '14 at 18:11
• To expand a bit on that comment - the error message seems quite clear, so the question then becomes what is fourier1 doing. You might have made a mistake in programming it. – Affine Jan 8 '14 at 18:19
• Thank you for commenting. It gives a Matrix(length(x),8) including values from a fourier series. That function is just copied from Dr. Hyndmans page. I've doublechecked the size, it's exactly the size of the univariate dataset... – Marc Jan 8 '14 at 18:45
• It helps if you could provide structure of x str(x) and the function definition of fourier1 (or is it same as in the webpage?) – vinux Jan 8 '14 at 19:03
• Yes, fourier1 is the same as on the webpage. I've posted str(x) above (sorry it's just an example) – Marc Jan 8 '14 at 19:38