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

st: Re: creating variables from regression coefficients


From   mindy.nitkin@simmons.edu
To   statalist@hsphsun2.harvard.edu, mindy.nitkin@simmons.edu
Subject   st: Re: creating variables from regression coefficients
Date   Fri, 25 Nov 2005 15:14:00 -0500

Hi all,

I am using the program below to complete industry level regressions and then
to apply the coefficiencts from the industry regressions to firms within each
industry in order to predict the level of TA. It works very well.

I am wondering if there is a way to imput the regression coefficents into my
data set as variables for each firm's observation in addition to or instead of
the predictions.

Alternately, can Stata use the coefficients from the first regression:
TA on REV PPE in a second regressioin: TA on (REV-AR) PPE. The model I am trying
to replicate changes between in first stage and second stage regressions.

Thanks in advance,
Mindy Nitkin

>clear
>use "C:\Program Files\Stata9\data\GEINDEX\EQ4_1985_2004.dta"
> tempvar id
> sort SIC
> by SIC: gen `id'=1 if _n==1
> qui replace `id'=sum(`id')
> local i=0
> tempvar pred0
> qui gen `pred0'=.
> local n=`id'[_N]
> while `i'<`n' {
> local i=`i'+1
> local j=`i'-1
> tempvar pred pred`i'
> qui regress TA REV PPE if `id'--`i'
> qui predict `pred' if `id'==`i', xb
> qui egen `pred`i''=rmax(`pred' `pred`j'')
> drop `pred' `pred`j''
> }
> rename `pred`i'' pred
> save "C:\Program Files\Stata9\EQ4\EQ4_1985_2004.dta", replace

*
*   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