This function provides the user with a decomposition of the R-Squared of a linear regression by deriving the marginal contribution of each explanatory variable included in the specification. We employ the methodology proposed by Israeli, O. (2007) "A Shapley-based decomposition of the R-squared of a linear regression". The Journal of Economic Inequality, 5(2), 199-212. As explained by Israeli (2007), the methodology combines an inequality decomposition procedure with the concept of Shapley value from game theory. The procedure is as follows: the variance of the explained/dependent variable may be decomposed into the contributions of each explanatory/independent variables included in the specification, and that of the residual. It is therefore possible to express the marginal contribution of each variable as the difference of the R-Squared obtained with and without the inclusion of the variable in the regression. Nevertheless, given the multiplicity of explanatory variables in the specification, the marginal effect depends on the elimination order. To address this issue, the contribution is given by the average of all possible elimination sequences. *Inputs This function requires the following: 1) A list of the independent variables included in the specification. A constant term is assumed to be present in the specification. 2) A series of the dependent variable. Note: the user must be aware that the function will not work if the sample contains any missing values. *Output The function returns a vector which includes the marginal effects associated to each explanatory variable of the specification. *Example In order to obtain the marginal contribution to the R-Squared of an specification, we propose the following example. Let us suppose a linear regression between the money stock (M2) as a dependent variable and real GNP (rgnp), stock prices (pstock) and the interest rate (interest) as independent variables, based on Nelson and Plosser's database. open np.gdt smpl 1909 1970 list x=rgnp pstock interest Shapley(x,money) The function then returns the following: R-Squared of linear regression: r2 = 0.98439265 Marginal contribution of each independent variable to the R-Squared of a linear regression: C (3 x 1) 0.52053 0.42413 0.039731 which may be interpreted as the contribution of each independent variable to the goodness of fit of the model explaining money stock. That is, from the 0.98 R-Squared obtained in the regression, 0.52 is due to the individual contribution of real GNP, 0.42 is due to the individual contribution of stock prices, and 0.04 is due to the interest rate. Update: The previous version (1.0) could not be generalized when more than two explanatory variables were included in the model. In this new version we updated the Shapley weights for each explanatory variable in order for the function to adequately assign the marginal contribution of the R-squared to the explanatory variables. The decomposition procedure (and proof) can be found in Shorrocks, A.F. (2013) "Decomposition procedures for distributional analysis: a unified framework based on the Shapley value". The Journal of Economic Inequality, 11 (1), 99-126. We would like to thank Patrick Galloway for making us aware the previous version was defective.