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: Coefficients resulting from Cross-Sectional Regressions


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: Coefficients resulting from Cross-Sectional Regressions
Date   Fri, 6 Apr 2012 16:20:00 +0100

statsby _b, by(gvkey) saving(coefsales): regress lnebit lnsales

conducts separate regressions for each firm. The coefficient does not
differ by year, as different years are pooled in each regression.

You can put the results of -statsby- back in the original dataset by
using -merge-.

Alternatively,

egen group = group(gvkey)
gen coeff = .
su group, meanonly

qui forval i = 1/`r(max)'  {
          regress lnebit lnsales if group == `i'
          replace coeff = _b[lnsales] if group == `i'
}

Nick

2012/4/6 Fabian Schönenberger <[email protected]>:

> I am an absolute beginner in Stata and face now some challenges with
> generating regression coefficients as new variable for further computations.
> I use tsset id t to conduct cross-sectional regressions. ID is gvkey which
> identifies firm (about 4’000 firms in my sample), t is fyear which
> identifies the specific year (ranging from 1984 to 2010). What I am looking
> for is the function to run cross-sectional regressions and generating
> coefficients as new variable to my list of variables. In other words: I am
> looking for b, specified for each ID for every t (yi,t = ai + bi,t*xi,t).
> I have tried the following:
> statsby _b, by(gvkey) saving(coefsales): regress lnebit lnsales
> However, two problems arise. First, the major problem, I only get
> coefficients for gvkey, but not specified for every point in time (fyear).
> Second, the coefsales are safed in a new file, but I would prefer a new
> variable in my list of variable.
> Any suggestions to solve the two problems are highly appreciated.

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index