| X | Min. : 0 | 1st Qu.: 6388 | Median :12180 | Mean :12145 | 3rd Qu.:17972 | Max. :23763 | NA’s :597 |
| address | Length:23764 | Class :character | Mode :character | NA | NA | NA | NA |
| city | Length:23764 | Class :character | Mode :character | NA | NA | NA | NA |
| floor | Min. : 0.0 | 1st Qu.: 1.0 | Median : 2.0 | Mean : 2.8 | 3rd Qu.: 4.0 | Max. :10.0 | NA’s :596 |
| id | Min. : 1 | 1st Qu.: 8425 | Median :15636 | Mean :15621 | 3rd Qu.:23111 | Max. :30308 | NA’s :596 |
| latitude | Min. :49.9 | 1st Qu.:50.1 | Median :52.2 | Mean :51.4 | 3rd Qu.:52.3 | Max. :54.4 | NA’s :596 |
| longitude | Min. : 4.2 | 1st Qu.:19.9 | Median :20.0 | Mean :19.9 | 3rd Qu.:21.0 | Max. :30.3 | NA’s :596 |
| price | Min. : 5000 | 1st Qu.: 411943 | Median : 521948 | Mean : 649774 | 3rd Qu.: 699999 | Max. :15000000 | NA’s :596 |
| rooms | Min. : 1.0 | 1st Qu.: 2.0 | Median : 3.0 | Mean : 2.6 | 3rd Qu.: 3.0 | Max. :10.0 | NA’s :596 |
| sq | Min. : 9 | 1st Qu.: 42 | Median : 54 | Mean : 104 | 3rd Qu.: 69 | Max. :1007185 | NA’s :596 |
| year | Min. : 70 | 1st Qu.:1985 | Median :2019 | Mean :2000 | 3rd Qu.:2021 | Max. :2980 | NA’s :596 |
The summary of statistics show the minimum value, 1st quartile, median, 3rd quartile, mean, and maximum value.
The statistical report focuses on the house prices in Poland and the association between features of the homes The dependent variables in the report focus on location(Krakow, Warszawa, and Pozna), interior of house(floors,rooms,square meters), the year the house was built, and the house id number.
Address : The Full house Address
City: The city the house is located, Krakow, Warszawa, or Pozna
id: The house id is the number order the house was built
price: The price the house was sold for
sq: The square meters of the house
year: year the house was built
floor: The number of floors in the house
room: The number of rooms in the house
longitude: Longitude of house location
latitude: latitude of house location
The purpose of the analysis is to see the association between the price of houses in Poland with the predictor variables, the different characteristics of the house. The report will also look at the difference of results using the full model and and reduced model.
To obtain the results of the analysis the following will be used:
Residual Analysis of the original model to check if the assumptions of the residuals are met using the initial model.
A check for Multicollinearity
A Box-Cox transformation on both response and predictor and a Residual Analysis on the transformed model
The removal of influential points and a Residual Analysis on the model
A step wise regressions to find the best model and a Bootstrap analysis to show histogram density curves of each predictor and their confidence intervals
A Bootstrap analysis on the residuals to find the histogram density curves of each predictor and their confidence interval
A final model will be created to show the best coefficient for the predictors and the significance level for each predictor
The data set contains 23764 observations with 10 dependent variable, and one independent variable, Price.
The plot shows that there are 3 main spots houses were sold. There is a large majority in the first quadrant at (20,50) and in the second quadrant at (22,52). There is also a large group in the third quadrant at (18,52.5).
The initial linear model has 6 predictor variables.
The linear model is: Price=β0+β1∗Longitude+β2∗Latitude+β3∗sq+β4∗floors+β5∗rooms+β6∗years +β7∗id+ϵ
We begin by finding the initial linear model to find the coefficients.
| Estimate | Std. Error | t value | Pr(>|t|) | |
|---|---|---|---|---|
| (Intercept) | 489000.70 | 126841.90 | 3.86 | 0.00 |
| sq | -0.08 | 0.47 | -0.16 | 0.87 |
| rooms | 244215.27 | 3093.18 | 78.95 | 0.00 |
| floor | 26626.10 | 1249.95 | 21.30 | 0.00 |
| id | 1.28 | 0.36 | 3.57 | 0.00 |
| year | -286.94 | 63.39 | -4.53 | 0.00 |
Using the given coefficients we find the linear model to be:
Price = 489000.70 -.08sq + 244215.27rooms + 26626.10floors + 1.28id - 286.94*year + ϵ
4 plots are used to check for possible violations of residuals these include: The model not having a normal distributed, Q-Q plot The linearity of the residuals, Residuals vs Fitted Constant variance, Scale-location Influential points, Residuals vs Leverage
The residual analysis plots show many important findings:
Q-Q plot: Shows there is a normal distribution
Residuals vs Fitted: Shows there is linearity in the variables
Scale-Location: shows there is a non-constant variance
Residual vs Leverage: shows there is an influential point ar 6199
VIF detects any issues of multicollinearity.
FALSE sq rooms floor id year
FALSE 1.000 1.002 1.001 1.002 1.003
The model shows that there are no issues with multicollinearity as
all of the VIF values are 1.
The Box-cox transformation is used on both response and predictor variables which allow to build regression models.
The Box-Cox transformations allow lambda when applies to the predictor
variables help stabilize the variance for a linear model. The Box-cox
transformation shows that an effective lambda = .11 can be used to
transform the model. The Log year lambda does a very good job at
stabilizing the variance as the plot shows almost a fully linear model.
For year lambda does not do as good when stabilizing the variance as the
plot still shows a log function.
| Estimate | Std. Error | t value | Pr(>|t|) | |
|---|---|---|---|---|
| (Intercept) | 4.20 | 0.05 | 82.98 | 0.00 |
| sq | 0.00 | 0.00 | -0.03 | 0.98 |
| year | 0.00 | 0.00 | -6.52 | 0.00 |
| floor | 0.01 | 0.00 | 23.13 | 0.00 |
| rooms | 0.14 | 0.00 | 114.30 | 0.00 |
| id | 0.00 | 0.00 | 11.62 | 0.00 |
The Box-Cox
transformation shows that many of the residual analysis assumptions are
met:
Q-Q plot: Shows a normal distribution
Residuals vs Fitted: Shows there is not linearity in the variables
Scale-Location: shows there is a constant variance
Residual vs Leverage: shows there is an influential point at 6199
It is important to remove the influential points because they have a large impact on the regression of the model.
| Estimate | Std. Error | t value | Pr(>|t|) | |
|---|---|---|---|---|
| (Intercept) | 4.19 | 0.05 | 83.75 | 0 |
| sq | 0.00 | 0.00 | 21.72 | 0 |
| year | 0.00 | 0.00 | -6.54 | 0 |
| floor | 0.01 | 0.00 | 23.40 | 0 |
| rooms | 0.13 | 0.00 | 105.51 | 0 |
| id | 0.00 | 0.00 | 12.05 | 0 |
By removing the influential point the residuals look much worse using
Box-Cox transformation.
Q-Q plot: Shows a normal distribution
Residuals vs Fitted: Shows there is linearity in the variables
Scale-Location: shows there is a non-constant variance
Residual vs Leverage: shows there are two new influential points at 18638 and 10799
Step wise regression is used to remove and add predictors to find the best variables in the data set to create the best preforming model
FALSE Start: AIC=-78109
FALSE (price)^0.11 ~ sq + year + floor + rooms + id
FALSE
FALSE Df Sum of Sq RSS AIC
FALSE <none> 795 -78109
FALSE - year 1 1 797 -78068
FALSE - id 1 5 800 -77966
FALSE - sq 1 16 811 -77644
FALSE - floor 1 19 814 -77570
FALSE - rooms 1 382 1177 -69018
FALSE
FALSE Call:
FALSE lm(formula = (price)^0.11 ~ sq + year + floor + rooms + id, data = IVI)
FALSE
FALSE Residuals:
FALSE Min 1Q Median 3Q Max
FALSE -2.9886 -0.1185 -0.0292 0.0895 1.4750
FALSE
FALSE Coefficients:
FALSE Estimate Std. Error t value Pr(>|t|)
FALSE (Intercept) 4.19e+00 5.01e-02 83.75 < 2e-16 ***
FALSE sq 3.27e-04 1.51e-05 21.72 < 2e-16 ***
FALSE year -1.64e-04 2.50e-05 -6.54 6.4e-11 ***
FALSE floor 1.15e-02 4.93e-04 23.40 < 2e-16 ***
FALSE rooms 1.34e-01 1.27e-03 105.51 < 2e-16 ***
FALSE id 1.70e-06 1.41e-07 12.05 < 2e-16 ***
FALSE ---
FALSE Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
FALSE
FALSE Residual standard error: 0.185 on 23161 degrees of freedom
FALSE (596 observations deleted due to missingness)
FALSE Multiple R-squared: 0.384, Adjusted R-squared: 0.384
FALSE F-statistic: 2.89e+03 on 5 and 23161 DF, p-value: <2e-16
The Stepwise regression results show that by finding the lowest AIC-value = 78109, the best model is
Price = 4.19e+00 + 1.34e-01rooms + 1.15e-02floor + 1.70e-06id - 1.64e-04year + 3.27e-04*sq + ϵ
| Estimate | Std. Error | t value | Pr(>|t|) | |
|---|---|---|---|---|
| (Intercept) | 479611.541 | 1.255e+05 | 3.823 | 1e-04 |
| sq | 857.770 | 3.775e+01 | 22.720 | 0e+00 |
| floor | 26665.844 | 1.236e+03 | 21.570 | 0e+00 |
| rooms | 225016.696 | 3.174e+03 | 70.897 | 0e+00 |
| id | 1.397 | 3.544e-01 | 3.942 | 1e-04 |
| year | -283.961 | 6.270e+01 | -4.529 | 0e+00 |
Using the hist() function we create 5 histograms, one for each predictor and the intercept. Each histogram has two density curves on them. The red density curve estimates regression coefficients and the corresponding standard error of regression. The blue curve is a non-parametric-data-driven estimate of density using the bootstrap distribution.
Intercept: The intercept histogram shows that both density curves follow the same normal distribution as the histogram and are almost identical curves.
Year: The year histogram is skewed to the right and so is the non-parametric density curve. The non-parametric curve is almost identical to the distribution of the histogram. However the regression curve starts much lower, closer to 0, and ends in the same spot as the histogram and non-parametric curve.
Square meter: The Square meter histogram shows that both density curves follow the same normal distribution as the histogram and are almost identical curves.
Rooms: The rooms histogram is skewed to the left and the non-parametric density curve follows the same skewed distribution. The regression curve starts much lower on the histogram and ends at the same spot as the non-parametric curve.
Floor: The Floor histogram shows that both density curves follow the same normal distribution as the histogram and are almost identical curves.
Bootstrap confidence intervals are used to make assumption. Bootstrap is used when parametric assumptions can not be made for a distribution.
| Estimate | Std. Error | t value | Pr(>|t|) | btr.ci.95 | |
|---|---|---|---|---|---|
| (Intercept) | 479611.5414 | 125454.5693 | 3.8230 | 0.0001 | [ 12.6282 , 13.5209 ] |
| sq | 857.7696 | 37.7542 | 22.7198 | 0.0000 | [ 2e-04 , 0.0139 ] |
| floor | 26665.8441 | 1236.2754 | 21.5695 | 0.0000 | [ 0.0202 , 0.0259 ] |
| rooms | 225016.6964 | 3173.8472 | 70.8971 | 0.0000 | [ -0.0156 , 0.2895 ] |
| id | 1.3969 | 0.3544 | 3.9416 | 0.0001 | [ 0 , 0 ] |
| year | -283.9605 | 62.6992 | -4.5289 | 0.0000 | [ -6e-04 , -2e-04 ] |
The results of the regression coefficient matrix show that id is not statistically significant. Id has a 95% CI, [0,0]. Since the variable id has a zero within the confidence interval it shows insignificance at alpha = 0.05. However floor, rooms,sq, and year are statistically significant as 0 is not in their confidence interval.
The Histogram of Residuals shows that the data is skewed right and is
centered around 0. The 95% CI verifies that the histogram should be
mainly around 0 as the all of the confidence intervals are close to
0.
Using the hist() function we create 5 histograms, one for each predictor and the intercept. Each histogram has two density curves on them. The red density curve estimates regression coefficients and the corresponding standard error of regression. The blue curve is a non-parametric-data-driven estimate of density using the bootstrap distribution.
Intercept: The intercept histogram shows that both density curves follow the same normal distribution as the histogram and are almost identical curves. The red curve however goes a little farther to the right and is slightly taller then the blue curve.
Year: The year histogram is skewed to the right and so is the non-parametric density curve. The non-parametric curve is almost identical to the distribution of the histogram. However the regression curve starts much lower, closer to 0, and ends in the same spot as the histogram and non-parametric curve.
Square meter: The Square meter histogram shows that both density curves follow the same normal distribution as the histogram and are almost identical curves. The red curve is a little taller than the blue curve and stops before the blue curve does.
Rooms: The rooms histogram is skewed to the left and the non-parametric density curve follows the same skewed distribution. The regression curve starts much lower on the histogram and ends at the same spot as the non-parametric curve.
Floor: The Floor histogram shows that both density curves follow the same normal distribution as the histogram and are almost identical curves. The red curve is taller than the blue curve. The red curve also peaks at the top of the histogram whereas the blue peaks to the left side of the histogram.
| Estimate | Std. Error | t value | Pr(>|t|) | btr.ci.95 | |
|---|---|---|---|---|---|
| (Intercept) | 479611.5414 | 125454.5693 | 3.8230 | 0.0001 | [ 479611.5414 , 479611.5414 ] |
| sq | 857.7696 | 37.7542 | 22.7198 | 0.0000 | [ 26665.8441 , 26665.8441 ] |
| floor | 26665.8441 | 1236.2754 | 21.5695 | 0.0000 | [ 857.7696 , 857.7696 ] |
| rooms | 225016.6964 | 3173.8472 | 70.8971 | 0.0000 | [ 225016.6964 , 225016.6964 ] |
| id | 1.3969 | 0.3544 | 3.9416 | 0.0001 | [ 1.3969 , 1.3969 ] |
| year | -283.9605 | 62.6992 | -4.5289 | 0.0000 | [ -283.9605 , -283.9605 ] |
The results of the regression coefficient matrix bootstrap show that each of the variables is statistically significant at the 95% CI. We conclude this finding by seeing that none of the confidence intervals have 0 in them.
| btc.wd | btr.wd |
|---|---|
| 0.8927 | 0 |
| 0.0136 | 0 |
| 0.0057 | 0 |
| 0.3051 | 0 |
| 0.0000 | 0 |
| 0.0004 | 0 |
| Estimate | Std. Error | t value | Pr(>|t|) | |
|---|---|---|---|---|
| (Intercept) | 479611.541 | 1.255e+05 | 3.823 | 1e-04 |
| sq | 857.770 | 3.775e+01 | 22.720 | 0e+00 |
| floor | 26665.844 | 1.236e+03 | 21.570 | 0e+00 |
| rooms | 225016.696 | 3.174e+03 | 70.897 | 0e+00 |
| id | 1.397 | 3.544e-01 | 3.942 | 1e-04 |
| year | -283.961 | 6.270e+01 | -4.529 | 0e+00 |
The final model verifies our findings that each variable is statistically significant as each p-value < .001.
The final model is:
Price = 479611.541 + 857.770sq + 225016.696rooms + 26665.844floors + 1.397id - 283.961*year + ϵ
The final model shows that as one predictor increases, all other predictors stay the same, the price of the house will increase/decrease by the amount of the coefficient.
Example: when we change the the id by one degree price of the house will increase by 1.397, all other predictors will stay the same.
The completion of the project allows for many conclusions to be made. The residual Analysis assumptions were shown to have many violations in the initial model.
Using the box-cox transformation to check residual assumptions allowed for many of the assumptions to be verified. The assumptions of normal distribution, linearity, and constant variance were all verified to be true. However there is an influential point at 6199.
When removing the influential point and running a regression analysis the results are alarming. There is no constant variance or linearity and there is a normal distribution with outliers. The removal of the influential point creates two new point at 18638 and 10799. By removing the influential point the model does worse and shows that the point did not affect the model a significant amount.
The final model verifies there is multicolinearity by having large coefficients instead of small ones.
The report shows that each of the predictors have a strong affect on the House price in Poland. However there is a very low R^2 value at R^2= 0.384. The low power value shows that model is not a good predictor.
The bootstrap method used that included the multicollinearity had a substantial difference from the one without. In the first bootstrap ID has a 95% CI [0,0]. Showing that ID is not statistically significant. When multicollinearity is removed and the bootstrap is run again each variable is statistically significant to the model.
In conclusion the final model shows that each of the predictors are statistically significant to the model and each of them has an association with price. Although each predictor is associated with price a logarithmic transformation was not needed
Using houses that were more spread apart within each region would allow for broader assumption to be made about all of the cities. This would be extremely useful as the data set has a majority of all data points in three spots.
The model although it is useful should be used carefully. The different methods used to create the model have shown violations within assumptions. Although the violations have been decreased by using bootstrapping and logarithmic transformation there can still be major impacts on the model results.
Cegielski, D. (2021, March 4). House prices in Poland. Kaggle. https://www.kaggle.com/datasets/dawidcegielski/house-prices-in-poland/data