Statalist


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

Re: st: How to 'predict' constant by region?


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: How to 'predict' constant by region?
Date   Thu, 7 Aug 2008 06:27:02 +0100 (BST)

--- Galina An <[email protected]> wrote:
> I was wondering if anybody encountered the following problem:
> when I run the following code, I need to save constants for different
> 
> regions:
> 
> by region: reg migration q1 q2 q3
> by region: gen constant=_b[_cons]
> 
> However, I get the same constant for all regions.

_b[_cons] gives you the constant for the reference region (the dummy
that was left out), which is by definition constant and does not change
over regions. You may have added dummies and interpret that as
different constants for different regions, but Stata has no way of
knowing that it has to treat those dummies differently from the other
variables. What you seem to want is the command -adjust-, as in the
example below:

*----------- begin example ------------
sysuse auto, clear
recode rep78 1/2= 3
tab rep78 , gen(rep)

reg mpg rep1 rep2 trunk
adjust trunk=0, by(rep78) gen(cons)
*---------- end example ---------------
(For more on how to use examples I sent to the Statalist, see
http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html )

Hope this helps,
Maarten

-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


      __________________________________________________________
Not happy with your email address?.
Get the one you really want - millions of new email addresses available now at Yahoo! http://uk.docs.yahoo.com/ymail/new.html
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index