I have panel data for people over a number of years. People can be categorised based on a certain characteristic, X. Individual's yearly observations can be categorised based on whether a particular event, E, occurred for that person in a year or not.

The characteristic, X, and event, E, can be further subdivided into two mutually exhaustive groups each, X1 and X2, and E1 and E2, respectively (i.e. if X then either X1 or X2, and similarly for E).

My aim is to write a simple linear regression model of Y versus these categories and their interaction effects (and an additional explanatory variable Z).

My proposed idea is to define the following dummy variables that cover the full space of X and E:

  • X1=1 if person is in category X1, =0 otherwise,
  • X2=1 if person is in category X2, =0 otherwise,
  • notX=1 if person is not in category X1 and is not in category X2, 0 otherwise
  • E1=1 if event E1 occurred in a year for a person, =0 otherwise,
  • E2=1 if event E2 occurred in a year for a person, =0 otherwise,
  • notE=1 if event E1 did not occur and event E2 did not occur in a year for a person, 0 otherwise

There would be 9 possible interaction terms: X1*E1, X1*E2, X1*notE, X2*E1, ..., notX*notE.

Is this the right approach to take and if so which variables do I put in my model and which do I leave out as a base case? Do I need to include the levels of X1, X2, etc if I have all the interactions?

There is also one continuous explanatory variable I wish to include in the model as well, Z, and I would like to include the dummy interactions interacted with Z as well. If I include the level Z and Z interacted with each of the 9 dummy interactions (i.e. Z*X1*E1, etc.) do I also need to include Z interacted with the level dummies (i.e. Z*E1, etc.)?

Your help is very much appreciated.

  • $\begingroup$ Just to be clear, there are three exhaustive X categories and three exhaustive E categories? $\endgroup$ – shadowtalker Mar 19 '15 at 23:40
  • $\begingroup$ Yes. X1, X2 and notX. E1, E2 and notE. $\endgroup$ – Andrew Myers Mar 19 '15 at 23:41
  • $\begingroup$ (Although in hindsight 'notX' and 'notE' were probably not the best labels to choose to represent when 'X is not X1 and not X2', and when 'E is not E1 and E2'). $\endgroup$ – Andrew Myers Mar 19 '15 at 23:47
  • $\begingroup$ I'd denote the base levels with X0 and E0 $\endgroup$ – shadowtalker Mar 19 '15 at 23:49
  • $\begingroup$ comment deleted $\endgroup$ – Andrew Myers Mar 20 '15 at 0:03

Your approach is fine.

If you are fitting a model with an intercept (and you should be unless you have good reason not to) then you need to omit base cases, with or without interactions. That's because the base cases are "included" in the intercept. If it helps, you can think of the dropped interaction with the base level as an "interaction with the intercept."

You should not omit two-way interactions unless, again, you have good reason to do so. The reason for this is similar to the reason for including an intercept. Unless your data is tiny and you are starved for degrees of freedom, the loss in precision due to adding a parameter is usually small relative to the flexibility you get in the model. If the coefficient on the two-way interaction turns out to be zero, so be it. But it is almost always better to start with a big model ad progressively strip out parameters than to try and build a bigger model out of a smaller one. A search for "stepwise regression" could be enlightening as to why.

  • $\begingroup$ So, to be clear, the appropriate 'bigger model' specification would be to include all of X0, X1, X2, E0, E1, E2, Z and all their interactions (X0*E0, X0*E1, X0*E2, X1*E0, X1*E1, ..., X0*E0*Z, X0*E1*Z, ..., etc.), but omit only the level X0 and E0 while keeping the base interactions of X0*E0, X0*Z, E0*Z, X0*E0*Z? $\endgroup$ – Andrew Myers Mar 20 '15 at 0:18
  • $\begingroup$ No. X0 and E0 don't appear anywhere. You include everything else $\endgroup$ – shadowtalker Mar 20 '15 at 0:25
  • $\begingroup$ i.e. Y vs constant, Z, X1, X2, E1, E2, X1*E1, X1*E2, X2*E1, X2*E2, X1*Z, X2*Z, E1*Z, E2*Z, X1*E1*Z, X1*E2*Z, X2*E1*Z, X2*E2*Z ?? How can I tell the effect when both event E1 and event E2 do not occur and the person is in category X1 (i.e. E0=1 and X1=1)? Should I just omit X0, E0 and any interactions involving both X0 and E0 but keep any interactions involving either (but not both) X0 or E0? $\endgroup$ – Andrew Myers Mar 20 '15 at 0:38
  • $\begingroup$ What i meant is: "X0 does not appear, and E0 does not appear." At all. The effect of E0-and-X1 is just the effect of X1, as long as the model includes an intercept. An "effect" in regression is always relative to something. That is one reason why the intercept is necessary: it's an estimate of your baseline Y level. $\endgroup$ – shadowtalker Mar 20 '15 at 4:43

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.