# An Improved Confounding Effect Model for Software Defect Prediction
## 3 Confounding Effect Model for Software Defect Prediction
### Data Analysis Method  
A simple and parsimonious approach is as follows: a measured confounding variable can be controlled through a regression adjustment [45]. A regression adjustment entails including the confounder as another independent variable in a regression model. Suppose the regression coefficient of the metric changes dramatically with and without the size variable. In that case, this strongly indicates that there was indeed a confounding effect [46]. This is further elaborated below. The regression method used in this paper is logistic regression.  
The general form of logistic regression(LR) is  
\[p=\frac{1}{1+e^{-(b+a_{1}X_{1}+\cdots+a_{n}X_{n})}} \tag{1}\]  
where \(p\) represents the probability that a software module contains at least one potential defect, and \(X_{i}\) are independent variables, which represent the software metrics. The parameters are estimated through the maximization of a log-likelihood [46].  
Since the value of the confounding variable is unknown, we first quantified its confounding effect using half-sibling regression [19]. Half-sibling regression is a model used to quantify unobserved confounding noise under causal inference, which can incorporate causal beliefs and assumptions of empirical targets. Both the confounding variable and software metrics are considered responsible for software defects under causal belief. Therefore, the confounding effect can be reconstructed. We replace the value of the confounder with a confounding effect. When we utilize software metrics for defect prediction, the discrepancy between the predicted probability and the actual value is considered to be caused by the unknown confounding variable. The model assumes that the prediction noise is additive. Therefore, the following formula for variable C is obtained:  
\[c=d-\frac{1}{1+e^{-(b+a_{1}X_{1}+\cdots+a_{n}X_{n})}} \tag{2}\]  
Figure 2: An improved confounding effect model.  
We establish univariate and bivariate logistic regression, corresponding to uncontrolled and controlled variable c, respectively. The effect of the confounding variable is analyzed by analyzing the change of the \(X_{1}\) coefficients of the two models:  
\[p_{1}=\frac{1}{1+e^{-(b+a_{1}X_{1})}} \tag{3}\]  
\[p_{2}=\frac{1}{1+e^{-(b+a_{1}X_{1}+a_{2}C)}} \tag{4}\]  
The odds ratio, as shown in the Formula (5), is the ratio of the probability that an event will happen (signed by \(p\)) to the probability that an event will not happen (signed by \(q\)). The extent of the confounding can be expressed by the change in the odds ratio when the X1 variable changes by one standard deviation(\(\varphi(X_{1}+\sigma)\)), denoted by \(\Delta\varphi\) in Formula (7). Since we construct two models, as shown in Formula (3) and Formula (4), which are with and without control for the confounder, we denote the change in odds ratio as \(\Delta\varphi_{1}\) and \(\Delta\varphi_{2}\), respectively. As suggested in [47], we can evaluate the extent to which the change in odds ratio (shown as Formula (8)) changes as an indication of the extent of confounding. We operationalize this as follows:  
\[\frac{p}{q}=\varphi(X)=e^{b+aX} \tag{5}\]  
\[\varphi(X+\sigma)=e^{b+a(X+\sigma)} \tag{6}\]  
\[\Delta\varphi=\frac{\varphi(X+\sigma)}{\varphi(X)}=e^{a\sigma} \tag{7}\]  
\[\Delta^{2}\varphi=|\frac{\Delta\varphi_{1}-\Delta\varphi_{2}}{\Delta\varphi_{ 2}}|*100\% \tag{8}\]