The In-Depth Guide to Interpretability Analysis in Linear Regression

Posted by : 10 min read.

Category : Machine-Learning


Contents

Code used in the blog can be accessed on GitHub

Introduction

Ever wondered what’s the effect of the addition of an extra predictor variable to a linear regression model ? Can we separate the individual influences of each predictor on the target variable ? If we can do that, we can determine what features are important the most and invest more in collecting those features more accurately. Such an analysis also helps to explain the outcomes of the model and helps us to make costly decisions based on the model. This kind of analysis is particularly useful in the finance industry, medical industry where we can’t afford to make decisions based on a model which we couldn’t interpret. In the previous post Everything You Need To Know About Interpretability in Linear Regression: Net Effects we saw an interpretability technique called Net Effects, and in this post, we will see how we can define a more robust Incremental Net Effects which has a very nice intuitive explanation from cooperative game theory (reserved for another post) and more interpretable than the traditional net effects.

If you have read the previous blog post Everything You Need To Know About Interpretability in Linear Regression: Net Effects, then feel free to skip Setting Pre-requisites right section. That post covers the prerequisites in detail.

Setting Pre-requisites right

Consider a standard regression model defined as follows,

We are given a dataset $\mathcal{D} = \{X, y\}$, where we are given $N$ data points $(X \in \mathbb{R}^{N \times n}, y \in \mathbb{R}^N)$. We are required to fit a straight line on this dataset such that we minimize the mean squared error .

This optimization problem has a closed-form solution and it can be represented as a solution to the set of linear equations expressed in matrix form . We are skipping the derivation of this formula as its straightforward.

where is the matrix of correlations (between features ), is a vector of correlations of with each feature variable. is the vector of regression coefficients. Solving this linear system, we get the solution,

where is the inverse correlation matrix. The square deviation can be represented in matrix form as,

Revisiting R-squared for Regression Analysis ()

Regression fit quality can be quantified by coefficient of multiple determination which is a bounded metric from $[0,1]$. It represents the relative decrease in squared error obtained when we consider fit model as opposed to a simple constant model (i.e) a model which predicts a constant value irrespective of the input $x \in \mathbb{R}^n$. It also conveys how the inclusion of the feature variables $x$ helps in reduction of $S^2$.

A very important decomposition of $R^2$ which formed the foundation of net effects,

is called the net effect of the predictor (). Net effect of a predictor is the total influence that predictor has on the target, considering both its direct effect and indirect effect (via correlation with other predictors).

Consider an example of 10 predictors on a synthetically created linear dataset with Gaussian noise. We calculate the net effect of each predictor in the below plot.

Problems caused by Multicollinearity

Multicollinearity arrises when the feature variables (predictor variables) are highly correlated among themselves. In that case, then he estimated standard deviation of predictor variables become large (quantified by Variance Inflation Factor). This also affects the interpretability measures, as now with correlated variables, it will be difficult to unmask the separate influences of each variable. Since the interpretability is under question now, the statistical significance of the predictor variables is also inaccurate.

Multicollinearity can change the sign of to opposite to that of the pairwise correlation , which means . This is counter-intuitive because say for example $r_{yj} > 0$, which means positively correlated and $a_j < 0$, then from the model we can say that $y$ decreases by $a_j$ units for every unit increase in $x_j$. But the correlation paints a completely different picture as it says $x_j$ and $y$ are increasing together. This is what we mean by saying inaccuracies in statistical significance as now $NEF_j$ are no longer accurate descriptions of the predictor’s influence on $y$.

The same dataset but the input features are correlated. Notice how the NEF values are negative for some predictors which are supposed to mean that they contribute negatively to $R^2$. We need a more sophisticated method to explain these observations as we will see in the next section.

Incremental Influence of Predictors in Multiple Determination

Objective: In order to better understand the predictor’s influence on the regression model, we now use the incremental approach (i,e) try to whats the marginal gain/loss in terms of performance does the inclusion of additional variable has on the multiple regression model.

Lets now aim to calculate the influence of (the last standardized variable) in the standardized regression model. The matrix (correlation matrix of all ’s) can be written in a block form,

