Bookmark and Share

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: generate regression coefficients as varaibles


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: generate regression coefficients as varaibles
Date   Wed, 9 Jan 2013 18:37:54 +0000

You don't explain what "is not working" means. This is crucial.

Your code appears more complicated than needed, but I can't see a bug.

gen coefficientCon=.
forvalue y= 2001/2012{
               reg Wscaled Wone Wscaled_ch  WPPE if  dind1 & datayearfiscal==`y'
               replace coefficientCon = _b[_cons]  if datayearfiscal==`y'
}

See also -statsby-.

On Wed, Jan 9, 2013 at 6:30 PM, Nahla Betelmal <nahlaib@gmail.com> wrote:
> Dear Statalist helpers,
>
> I am applying a cross sectional regression for 37 industries (i.e.
> dind) over 11 fiscal years. I need to
> extract the coefficients of each industry/year to substitute in a sub-sample.
>
> I tried this loop but it is not working:
>
> gen coefficientCon=.
> forvalue y= 2001/2012{
> reg Wscaled Wone Wscaled_ch  WPPE if  dind1 & datayearfiscal==`y'
> scalar bvar=_b[_cons]
> gen bvar=_b[_cons] if datayearfiscal==`y'
> replace coefficientCon= bvar if datayearfiscal==`y'
> drop bvar
> }
>
> the out put I hope to get is silmilar to this in the edit file
>
>  year       industry        coefficientCon    coefficientb1       coefficientb2
> 2001         dind1            0.2324                1,4356             8.98
> 2002         dind1            0.654                   1.445              3.98
> .
> .
> 2011
> 2001        dind2              0.343                 .4344               2.3434
> .
> .
*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index