I have weekly panel data for more than a hundred cities. The independent variables are temperature and precipitation. The time dimensions; year, month, and week - likely have time invariant characteristics and are all important for proper estimation.

I was wondering if there are any issues in controlling for all three fixed effects (year, month, and week) in the same regression? Thanks!

  • $\begingroup$ I take it you are specifically interested in the effects of year/month/week? Because if you're not, and just want to adjust for these variables, you might be better of using them as random effects. But if you insist on using them as fixed effects, I would try using regression splines in the context of a generalized additive mixed model (you need the mixed model to account for the repeated measurements). $\endgroup$ – JonB Sep 17 '15 at 12:45
  • $\begingroup$ Thanks for your reply @JonasBerge Yes, I'm interested in the effects of year/month/week. I would like to use them in a Generalized Additive Models (GAM) framework. Does it make sense? $\endgroup$ – shouro Sep 17 '15 at 13:02
  • $\begingroup$ Yes, it makes sense, but you need to take the correlational structure of the data into account. I mean that each city is measured at repeated times, and the measurement of each city is likely to be correlated with other measurements from that city, regardless of other variables. So you need a Generalized Additive Mixed Model (GAMM) to do this. $\endgroup$ – JonB Sep 17 '15 at 13:22

You can model year/time/week in various ways. First of all, I wonder if there really is an effect of month when adjusting for week? It depends on what you measure, obviously, but still, any effect that varies across the year should be taken care of by week.

In any case, I recommend using regression splines in a generalized additive model to do this. To take the correlation between repeated measurements within each city into account, you need to use a mixed model, so a generalized additive mixed model will be fine. Using R code:

M1 <- gamm(outcome ~ temperature + precipitation + s(year) + s(month) + s(week), random=~1|city)

And you can also try without month:

M2 <- gamm(outcome ~ temperature + precipitation + s(year) + s(week), random=~1|city)

You can now compare the models since the models are nested:

anova(M1$lme, M2$lme)

The second model is nested within the first, and a low p-value indicates that month should be kept, and a high p-value indicates that it should be dropped from the model.

  • $\begingroup$ This is very informative! I have been using something like: s1 <- gam(outcome ~ s(temperature) + s(precipitation) + factor(year) + factor(month) + factor(week) AIC suggests that all three should be kept while BIC suggests that month should be dropped - though AIC and BIC asks different questions. I really appreciate the codes. Excellent @JonasBerge! $\endgroup$ – shouro Sep 17 '15 at 13:54
  • $\begingroup$ As I said, you really need to take the correlational structure of the data into account by using a mixed model instead. And you can also consider having at least week as a spline s(week) as you'll save a lot of estimated parameters that way. $\endgroup$ – JonB Sep 17 '15 at 13:56
  • $\begingroup$ You're welcome. Welcome to the site! $\endgroup$ – JonB Sep 17 '15 at 14:06
  • $\begingroup$ If I wanted to run the above model using a simpler FE apporach (LFE package), would this be valid: felm(outcome ~ temperature + precipitation |citycode + year + week $\endgroup$ – shouro Nov 13 '15 at 14:51
  • $\begingroup$ I'm sorry, but I'm not familiar with the LFE package and I don't have time to look into it at the moment. $\endgroup$ – JonB Nov 14 '15 at 19:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.