# Compare coefficients across groups in panel data set

I want to test for differences in (regression) coefficients across two groups. I understand, that this is possible by including interaction terms and performing a Chow-Test.

But what do you do if you can't identify the groups in your panel dataset anymore? Have a look at this example. This may clarify my problem:

Imagine 2 groups of people. Over 1 month, you record how much everybody spend on ice-cream (4 sorts), how they rated the ice-cream and what size of ice-cream they got. Your dependent variable is rating, your independent variables are cost and size.

   +-------------------------------------------------+
| day | ice-cream | rating | cost  | size  | group|
|-----+-----------+--------+-------+--------------+
1. |  1  |  vanilla  |  2     |  3    |  4    | 1    |
2. |  1  |  choco    |  1     |  4    |  3    | 0    |
3. |  1  |  vanilla  |  2     |  2    |  1    | 1    |
4. |  1  |  hazelnut |  9     |  2    |  1    | 0    |
5. |  2  |  hazelnut |  2     |  1    |  1    | 0    |
6. |  2  |  hazelnut |  5     |  1    |  1    | 0    |
7. |  2  |  vanilla  |  6     |  5    |  2    | 1    |
8. |  3  |  berry    |  1     |  6    |  3    | 0    |
9. |  3  |  berry    |  6     |  4    |  2    | 0    |
10. |  3  |  berry    |  7     |  3    |  4    | 1    |
11. |  3  |  berry    |  5     |  2    |  1    | 1    |
12. |  3  |  vanilla  |  4     |  1    |  2    | 0    |
13. |  3  |  vanilla  |  4     |  5    |  2    | 0    |
etc |  .  |  ......   |  .     |  .    |  ...  | .    |
+-------------------------------------------------+


Not caring about groups at all, I could just aggregate the data to a day-icecream level (because I want to consider fixed effects at the ice-cream level). My panel dataset would look like this:

    +------------------------------------------+
| day | ice-cream | rating | cost  | size  |
|-----+-----------+--------+-------+-------+
1. |  1  |  vanilla  |  2     |  2.5  |  2.5  |
2. |  1  |  choco    |  1     |  4    |  3    |
3. |  1  |  hazelnut |  9     |  2    |  1    |
4. |  2  |  hazelnut |  3.5   |  1    |  1    |
5. |  2  |  vanilla  |  6     |  5    |  2    |
6. |  3  |  berry    |  4.75  |  3.7  |  2.5  |
7. |  3  |  vanilla  |  4     |  3    |  2    |
etc |  .  |  ......   |  .     |  .    |  ...  |
+------------------------------------------+


However, this doesn't allow me to calculate a regression model for each group. So, I followed a different path: I split the raw data set according to groups (one set for each group) and aggregated to the daily level afterwards. The two panel datasets looks like this:

Group 1

    +-------------------------------------------------+
| day | ice-cream | rating | cost  | size  | group|
|-----+-----------+--------+-------+--------------+
1. |  1  |  vanilla  |  1.5   |  2.5  |  2.5  | 1    |
2. |  2  |  vanilla  |  6     |  5    |  2    | 1    |
3. |  3  |  berry    |  7     |  3    |  4    | 1    |
4. |  3  |  vanilla  |  6     |  2.5  |  2.5  | 1    |
etc |  .  |  ......   |  .     |  .    |  ...  | .    |
+-------------------------------------------------+


Group 2

    +-------------------------------------------------+
| day | ice-cream | rating | cost  | size  | group|
|-----+-----------+--------+-------+--------------+
1. |  1  |  choco    |  1     |  4    |  3    | 0    |
2. |  1  |  hazelnut |  9     |  2    |  1    | 0    |
3. |  2  |  hazelnut |  3.5   |  1    |  1    | 0    |
4. |  3  |  berry    |  3.5   |  5    |  2.5  | 0    |
5. |  3  |  vanilla  |  4     |  3    |  2    | 0    |
etc |  .  |  ......   |  .     |  .    |  ...  | .    |
+-------------------------------------------------+


For each dataset, I run a fixed-effects regression. This leaves me with two model outputs which I want to compare and see whether the coefficients are different.

Any ideas how to test coefficients across models in this case?

• You have already answered your own question. Just re-stack your datasets, noting the group number in each dataset before you do it. Then estimate your model, with the appropriate group interaction term. – D L Dahly Dec 3 '13 at 16:31
• @DLDahly, stacking both datasets leaves me with more than one timevariable per unit (ice-cream), which is not allowed in a panel dataset. Do I need to recode the time variable? (e.g. vanilla on day 3 would occur twice in a stacked dataset). Thanks! – SPi Dec 5 '13 at 10:00
• Can anyone help? I'm stuck here but I feel like DLDahly's comment points to the right direction. Still, I can't figure out how to 'restock' the datasets correcty to panel format.. – SPi Dec 6 '13 at 8:38
• Instead of splitting the dataset and then aggregating, why not aggregrate by group within the full dataset. That said, I suspect that you don't really need to aggregate/collapse your data at all. Can you specify the hypothesis or research question you are trying to test or model? – D L Dahly Dec 6 '13 at 9:40
• Imagine the ice-cream to be different stocks. Thus, the baseline model (without accounting for different groups of people) is based on a panel dataset with one stock per day (fixed-effects at the stock-level). The IVs stem from the people's behavior (ice-cream spendings and size in this example). Next I want to test whether the regression coefficients I get for the IVs are different for the two groups of people..the ice-cream illustrates the problem quite realistically.. Thanks a lot for your help! – SPi Dec 6 '13 at 16:14