# Seasonality Frequency (State Space regression Model)

I'm having a bit of trouble with my state space model fit (using KFAS package) when I include a seasonal component in the model. The computations don't seem to end when I include (what I believe is) the frequency of the seasonality in the seasonal component of the model.

So heres what my data Looks like.. The response variable is count data, basically the number of animals at a site. I have 10 of these sites, and each month from 1997-2014 I make an observation at each site and record the number of animals. So 10 observations in total for 10 sites in 1 month. So in total I have 2160 data points.

Now I want to capture the 'seasonality' in the data, because I know that I'll have higher counts during summer months than I will during the winter months. So in 1 year, I've taken 120 observations.. what i've been doing up until this post is setting the frequency of my seasonality as 120. To me it seems correct, but the computation seems to be very intensive so I have a feeling I may be wrong.

Any suggestions?

I also had another idea in mind, but im not sure if its a valid approach. Since my response is count data, it follows a poisson distribution (non-gaussian), if I were to decompose the data into trend,error and seasonal components, could I be able to model just the trend+error and assume its under a gaussian distribution? (thus completely removing the seasonality from my analysis)

Thanks for your help.

• are you asking for how to parametrize the model to include seasonal components? Or are you asking for code help? – Taylor Jul 20 '17 at 21:55
• more so how to parametrize the model @Taylor – Shaharyar Ali Jul 20 '17 at 22:03
• As currently described, you seem to neglecting the spatial correlations in you data i.e. you have 10 time series, each of them with a period of 12 months. Not 1 site with a time period of 1200. – mkt - Reinstate Monica Jul 21 '17 at 14:40
• I see what you mean.. I'm essentially just trying to fit some sort of dynamic linear model such that I can include regressors of interest, determine their coefficients at each time step and plot the change. But fitting 10 different models,1 for each site, seems a little tedious. Do you suggest I model the data as a multivariate(response) state space/dynamic linear model? – Shaharyar Ali Jul 21 '17 at 16:52
• And in regards to spatial correlation, I've created a new predictor variable to act as kind of a 'penalty' in a sense; using the spatial coordinates of each site and a nearest neighbours algorithm i've given a 'weight' to each site. – Shaharyar Ali Jul 21 '17 at 17:01

If you had, say, two known angular frequencies $\omega_1$ and $\omega_2$, you could set the state transition matrix to $$T_t = T = \left[\begin{array}{ccccc} 1 & 0 & 0 & 0 & 0\\ 0 & \cos(\omega_1) & \sin(\omega_1 ) & 0 & 0 \\ 0 & -\sin(\omega_1) & \cos (\omega_1) & 0 & 0\\ 0 & 0 & 0 & \cos(\omega_2) & \sin(\omega_2) \\ 0 & 0 & 0 & -\sin(\omega_2 ) & \cos(\omega_2) \end{array}\right],$$ and, if you had a univariate response, the observation matrix to $$Z_t = Z = [1 1 0 1 0].$$ In the case of a multivariate response, where all the dependent variables share the same mean, you could set the observation matrix to $$Z_t = \left[ \begin{array}{c} 1 \\ 1\\ \vdots \\ 1 \end{array}\right] [1 1 0 1 0].$$
For example, if you have monthly data, and you expect there is a quarterly cycle, that is once every three months, so you would set one of your angular frequencies to be $$\omega_i = 2 \pi \frac{1}{3}.$$