Bookmark and Share

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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Equivalent variables but different results


From   Maarten Buis <[email protected]>
To   [email protected]
Subject   Re: st: Equivalent variables but different results
Date   Thu, 11 Jul 2013 16:11:55 +0200

I just tried it out and got exactly the same results for the two
regression commands.

I suspect that you did not ran the exact code you gave us, but instead ran

reg mpg c.length#i.foreign i.foreign

instead of:

reg mpg c.length#i1.foreign i1.foreign

The problem comes from the fact that you did not include all the main
effects, i.e. you forgot to include -length-. Stata tried to solve
that in the way I described before. However, in the second command you
explicitly forbid Stata from fixing your model, so it does what you
told it to do (but probabibly not what you want it to do). If you want
to be sure, just add all the main effects or use the ## syntax instead
of the #. Also see:
M.L. Buis (2012) "Stata tip 106: With or without reference", The Stata
Journal, 12(1), pp. 162-164.

-- Maarten

On Thu, Jul 11, 2013 at 3:46 PM, Yu Chen, PhD <[email protected]> wrote:
> Dear Statalist,
> I ran the following code, and made sure that dd is equivalent to
> c.length#i1.foreign, and foreign is equivalent to i1.foreign by using
> the list command.
> However, when I put the variables into regressions, I got very
> different results. I want to know why this happened.
> Thank you.
>
> sysuse auto , clear
> gen dd=length*foreign
> list foreign i1.foreign dd c.length#i1.foreign
> reg mpg dd foreign
> reg mpg c.length#i1.foreign i1.foreign
> *
> *   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/



-- 
---------------------------------
Maarten L. Buis
WZB
Reichpietschufer 50
10785 Berlin
Germany

http://www.maartenbuis.nl
---------------------------------
*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index