Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: predict when using by for regress


From   "Scott Merryman" <smerryman@kc.rr.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Re: predict when using by for regress
Date   Sun, 14 Mar 2004 22:08:09 -0600

Here is oneway:

egen group = group(country year)

gen hlnoutput = .
levels group, local(levels)
foreach l of local levels {
    regress lnoutput lnl lnk lnm if group == `l'
    predict temp
    replace hlnoutput = temp if group == `l'
    drop temp
    }

-levels- in conjunction with -foreach- is very useful to cycle through distinct
groups.

Hope this helps,
Scott

----- Original Message ----- 
From: "Helena Schweiger" <schweige@econ.bsos.umd.edu>
To: <statalist@hsphsun2.harvard.edu>
Sent: Sunday, March 14, 2004 6:49 PM
Subject: st: predict when using by for regress


> Hi all,
>
> My dataset has three dimensions (country, year, firm) and I'm estimating
> total factor productivity (using OLS estimates as a reference for more
> appropriate estimation techniques) by country and year. I want to get
> the estimated values of log of output, so that I can calculate log of
> TFP, but if I use predict after my regress command - which would look
> for example like this:
> sort country year;
> by country year: regress lnoutput lnl lnk lnm;
> predict hlnoutput, xb;
>
> - it uses the coefficients estimated in the last country-year pair,
> which is not what I want. There probably is a way to do this (other than
> writing down the equations for each country-year pair to get the
> estimated values which is very time-consuming, since all the
> coefficients need to be typed for each pair), but I cannot find it.
> Could you please help?
>
> Thanks,
> Helena




*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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   |   What's new   |   Site index