Dear Statalisters,
I have a problem in computing the margins of an OLS regression with a panel data that I have not managed to solve by looking at previous posts - I apologies in case I overlooked similar issues that had already been discussed.
Background
I have a panel data of crime incidence (from now on, "main_rate") observed for each of the 600 municipalities of a country across 13 years and I evaluated successfully the impact of a reform that occurred in the 6th years. Now I would like to explore some heterogeneous effects, and in particular how the magnitude of the treatment coefficient changes with the size of each of the police districts the country is divided into. By "size" I mean the number of municipalities composing the police district.
The dummy "Treat" is equal to 1 for those municipalities were the reform was implemented and the dummy d turns on for the years during which the reform was enforced.
(using, instead, the interaction form ## would not change what follows)
The distribution of the size of the police (variable's name "sizeZP") district based on the value of the treatment variable is the following.
Code:
| treatment
sizeZP | 0 1 | Total
-----------+----------------------+----------
1 | 504 120 | 624
2 | 858 208 | 1,066
3 | 1,446 192 | 1,638
4 | 996 512 | 1,508
5 | 915 320 | 1,235
6 | 306 240 | 546
7 | 91 0 | 91
8 | 80 128 | 208
9 | 135 216 | 351
10 | 230 160 | 390
-----------+----------------------+----------
Total | 5,561 2,096 | 7,657
Due to the fact that there are some imbalances in the distribution (in particular, police districts with 7 municipalities are only in the control group) and to other rather conceptual reasons, I decided to regroup the police districts in this way (however, I don't believe this is actually the source of my problem. Even by using "sizeZP" I would encounter the problem described below):
Code:
gen sizePD=1 if sizeZP==1
replace sizePD=2 if sizeZP>1 & sizeZP <=4
replace sizePD=3 if sizeZP>4 & sizeZP<=7
replace sizePD=4 if sizeZP>7
The interaction term
I then proceed computing the interaction term
Code:
xtreg main_rate Treat d treatment##i.sizePD $controls i.year, fe vce(cluster INS)
This are the results I get:
Code:
Fixed-effects (within) regression Number of obs = 7655
Group variable: INS Number of groups = 589
R-sq: within = 0.0943 Obs per group: min = 11
between = 0.2051 avg = 13.0
overall = 0.1403 max = 13
F(21,588) = 17.38
corr(u_i, Xb) = -0.6185 Prob > F = 0.0000
(Std. Err. adjusted for 589 clusters in INS)
----------------------------------------------------------------------------------
| Robust
main_rate | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-----------------+----------------------------------------------------------------
WAL | 0 (omitted)
d | -.0441572 .0209879 -2.10 0.036 -.0853775 -.0029369
1.treatment | -.1234831 .0265136 -4.66 0.000 -.175556 -.0714102
|
sizePD |
2 | 0 (omitted)
3 | 0 (omitted)
4 | 0 (omitted)
|
treatment#sizePD |
1 2 | .0595935 .0275074 2.17 0.031 .0055688 .1136182
1 3 | .0610467 .0297444 2.05 0.041 .0026285 .1194648
1 4 | .0920392 .0321078 2.87 0.004 .0289793 .1550992
|
pop | -2.26e-06 1.91e-06 -1.18 0.237 -6.02e-06 1.49e-06
density | -.0000497 .0000186 -2.67 0.008 -.0000863 -.0000132
meanyxdecla | -3.00e-06 3.94e-06 -0.76 0.446 -.0000107 4.73e-06
unemp | .0016622 .0049068 0.34 0.735 -.0079748 .0112993
edu_low | .0080593 .0069817 1.15 0.249 -.0056527 .0217713
|
year |
2001 | -.0124893 .0083754 -1.49 0.136 -.0289387 .00396
2002 | .0212187 .0107612 1.97 0.049 .0000836 .0423537
2003 | -.0054469 .0142556 -0.38 0.703 -.0334449 .0225512
2004 | -.0272049 .0168966 -1.61 0.108 -.06039 .0059802
2005 | 0 (omitted)
2006 | -.0055406 .0066912 -0.83 0.408 -.0186822 .0076009
2007 | .0142893 .0107971 1.32 0.186 -.0069164 .0354949
2008 | .0312251 .0146257 2.13 0.033 .0025001 .05995
2009 | .0184093 .0173059 1.06 0.288 -.0155796 .0523983
2010 | .0089712 .019733 0.45 0.650 -.0297845 .047727
2011 | .0410702 .0246737 1.66 0.097 -.0073891 .0895295
2012 | .0293179 .0309947 0.95 0.345 -.0315559 .0901918
|
_cons | 3.700322 .2984158 12.40 0.000 3.114231 4.286412
-----------------+----------------------------------------------------------------
sigma_u | .51188845
sigma_e | .14790359
rho | .92294798 (fraction of variance due to u_i)
----------------------------------------------------------------------------------
The margins... and the problem
In computing margins, I tried several combinations of
Code:
margins treatment##sizePD
and obtained this:
Code:
. margins treatment##sizePD
Predictive margins Number of obs = 7655
Model VCE : Robust
Expression : Linear prediction, predict()
----------------------------------------------------------------------------------
| Delta-method
| Margin Std. Err. z P>|z| [95% Conf. Interval]
-----------------+----------------------------------------------------------------
treatment |
0 | . (not estimable)
1 | . (not estimable)
|
sizePD |
1 | . (not estimable)
2 | . (not estimable)
3 | . (not estimable)
4 | . (not estimable)
|
treatment#sizePD |
0 1 | . (not estimable)
0 2 | . (not estimable)
0 3 | . (not estimable)
0 4 | . (not estimable)
1 1 | . (not estimable)
1 2 | . (not estimable)
1 3 | . (not estimable)
1 4 | . (not estimable)
----------------------------------------------------------------------------------
I have the feeling I am missing something really basic detail, but I have been digging into it so much that I don't manage to step back and find a solution anymore.
Does anyone of you have a solution to this oddity? If you need more information about the type of data, please do not hesitate to ask me below.
Thank you in advance!
Andrea