I have time-series data. I want to run rolling regressions and obtain the decomposed R2 (also called Shapley values)
I can easily obtain the slope coefficients as follows.
Code:
rolling _b , window (40) saving (betas, replace) keep(fqdate):reg rgdp x1 x2
The problem is that I do not know how rego, for example, saves the decomposed R2. I did the following to investigate further
Code:
. rego gdp x1 x2, noperc ------------------------------------------------------------------------------ Gr Regressor | Coef. Std.Err. P>|t| Std.Coef. Shapley R2 --------------------+--------------------------------------------------------- 1 x1 | -.1608338 * .0853014 0.061 -0.1375 0.0191 2 x2 | .056379 * .0308584 0.069 0.1333 0.0179 - Intercept | .0256372 .0061803 0.000 --------------------+--------------------------------------------------------- Observations | 184 Overall R2 | 0.03703 Root MSE | .0799205 F-stat. Model | 3.480318 ** 0.033 Log Likelihood | 205.3446 ------------------------------------------------------------------------------ . ereturn list scalars: e(N) = 184 e(df_m) = 2 e(df_r) = 181 e(F) = 3.480318446798436 e(r2) = .0370324181096345 e(rmse) = .0799205236317307 e(mss) = .0444596071032519 e(rss) = 1.156099507660175 e(r2_a) = .0263918923428902 e(ll) = 205.3446297734195 e(ll_0) = 201.8729608831572 e(rank) = 3 e(noperc) = 1 macros: e(cmdline) : "rego gdp x1 x2, noperc" e(regressors) : " x1 x2" e(cmd) : "rego" e(title) : "Linear regression" e(marginsok) : "XB default" e(vce) : "ols" e(depvar) : "gdp" e(properties) : "b V" e(predict) : "regres_p" e(model) : "ols" e(estat_cmd) : "regress_estat" matrices: e(b) : 1 x 3 e(V) : 3 x 3 e(shapley_perc) : 1 x 2 e(shapley) : 1 x 2 e(group_details) : 2 x 1 e(vars_per_group) : 2 x 1 e(stdb) : 1 x 3 functions: e(sample)
Then I thought to try something like:
Code:
. rolling _b decomposed=e(shapley_perc), window (40) saving (betas, replace) keep(fqdate):rego gdp x1 x2, noperc (running rego on estimation sample) type mismatch error in expression: e(shapley_perc) r(109);
0 Response to Rolling problems: get decomposed R2, also called Shapley value
Post a Comment