Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# Re: st: Strange Behaviour When Selecting Levels For Factor Variables In Regression With i#

 From Sarah Elizabeth Edgington To statalist@hsphsun2.harvard.edu Subject Re: st: Strange Behaviour When Selecting Levels For Factor Variables In Regression With i# Date Fri, 18 Jan 2013 22:12:53 -0800

I share Daniel's confusion and this explanation doesn't make it any clearer to me. If sex were not a binary variable then the other coefficients changing would make sense because the different regressions would actually be changing how sex is coded. However, with a variable that's coded 0/1 to begin with, isn't i.sex the equivalent of i1.sex? That is, isn't an indicator for when sex=1 exactly the same variable as the original sex variable? In which case you'd expect the first two regression examples to be exactly the same. The fact that they aren't suggests to me that there's something I don't understand about the i1.sex factor variable syntax. What am I missing?
```
-Sarah

At 08:32 PM 1/18/2013, you wrote:
```
```Daniel,

The definition of a coefficient in a multiple regression model
includes the list of all the other predictors in the model.  Thus,
using a different predictor for sex changes the definitions of the
coefficients for patient and the categories of when.

If the other predictors were orthogonal to sex, the numerical values
of their coefficients would not differ among the models, even though
the definitions were not the same.

Your models may be equivalent, in the sense that they have the same
predicted values and the same residuals, but they are not all the same
model.

I hope this discussion helps.

David Hoaglin

On Fri, Jan 18, 2013 at 6:45 PM,  <daniel56061-stata@yahoo.de> wrote:
> Hello,
>
```
> when i use indicator i with selecting level of a factor variable like i1.varname to run a regression I get strange results.
```>
> For example:
>
> sysuse blong,clear
> regress bp i.sex    i.when  c.patient   i.when#c.patient
> regress bp i1.sex  i.when  c.patient   i.when#c.patient
> regress bp i0.sex  i.when  c.patient   i.when#c.patient
>
```
> This regression is wihout sense but theoretically it should estimate the same model and should give same results except for variable sex cause all I do is demand an indicator for a different level of a 2-level variable sex. > But if I run these lines I get three regressions with three different coefficients for the variable "when" and "patient" even I didnt change anything that should be related to these variables.
```> Whats wrong here?
>
> regards
> Daniel
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/
```