Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.

# Re: Re-re-post: Stata 11 - Factor variables in a regression command

 From Richard Williams To statalist@hsphsun2.harvard.edu Subject Re: Re-re-post: Stata 11 - Factor variables in a regression command Date Sat, 01 May 2010 14:13:11 -0400

```At 12:20 PM 5/1/2010, Richard Williams wrote:
```
These factor variables are nice but make sure you understand what parameterization you are getting and how to interpret it!!! Personally I think there is much to be said for explicitly including the main effects so I can make sure they are there and to make my commands easier to read, i.e. I prefer
```
logit y i.a i.b a#b

over

logit y a##b
```
```
```
Backtracking a bit -- if the model is rather complicated (2 way interactions, 3 way interactions, squared and cubic terms, whatever) the ## notation may be good in that it seems to ensure that you don't miss any of the lower level effects, e.g. if you have a 3 way interaction, you will get the main effects, all the 2 way interactions, and the 3 way interactions. This saves some typing and also means you don't accidentally miss something. For example,
```
. use "http://www.indiana.edu/~jslsoc/stata/spex_data/ordwarm2.dta";, clear
(77 & 89 General Social Survey)

. logit  warmlt2  yr89##male##white, nolog

Logistic regression                               Number of obs   =       2293
LR chi2(7)      =      72.91
Prob > chi2     =     0.0000
Log likelihood = -847.45724                       Pseudo R2       =     0.0412

------------------------------------------------------------------------------
warmlt2 |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
1.yr89 |  -1.273307   .6709848    -1.90   0.058    -2.588413    .0417992
1.male |  -.4390817   .5343667    -0.82   0.411    -1.486421    .6082578
|
yr89#male |
1 1  |   1.643054   .9264743     1.77   0.076    -.1728023     3.45891
|
1.white |   .3282413   .3396167     0.97   0.334    -.3373951    .9938778
|
yr89#white |
1 1  |  -.0163456    .713958    -0.02   0.982    -1.415678    1.382986
|
male#white |
1 1  |   .6641487   .5548806     1.20   0.231    -.4233973    1.751695
|
yr89#male#|
white |
1 1 1  |  -1.316027    .981776    -1.34   0.180    -3.240273    .6082182
|
_cons |  -1.958814   .3220708    -6.08   0.000    -2.590061   -1.327566
------------------------------------------------------------------------------

```
I would have preferred that the 1.white appear right after the 1.yr89 and the 1.male (i.e. have all the main effects together), but everything you want is in there somewhere.
```
-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
HOME:   (574)289-5227
EMAIL:  Richard.A.Williams.5@ND.Edu
WWW:    http://www.nd.edu/~rwilliam

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