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: How to correctly code categorical variables effects in FE/RE model
From
Maarten Buis <[email protected]>
To
[email protected]
Subject
Re: st: How to correctly code categorical variables effects in FE/RE model
Date
Tue, 20 Aug 2013 15:36:42 +0200
On Tue, Aug 20, 2013 at 3:18 PM, Herman Haugland wrote:
> Suppose that I want to test for the year effects in the regression.
> I, so far, have been doing the following:
>
> xtreg y x i.year, fe
>
> But reading here (sorry for citing Wikipedia):
> http://en.wikipedia.org/wiki/Categorical_variable#Effects_coding
>
> It seems I am doing it the wrong way.
>
> How would you correctly code categorical variables (year) effects in Stata?
You did it right. Effect coding is just another way of representing
exactly the same model. Say we have two groups (years), 1 and 2 and
they are of equal size and year 1 has a value of 3 and year 2 a value
of 5. We could say the overall mean is 4 and year 1 defiates -1 from
that mean and year 2 deviates +1 from that mean. That would be effect
coding. We could also say that year 1 has a value of 3 and year two
deviates +2 from that value. That would be the default with factor
variable notation. Notice that these are just different ways of saying
exactly the same thing.
You could get effect coding with -contrast-, which can sometimes help
as that comparison fits a particular application better. It is
certainly not a case of "correct" versus "incorrect" way of doing
things, as the models are just mathematically equivalent.
-- Maarten
---------------------------------
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/