# re: st: Adjust after regression involving categorical variables

 From Kit Baum To statalist@hsphsun2.harvard.edu Subject re: st: Adjust after regression involving categorical variables Date Wed, 28 Oct 2009 10:37:55 -0400

```<>
Maarten suggested

This is a case where you can meaningfully use "effect coding".
This is a way of coding the categorical variable dummies so
that they measure the effect relative to the overal mean
rather than relative to the reference catogories. If you set
the resulting dummies at zero you will get the adjusted prices
for an average car. Effect coding is implemented in the -xi3-
package by Michael Mitchell and Phil Ender. You can find it
by typing in Stata -findit xi3-.

*---------------- begin example -----------------
sysuse auto, clear
xi3: regress price weight turn e.rep i.foreign

_Irep78_2=0 ///
_Irep78_3=0 ///
_Irep78_4=0 ///
_Irep78_5=0 ///
, by(foreign)
*--------------- end example --------------------

Or much more easily as

regress price weight turn i.rep78 i.foreign
margins i.foreign, asbal

```
Predictive margins Number of obs = 69
```Model VCE    : OLS

Expression   : Linear prediction, predict()
at           : rep78            (asbalanced)
foreign          (asbalanced)

------------------------------------------------------------------------------
|            Delta-method
```
| Margin Std. Err. z P>|z| [95% Conf. Interval] ------------- +----------------------------------------------------------------
```     foreign |
```
0 | 5077.14 453.2891 11.20 0.000 4188.71 5965.57 1 | 8316.978 726.8291 11.44 0.000 6892.419 9741.537
```------------------------------------------------------------------------------

Kit Baum   |   Boston College Economics & DIW Berlin   |   http://ideas.repec.org/e/pba1.html
```
An Introduction to Stata Programming | http://www.stata-press.com/books/isp.html
```   An Introduction to Modern Econometrics Using Stata  |   http://www.stata-press.com/books/imeus.html

*
*   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/
```