I am attempting to regress every 6 months, then append these regressions to form a single index from 2004-2018. However, I am getting the mismatch error-
I want to get the variables with negative t-statistics, and only include these in my average to put into 'UKIS1', then do the same for the next 6 months, and append these to form a single UKIS
Is this the correct way to do it, and is there something I can do to fix my error?
Code:
. foreach var of varlist ldiffcost_w_res -ldiffexpense_w_res {
2. regress `var' rmrf, robust
3. if date >= "01-01-2004" & date <= "06-30-2004"
4. if e(b)[1,1] < 0 local negvars `negvars' `var'
5. egen UKIS1 = rowmean(`negvars')
6. save UKIS1, replace
7. }
Linear regression Number of obs = 3,536
F(1, 3534) = 3.03
Prob > F = 0.0819
R-squared = 0.0008
Root MSE = .10476
------------------------------------------------------------------------------
| Robust
ldiffcost_~s | Coefficient std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
rmrf | .2680922 .1540329 1.74 0.082 -.0339103 .5700946
_cons | .0002808 .0017616 0.16 0.873 -.003173 .0037346
------------------------------------------------------------------------------
type mismatch
r(109);
Is this the correct way to do it, and is there something I can do to fix my error?

Comment