where matrix of correlation of among themselves and is the correlation of with . Using the result from block matrix inversion, we get

where,

Anything similar you can see with in and in ? Indeed! So is the vector of regression coefficients when is regressed for, from other variables . Following the notations from , is the least squares solution for

Similarly, observing in and noticing that it has similar similar to in (). So we denote as (i.e) the multiple determination coefficient for model . in can be written as,

Using in for obtaining the solution for ,

where a vector of all correlations between and . is the first correlations in and is the correlation between and (last element in ).

In , is the solution for the model, (multiple regression model with predictor variables ),

so we continue with the same notation in , taking inspiration from , we get

The interpretation of this model, is that without how other features influence the predictor variables. Now to understand the incremental gains obtained by including in regression analysis, we try to write of model in terms of of model as defined in + some entity depending on .

Calculating of the model using ( defined in ),

Now, what is (i.e) the of model ? We can use the expressions (), and write it as,

Applying in , (and substituting from )

We see that addition of is clearly beneficial as it increases the by a non-negative amount.

Incremental Net Effect

From our analysis, it’s clear that addition of extra variables contributes in a non-negative way to . Now in just a few steps, a new interesting result emerges, that is incremental net effect of a predictor.

Continuing our analysis, from the last row of , we get

Substituting , in ,

Interpretation of the equation: of model can be decomposed to the sum of of variables and the incremental value which depends on

  • the coefficient of the nth predictor
  • where is the multiple determination in model . As from , this term actually is the least squares error for model .

Without loss of generality, assuming any predictor instead of , we can write

The incremental gain in due to addition of predictor is given by which is a measure of the usefulness of the predictor .

Averaging for all n expressions, to combine all the marginal contributions from each predictor, we arrive at,

In the above equation, collecting all the terms related to predictor $j$, we arrive at $INEF_j$. aka incremental net effect for predictor $j$. Note that incremental net effects are always positive, irrespective of whether influences of collinearity is present or not, unlike in the case of net effects defined in which can be negative under correlated settings.

Ok, lets now jump into an example and understand the calculation of incremental net effects.

A Simple Example

Lets take a simplifying 2 predictor example, $y = a_1x_1 + a_2x_2$, then the becomes

when solved leads us to this solution,

Now coefficient of multiple determination can be computed using $\eqref{r2_decomp}$,

Before we finish closing the example by calculating the incremental net effect for each predictor, lets better appreciate why the traditional net effect is inadequate with this example. Assume $r_{y2}=0$, what will happen to the net effects computed in $\eqref{2pred_r2}$?

So is the above equation trying to convey that addition of predictor 2, is not contributing anything to $R^2$? But we have seen in $\eqref{inc_r2}$ that addition of a new predictor always increases $R^2$ determined by $U_j$. So this is another reason to learn incremental net effects as they are always positive and sum up to $R^2$ giving a nice interpretable notion to them.

Getting back to calculating $INEF_1, INEF_2$, using $\eqref{inef_r2}$ in our 2 predictor case,

Now lets consider the same assumption of $r_{y2}=0$ and analyse what happens,

and its clear to see that both $INEF_1, INEF_2$ are positive despite $r_{y2} = 0$. This captures the contribution of each predictor in a more accurate sense than the traditional net effects.

Notice in the below plot, how effectively incremental net effects distribute the influences of the predictors in a more interpretable way, even when the correlation is present and NEF values are negative.

Using , and then collecting every element related to each predictor to compute the INEFs for each predictor might be cumbersome. We can do this type of analysis for 2 predictors or maybe till 3 predictors. So to get an intuitive explanation for incremental net effects, we take help of cooperative game theory. Consider the setting of the linear regression as a game and the players are the predictors. The total reward obtained by the players is $R^2$. Now the problem is How can the total reward obtained by a coalition of all the players (predictors) be distributed among the individual players? That’s reserved for another post, the final post in the series Interpretability in Linear Regression.

The code used in the creation of the plots and values is here. In the implementation of incremental net effects, I have used the cooperative game theory interpretation of incremental net effects to compute their values.

About

Data Science Enthusiast

Star
Categories
Useful Links