Bookmark and Share

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


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

Re: st: coding of factor variables


From   Maarten Buis <maartenlbuis@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: coding of factor variables
Date   Sun, 5 Jun 2011 09:55:01 +0200

On Sat, Jun 4, 2011 at 11:03 PM, Sun, Yan (IFPRI) wrote:
> Part I, when I have three groups, I create dummies for group1 and group2
> (treating group3 as a base):
> My equation is reg y x z group1 group2
> I want to calculate:
> predict xb, xb
> gen xbb1=xb-_b[group1]*group1-_b[group2]*group2
>
> Part II, when I have 400 groups now
> My equation now is: xi: reg y x z i.group
> Predict xb, xb
> How do I calculate xbb1? Could I write xbb1=xb-b[i.group]*i.group? Since
> My problem is that I am not able write all of these 400 groups in the
> code.

Typically you do not add that many dummies but use -xtreg , fe-
instead (or -areg-). After -xtreg- you can still -predict- the fixed
effects (what you called xbb1), see the -predict- section of -help
xtreg postestimation-.

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany


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


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index