# A Proposal for a New Python Library Implementing Stepwise Procedure
## 4 Case Study
diagnosis was performed using the statistics Variance Inflation Factor (VIF) and Tolerance, according to Figure 6.  
Although no cutoff point is established in the literature to define whether or not there is multicollinearity between explanatory variables, it is necessary to observe VIF values greater than ten. In this sense, the variables 'area' and 'land_area' present VIF values  
Figure 4: Distribution of the metric variables. Figure 5: MLR model. Figure 6: Variance Inflation Factor and Tolerance. close to 4000, with Tolerance practically equal to 0, representing a practically maximum \(R^{2}\), representing a preliminary indication of multicollinearity in the proposed model. To confirm the multicollinearity and establish the set of statistically significant variables, we arrive at the main contribution of this work: the implementation of the stepwise procedure based on the statistical significance of the variables as a function of the Python programming language. To apply stepwise through the function proposed in this paper, run the following command:  
\[\text{from stats tests.process import stepwise}\]  
\[\text{model\_step\_apartments}=\text{ stepwise(model\_apartments, pvalue\_limit}=0.05)\]  
where'model_apartments' is the MLR model in Figure 5;'model_step_apartments' is the MLR model obtained after the stepwise procedure; 'pvalue_limit' refers to the level of statistical significance (in this case, equal to 0.05). Figure 7 shows the new model obtained after applying the stepwise. According to the preliminary analysis by \(VIF\) and _Tolerance_ statistics, the variables 'area' and 'land_area' present multicollinearity, being excluded from the multiple regression model after the stepwise procedure, leaving only the variables 'rooms' and 'neighborhood' (with two categories, since 'Brooklyn' was the reference category). The following analysis consists of the verification of adherence of the residues to normality using the Shapiro-Francia test, implemented by the 'Shapiro-Francia' function of the'statstests.tests' package, also presented in this article, according to the commands below:  
Figure 5.0  
Figure 5.1  
where'model_step_apartments' is the MLR model after performing the stepwise procedure. The Shapiro-Francia test is shown in Figure 5.2 As a result, a \(p\)-value of 0.00002 was obtained, lower than the established significance level of 0.05. Therefore, we rejected the hypothesis, which means there is no adherence to the normality of the residues of the analyzed model. Figure 5.3 New model (‘model_step_apartments’) obtained after applying the stepwise. method : Shapiro-Francia normality test statistics W : 0.9428879585951422 statistics z : 4.610630444107969 p-value : 2.0072482113803717e-06 Statistics W=0.94289, p-value=0.000002  
As a result of nonadherence to normality, another essential analysis is the diagnosis of heteroskedasticity using the Breusch-Pagan test. It is possible to see the result of which in Figure 5.4 The \(p\)-value was approximately \(6.41\times 10^{-15}\), lower than the significance level of 0.05. Thus, there is heteroskedasticity in the data, which means that there is correlation between the residues and one or more explanatory variables. In short, relevant variables are omitted from the model. Considering that the residues of the model in question are not adherent to normality and the data present heteroskedasticity, a solution is the Box-Cox transformation in the dependent variable 'price', aiming to maximize the adherence of variable \(Y\) to normality. Figure 10 shows the \(p\)-values of the model variables after applying the Box-Cox transformation. Considering the level of statistical significance of 5%, as in the previous model, we verified that the variables 'area' and 'land_area' were not statistically significant in the presence of the other variables. In addition, there is an increase in \(R^{2}\) to 0.893.