# Re: st: AW: how to get slopes by clusters in a linear regression

 From László Sándor To statalist@hsphsun2.harvard.edu Subject Re: st: AW: how to get slopes by clusters in a linear regression Date Tue, 25 Aug 2009 12:13:20 -0400

```Thanks, Eric,
the treatment was a dummy, so I don't need to tabulate that -- but I
would need to tabulate my cluster id, to have interactions if I want
to put all that into one regression. However, that would mean
thousands of new variables, not very elegant. I think I'll stick to
'regression of residuals on residuals' as mentioned above, if nothing
else comes up.

Thanks again,

Laszlo

On Tue, Aug 25, 2009 at 11:59 AM, DE SOUZA
Eric<eric.desouza@coleurope.eu> wrote:
> How is your treatment dummy defined?
> If it is a categorical variable: 1, 2 ,3, etc, define a set of dummies by -tab(var), gen(var)
> Example:
> . webuse grunfeld
>
> . tab(company), gen(company)
>
> . reg invest mvalue kstock company1-company9
> .......
> ------------------------------------------------------------------------------
>      invest |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
> -------------+----------------------------------------------------------------
>      mvalue |   .1101238   .0118567     9.29   0.000     .0867345    .1335131
>      kstock |   .3100653   .0173545    17.87   0.000     .2758308    .3442999
>    company1 |  -63.72884   50.33023    -1.27   0.207    -163.0134    35.55572
>    company2 |   108.4737   26.95322     4.02   0.000     55.30405    161.6433
>    company3 |   -229.004   26.51076    -8.64   0.000    -281.3008   -176.7072
>    company4 |  -21.24145   18.04916    -1.18   0.241    -56.84635    14.36346
>    company5 |   -108.049   18.43201    -5.86   0.000    -144.4091   -71.68883
>    company6 |  -16.59345   17.12189    -0.97   0.334    -50.36917    17.18227
>    company7 |  -59.98563   17.44425    -3.44   0.001    -94.39725   -25.57401
>    company8 |  -50.97781    17.9877    -2.83   0.005    -86.46148   -15.49414
>    company9 |  -80.65443   17.37635    -4.64   0.000    -114.9321   -46.37675
>       _cons |  -6.567843   11.82689    -0.56   0.579    -29.89831    16.76262
> ------------------------------------------------------------------------------
>
> Eric
>
>
>
> Eric de Souza
> College of Europe
> Brugge (Bruges), Belgium
> http://www.coleurope.eu
>
> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of László Sándor
> Sent: 25 August 2009 17:48
> To: statalist@hsphsun2.harvard.edu
> Subject: Re: st: AW: how to get slopes by clusters in a linear regression
>
> Thank you, Martin!
>
> I don't see how this could be used to estimate the model in a single command -- statsby still seem to break down the regression by clusters, without the intercluster restrictions on the controls/covariates.
>
> However, this led me to try to apply the Frisch-Waugh-Lowell theorem:
> I estimate the univariate regression of outcome on treatment by each cluster, I must only use the residuals for both after regressing them on the set of controls.
>
> If there is no other way, this seems to be doable.
>
> Thanks again!
>
> Laszlo
>
> On Tue, Aug 25, 2009 at 11:23 AM, Martin Weiss<martin.weiss1@gmx.de> wrote:
>>
>> <>
>>
>>
>> ******
>> h statsby
>> ******
>>
>>
>> HTH
>> Martin
>>
>>
>> -----Ursprüngliche Nachricht-----
>> Von: owner-statalist@hsphsun2.harvard.edu
>> [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von László
>> Sándor
>> Gesendet: Dienstag, 25. August 2009 17:20
>> An: statalist@hsphsun2.harvard.edu
>> Betreff: st: how to get slopes by clusters in a linear regression
>>
>> Dear Fellow Statalisters,
>>
>> I want to extend a fixed-effects-type model to allow for different
>> coefficients on a variable (actually a treatment dummy) by each
>> cluster I have. The richness of my data would allow for that. However,
>> I did not find a way to do it in Stata that would report (and collect)
>> the coefficients themselves. -xtmixed- doesn't seem to do so. I would
>> like to restrict the coefficients on controls to be equal across
>> clusters, so estimation by cluster is not a solution either.
>>
>> If there were a way that could collect the slopes to a single new
>> variable (with the same value for observations in the same cluster,
>> naturally), that would be the best. It would be great if I did not
>> need to introduce all the 1438 cluster-indicator variables and
>> interactions myself, and collect the coefficients.
>>
>> Thank you for any guidance in advance!
>>
>> Laszlo
>> *
>> *   For searches and help try:
>> *   http://www.stata.com/help.cgi?search
>> *   http://www.stata.com/support/statalist/faq
>> *   http://www.ats.ucla.edu/stat/stata/
>>
>>
>> *
>> *   For searches and help try:
>> *   http://www.stata.com/help.cgi?search
>> *   http://www.stata.com/support/statalist/faq
>> *   http://www.ats.ucla.edu/stat/stata/
>>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```