Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Negative Shapley decomposed R2 and a sum that is not equal to to 100% ?

    Dear all
    I am running a shapley R2 decomposition to see the relative contribution of each independent variable towards the adjusted R2 of the model. I use the user-written program shapley2


    I run the regression for different portfolios based on a certain variable:
    For portfolio 1:

    reg f.ibaW ceW neg_siW bvW if portfolio==1
    shapley2, stat(r2_a)



    . reg f.ibaW x1 x2 x3 if portfolio==1

    Source | SS df MS Number of obs = 3761
    ---------------------------------------------------------------------- F( 3, 3757) = 1484.23
    Model | 1143.67823 3 381.226076 Prob > F = 0.0000
    Residual | 964.990223 3757 .25685127 R-squared = 0.5424
    -------------------------------------------------------------------- Adj R-squared = 0.5420
    Total | 2108.66845 3760 .560816077 Root MSE = .5068

    ------------------------------------------------------------------------------
    F.ibaW | Coef. Std. Err. t P>|t| [95% Conf. Interval]
    --------------------------------------------------------------------------------------------
    x1 | .7788812 .0179106 43.49 0.000 .7437658 .8139967
    x2 | .2202045 .0435674 5.05 0.000 .1347866 .3056225
    x3 | -.0506716 .0055861 -9.07 0.000 -.0616236 -.0397196
    _cons | -.027272 .0112673 -2.42 0.016 -.0493626 -.0051814



    . shapley2, stat(r2_a)
    Factor | Shapley value | Per cent
    | (estimate) | (estimate)
    -----------------------------------------
    x1 | 0.39360 | 72.62 % |
    x2 | 0.05989 | 11.05 % |
    x3 | 0.13253 | 24.45 % |
    ------------------------------------------
    TOTAL | 0.54200 | 100.00 %
    --------------------------------------------



    These results make sense But still the decomposed R2 do not sum to 100%

    Even worse here:

    When I run for portfolio 3:

    reg f.ibaW x1 x2 x3 if portfolio==3

    Source | SS df MS Number of obs = 4422
    ------------------------------------------------------------------------------------ F( 3, 4418) = 58.62
    Model | 4.66770377 3 1.55590126 Prob > F = 0.0000
    Residual | 117.256773 4418 .026540691 R-squared = 0.0383
    --------------------------------------------- Adj R-squared = 0.0376
    Total | 121.924476 4421 .027578484 Root MSE = .16291

    ------------------------------------------------------------------------------
    F.ibaW | Coef. Std. Err. t P>|t| [95% Conf. Interval]
    -------------------------------------------------------------------------------
    x1 | .2229972 .024144 9.24 0.000 .1756628 .2703315
    x2 | .2084894 .0255087 8.17 0.000 .1584796 .2584992
    x3 | .0007467 .0039617 0.19 0.851 -.0070201 .0085136
    _cons | .0037299 .0040387 0.92 0.356 -.0041879 .0116478
    ------------------------------------------------------------------------------

    . shapley2, stat(r2_a)
    Factor | Shapley value | Per cent
    | (estimate) | (estimate)
    -------------------------------------------------
    x1 | 0.11232 | 298.49 % |
    x2 | -0.00040 | -1.06 % |
    x3 | 0.01027 | 27.30 % |
    --------------------------------------------------
    TOTAL | 0.03763 | 100.00 % |
    --------------------------------------------------



    Results do not add up to 100% and R2 for x1 is very high, while x2 R2 becomes negative ??

    Is there anything wrong with my code ? If not any interpretation for these results ?

  • #2
    Dear all,

    I am the author of 'shapely2'. The routine does not yet handle factor variables (generally an error message is given, but in the case of the dependent variable it seems that the error message is not provided).
    I will see whether the inclusion of factor variables is possible in the next release. In the meanwhile, please generate a variable 'gen dep=F.ibaW' and use this. Doing so, the problem should be solved. Alternatively you can use another routine computing the shapley value.

    I hope this helps,
    Kind regards,

    p.s. Please directly contact me for support if needed. You find my email in the help file.

    Comment

    Working...
    X