[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: missing dummy variable

From   Ben John <>
Subject   st: Re: missing dummy variable
Date   Thu, 4 Oct 2007 19:55:16 +0100

Thank you very much: Maarten and Rich

How can I apply your suggestion to xtregar?

Thank you!

Note that if you want the R-squared (e.g.) values to be comparable
between the two models you should use the hascons option rather than
the nocons option -- see the manual

also, another option is to have all dummies and the constant by
constraining the coefficients of the set of dummies to sum to 0


I am first going to explain that both models contain exactly the same
information, before I am going to tell you how to add all dummies.

Say we want to know how foreign and domestic cars differ with respect
to mpg. We can do that in two ways: We can do a regression of mpg on a
dummy which is 1 for foreign and 0 for domestic cars. The equation than
looks like this:

mpg = b0 + b1 * foreign

The expected mpg for foreign cars is than:
E(mpg|foreign) = b0 + b1 * 1 = b0 + b1

The expected mpg for domestic cars is than:
E(mpg|foreign) = b0 + b1 * 0 = b0
So the constant tells you the expected mpg for domestic cars and b1
tells you how much foreign cars differ from domestic cars.

An alternative would be to add a dummie for foreign cars and a dummie
for domestic cars:

mpg = b1 * foreign + b2 * domestic

The expected mpg for foreign cars is than:
E(mpg|foreign) = b1 * 1 + b2 * 0 = b1

The expected mpg for domestic cars is than:
E(mpg|foreign) = b1 * 0 + b2 * 1 = b2
So now b1 and b2 tell you the expected value of respectively foreign
and domestic cars. The two model contain exactly the same information:
Say that the mean mpg for domestic cars is 20 and is 5 more for foreign
cars is exactly the same as saying that the mean mpg is 20 for domestic
cars and 25 for foreign cars.

You may have noticed that in the second model (both dummies) I did not
have a constant in the equation, this is delibarate. If you want to
enter all dummies you have to exclude the constant. The way to do that
is to add the -noconst- option in Stata, see the example below:

*------------------ begin example ---------------
sysuse auto, clear
gen domestic = !foreign

reg mpg foreign
reg mpg foreign domestic, noconst
*------------------- end example ----------------
(For more on how to use examples I sent to the Statalist, see )

Hope this helps,

> I wonder whether there is a solution to avoid missing the first dummy
> variable in stata programm? I need all of the dummy variables in the
> equations.
> Many thanks in advance.
> Ben

*   For searches and help try:

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