Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: How to get country-specific effects as difference from averageeffect?


From   "Joel E. Pike" <[email protected]>
To   [email protected]
Subject   RE: st: How to get country-specific effects as difference from averageeffect?
Date   Fri, 06 Sep 2002 10:02:16 -0500

Another method to get results directly is to use effects coding instead of dummy coding. In effects coding, in addition to the one signifying group membership, (country) you code a -1 for the control group (say country 1). Each regression coefficient then represents the difference between the mean for the country and the grand mean for all countries. If you need the contrast between country one and the grand mean, it can be calculated as

tg(Ntotal � ktotal � 1) = -g sum (bi)
��������������
(MSerror (((g-1)2/ng) + (1/nj))

See Cohen and Cohen Applied Multiple Regression/Correlation Analysis for the Behavioral Sciences, Second Edition, Lawrence Erlbaum Associates, Hillsdale NJ, (1983) pp. 198-204. for further discussion of effects coding.

Joel Pike

At 09:14 AM 9/6/02 -0500, you wrote:

"Neumayer,E" <[email protected]> asked

> If I do "reg y x country2-country207" the country-specific dummy
> variables country2 to country207 are relative to the left out
> category country1. If I do "reg y x country1-country207, noconst"
> instead, the constant is dropped and the country-specific dum my
> variables give each country's level. How do I get Stata to compute
> country-specific estimates as a difference from the average country
> effect? I tried "constraint define 1 country1+...+country207=0" and
> cnsreg, but that does not work.

On the assumption that, in problems like this one, code speaks loader than
words, I have appended two briefly documented examples below.

Method 1:

Save off the estimated dummies from the regression and then subtract their
mean.


Here is an example.

. use grunfeld, clear
. tab company, gen(cdum)

company | Freq. Percent Cum.
------------+-----------------------------------
1 | 20 10.00 10.00
2 | 20 10.00 20.00
3 | 20 10.00 30.00
4 | 20 10.00 40.00
5 | 20 10.00 50.00
6 | 20 10.00 60.00
7 | 20 10.00 70.00
8 | 20 10.00 80.00
9 | 20 10.00 90.00
10 | 20 10.00 100.00
------------+-----------------------------------
Total | 200 100.00

. regress invest mvalue cdum1-cdum10, nocons

Source | SS df MS Number of obs = 200
-------------+------------------------------ F( 11, 189) = 148.52
Model | 12208389.6 11 1109853.60 Prob > F = 0.0000
Residual | 1412316.51 189 7472.57415 R-squared = 0.8963
-------------+------------------------------ Adj R-squared = 0.8903
Total | 13620706.1 200 68103.5304 Root MSE = 86.444

------------------------------------------------------------------------------
invest | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
mvalue | .1898776 .0179944 10.55 0.000 .1543819 .2253733
cdum1 | -214.8799 80.34482 -2.67 0.008 -373.3677 -56.39209
cdum2 | 36.06969 40.40532 0.89 0.373 -43.63364 115.773
cdum3 | -266.324 39.92423 -6.67 0.000 -345.0784 -187.5697
cdum4 | -45.50152 23.00494 -1.98 0.049 -90.88094 -.1220956
cdum5 | 17.85154 19.77315 0.90 0.368 -21.15287 56.85595
cdum6 | -24.31194 20.75356 -1.17 0.243 -65.2503 16.62642
cdum7 | 19.15374 19.5165 0.98 0.328 -19.34441 57.65189
cdum8 | -84.49925 22.78985 -3.71 0.000 -129.4544 -39.54411
cdum9 | -21.46365 20.24042 -1.06 0.290 -61.38981 18.46251
cdum10 | -10.38181 19.37156 -0.54 0.593 -48.59405 27.83044
------------------------------------------------------------------------------

. mat bfdum = e(b)
. mat dums = bfdum[1,2...]
. mat list dums

dums[1,10]
cdum1 cdum2 cdum3 cdum4 cdum5 cdum6
y1 -214.8799 36.069688 -266.32404 -45.50152 17.851543 -24.31194

cdum7 cdum8 cdum9 cdum10
y1 19.15374 -84.499251 -21.463647 -10.381806

. mat dums_t = dums - J(1,10,1)*(dums*J(10,1,1)/10)
. mat list dums_t

dums_t[1,10]
c1 c2 c3 c4 c5 c6
r1 -155.45118 95.498401 -206.89533 13.927193 77.280256 35.116773

c7 c8 c9 c10
r1 78.582454 -25.070538 37.965067 49.046907

. mat nsum = dums_t*J(10,1,1)
. mat list nsum

symmetric nsum[1,1]
c1
r1 9.237e-14


Method 2:

Another method would be to compute the average effect from the -dums-
vector, subtract this quantity from the orginal dependent variable, and then
re-run the regression.

. mat ave_effect = (dums*J(10,1,1)/10)
. mat list ave_effect

symmetric ave_effect[1,1]
c1
y1 -59.428713

. gen double invest2 = invest-ave_effect[1,1]
. regress invest2 mvalue cdum1-cdum10, nocons

Source | SS df MS Number of obs = 200
-------------+------------------------------ F( 11, 189) = 199.33
Model | 16384388.4 11 1489489.85 Prob > F = 0.0000
Residual | 1412316.51 189 7472.57415 R-squared = 0.9206
-------------+------------------------------ Adj R-squared = 0.9160
Total | 17796704.9 200 88983.5243 Root MSE = 86.444

------------------------------------------------------------------------------
invest2 | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
mvalue | .1898776 .0179944 10.55 0.000 .1543819 .2253733
cdum1 | -155.4512 80.34482 -1.93 0.055 -313.939 3.036619
cdum2 | 95.4984 40.40532 2.36 0.019 15.79507 175.2017
cdum3 | -206.8953 39.92423 -5.18 0.000 -285.6497 -128.141
cdum4 | 13.92719 23.00494 0.61 0.546 -31.45223 59.30662
cdum5 | 77.28026 19.77315 3.91 0.000 38.27584 116.2847
cdum6 | 35.11677 20.75356 1.69 0.092 -5.821591 76.05514
cdum7 | 78.58245 19.5165 4.03 0.000 40.0843 117.0806
cdum8 | -25.07054 22.78985 -1.10 0.273 -70.02568 19.8846
cdum9 | 37.96507 20.24042 1.88 0.062 -1.961093 77.89123
cdum10 | 49.04691 19.37156 2.53 0.012 10.83466 87.25915
------------------------------------------------------------------------------


I hope that this helps.

--David
[email protected]
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*************************************************
Joel E. Pike
School of Business
University of Wisconsin
1238 Grainger Hall
975 University Avenue
Madison, WI  53706-1323
Tel: 608-265-4830
*************************************************

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index