The basic idea of calculating the importance of attributes in a linear regression is according to the coefficients in the regression. However, when we put too many independent variables to regress, we can not promise that all those independent variables are independently distributed, commonly speaking. On other words, it may have great possibility that several attributes are collinearity, which also known as highly correlated. In an example context, we can easily remove the highly correlated attributes and then do the regression. However, in real world business cases, all the attributes we selected are important and meaningful, thus we can not remove the attributes which are highly correlated randomly. Therefore, we need to find out how to calculating the importance of attributes when several attributes are collinearity.
Shapley Value regression is also called Shapley regression, Shapley Value analysis, Kruskal analysis, and dominance analysis, and incremental R-squared analysis. Apart from using it while independent variables are moderately to highly correlated in linear regression, it also can be used when computing the contribution of each predictors in machine learning.
This package only has one function
shapleyvalue, and you can use it to analyze the relative importance of attributes in linear regression.
Here, we use the bulit-in dataset
Boston in package
MASS. In this demo,
medv as dependent variable,
dis as four predictors, and we want to find out the importance of each predictor.
<- Boston data head(data) %>% kbl() %>% kable_classic(full_width = F, html_font = "Cambria")
<- data$medv y <- as.data.frame(data[,5:8]) x <- shapleyvalue(y,x) value %>% value kbl() %>% kable_classic(full_width = F, html_font = "Cambria")
|Standardized Shapley Value||0.1488||0.7009||0.1020||0.0483|