# K in Fourier series - How to find value of K to use it in ARIMA?

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)

$$$$
`
• See "Forecasting weekly data" and "Forecasting with daily data" by Rob J. Hyndman. – Richard Hardy Apr 16 '19 at 17:48
• I don't understand the link between holidays and Fourier. if you have a list of 10 holidays then why not simply put 10 dummies? Fourier is overkill in this case, unless the holidays are very regular – Aksakal Feb 11 at 21:57