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

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

From   Richard Williams <[email protected]>
To   [email protected], [email protected]
Subject   Re: st: How to 'predict' constant by region?
Date   Thu, 07 Aug 2008 09:24:14 -0400

At 11:01 PM 8/6/2008, Galina An wrote:
Dear statalist users,
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.
Can anybody give me a hint?
With the 2nd by command, you are not rerunning all the separate regressions. Instead, the gen command just picks up the constant for the last region's regression.

You could use the -statsby- command. Or, do something like

gen constant = .
levelsof region, local(levels)
foreach levl of local levels {
reg migration q1 q2 q3 if region == `levl'
replace constant=_b[_cons] if region == `levl'

I think there are some other handy utilities for such tasks but I forget what they are.

Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
HOME: (574)289-5227
EMAIL: [email protected]

* For searches and help try:

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