I found an outlier using the outlierTest function in the car package. However, I can see from the results that the Externally Studentized Residual and p-values. This is a result for the full model.
rstudent unadjusted p-value Bonferroni p
348 5.872682 7.9377e-09 3.9689e-06
Cooks D Bar Plot:
After using removing the outlier I have used the ols_step_both_aic fromperformed normality test on residuals using the olsrr library and decidedfollowing code:
shapiro.test(resid(housing.lm))
R Console:
Shapiro-Wilk normality test
data: resid(housing.lm)
W = 0.97068, p-value = 1.876e-08
The p-value is less than 0.05 indicating that 2 predictors are significant whichthe residuals may not be normally distributed. However, I assume it is not critical for linear regression as long as the other assumptions are bath and sqftmet.
I have also performed heteroscedasticity test using the following code:
ncvTest(housing.lm)
R console:
Non-constant Variance Score Test
Variance formula: ~ fitted.values
Chisquare = 0.3243994, Df = 1, p = 0.56898
When I fit the regression using the coded:
lm(price~ bath + sqft, data=without_outlierdata=data)
Summary: My diagnostic plots looks as follows;
Although after removing the outlier sqft is not a significant predictor anymore. Did I make a wrong decision removing the outlier? If so why?
Summary withWhen try to remove observation 348 based on the outlier:p-value sqft variable becomes insignificant.
The diagnostic graphics from the chosen model look as follows:Is it better to keep it since it seems an influential point?