I am using the forecast library for doing some time series forecasting. I need to forecast number of sold items. I am planning to add holidays as xreg in auto.arima. The holiday will be a 0/1 list, where 0 indicates no holiday and 1 indicates holiday. Holiday list has to be modeled in fourier package, which takes
fourier(x, K, h = NULL)
I am not sure how to calculate the correct value of K.
Can somebody point me to some source or some code for it in r?
This is some piece of code which I am using
holidayf <- c(0,0,0,0,0,1,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,1,1,1,1,0,0,0,0) h <- length(holidayf) h #given holidays holiday <- df[,2] y <- ts(df[,1],start = 2011,frequency = 52) z <- fourier(y, K=k) zf <- fourier(y, K=k, h=h) fit <- auto.arima(y, xreg=cbind(z,holiday), seasonal=FALSE) fc <- forecast(fit, xreg=cbind(zf,holidayf), h=h) fc %>% autoplot() summary(fit) ```