Saving Regression Coefficients in STATA

stekun

New Member
Hi,

I am running a first stage model that looks something like:

y = xB + sum(cG) + e

where c is a bunch of category dummy variables (and G is the associated coefficient).

I know that STATA will save the estimated G's in a system variable: _b[G_i] (where i indexes each coefficient).

However, I would then like to use these G's in a model where I regress some other variable, say z, on the estimated G's (and other stuff). Does anyone know how I can code this in STATA?

More specifically, I want to collapse a dataset using the command:

collapse {a bunch of variables}, by(c)

and I want the resulting dataset to have the estimated G's as one of the columns. Any hints?

Steve

Etienne

New Member
If I understand well, you want a column G which rows correspond to G_c. Then after doing the regression that generates the _b[G_i] I suggest this :

collapse {a bunch of variables}, by(c)

gen G = .
levelsof c, local(clist)
foreach c of local clist {
replace G = _b[G_c'] if c == c'
}

Hope this helps !

sam1982

New Member
Hi, I wonder whether is it possible if previous codes are applicable on panel data analysis (Fama and Macbeth). Actually, I am estimating the following model:

tsset company time
xtfmb var1 var2 var3 var4 var5....

and I want to save the coefficient of var2 and use it as dependent variable in another regression.

I know that I can use statsby but it takes long time specially when I have more than 1000 companies for over 40 years.

Your help will be highly appreciated,

Sam