Hi
I am trying to regress a y variable with a lot of x variables but I only want to include variables where the correlation between y and the individual x is above or below a certain value in the regression.
The data is reported weekly.
I have 474 x variables in total and have found each variable's rolling correlations with the y variable for the previous 25 weeks. But I cannot find a way to link the correlations with the variables. I even tried with dummy variables.
Is this somehow possible?
I am trying to regress a y variable with a lot of x variables but I only want to include variables where the correlation between y and the individual x is above or below a certain value in the regression.
The data is reported weekly.
I have 474 x variables in total and have found each variable's rolling correlations with the y variable for the previous 25 weeks. But I cannot find a way to link the correlations with the variables. I even tried with dummy variables.
Is this somehow possible?
Code:
use "Google.dta" gen fakedate=_n tsset fakedate merge m:m fakedate using "Index.dta" forvalues i=1/439{ gen co`i'=. gen cohej`i'=. forvalues j=27/747{ corr OMXC20 Word`i' if fakedate<`j'-1 & fakedate>=`j'-26 replace co`i'=r(rho) in `j' replace cohej`i'=1 if co`i' < -0.2 | co`i' > 0.2 in `j' replace cohej`i'=. if co`i'==. } *drop co`i' } forvalues j=27/747{ reg OMXC20 Word1-Word439 if fakedate<`j'-1 & fakedate>=`j'-26 & co`i'==1 }
Comment