Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 72764

Varlist and regression coefficient

$
0
0
Hi,

I am trying to make my code more flexible using macro varlist since I would like to use various combinations of independent variables. Here is an example of what I'm trying to do:
Code:
use http://www.stata-press.com/data/r13/ibm, clear
tsset t

generate ibmadj = ibm - irx
generate spxadj = spx - irx

sort date
save ibm.dta, replace

rolling _b, window(200) saving(betas, replace) keep(date): regress ibmadj spxadj irx

use betas.dta, clear

merge 1:1 date using ibm.dta, keepusing(ibmadj spxadj irx)

* Calculate the predition:
gen ibmadj_hat = _b_cons+spxadj*_b_spxadj+irx*_b_irx
In this case the independant variables are: spxadj irx. I would like to incorporate the following in a way that I can calculate the prediction "ibmadj_hat":

Code:
local dep ibmadj
local index spxadj irx
Is there an easy way to do that? Thanks!



Viewing all articles
Browse latest Browse all 72764

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>