# All-inclusive model
lm_pre_alpha <- lm(sold_price ~ . , data = data_factor_core)
summ(lm_pre_alpha)
MODEL INFO:
Observations: 24653 (19 missing obs. deleted)
Dependent Variable: sold_price
Type: OLS linear regression
MODEL FIT:
F(64,24588) = 40127.54, p = 0.00
R² = 0.99
Adj. R² = 0.99
Standard errors: OLS
-------------------------------------------------------------------------
Est. S.E. t val. p
----------------------------------- ----------- --------- -------- ------
(Intercept) -16871.45 9645.53 -1.75 0.08
property_typeDUP -1382.69 2916.00 -0.47 0.64
property_typeOTH -2350.66 2032.65 -1.16 0.25
property_typePAT -625.39 939.73 -0.67 0.51
property_typeSGL 1870.34 442.88 4.22 0.00
property_typeTNH 743.22 557.89 1.33 0.18
ac_typenone -192.06 386.13 -0.50 0.62
ac_typenot_central -1641.51 247.97 -6.62 0.00
list_price 0.98 0.00 926.47 0.00
patio1 827.42 128.03 6.46 0.00
school_general1 410.87 162.69 2.53 0.01
photo_count -50.96 7.61 -6.70 0.00
pool1 -53.01 212.04 -0.25 0.80
roof_typeother 1112.08 235.71 4.72 0.00
roof_typeshingle 1951.83 264.77 7.37 0.00
roof_typeslate 309.46 1122.51 0.28 0.78
gas_typenatural 4341.76 8665.75 0.50 0.62
gas_typenone 3266.70 8661.79 0.38 0.71
gas_typepropane -989.13 8865.14 -0.11 0.91
gas_typeunknown 2898.61 8660.78 0.33 0.74
out_building1 -476.10 138.84 -3.43 0.00
area_living -0.82 0.27 -3.00 0.00
land_acres -439.56 155.64 -2.82 0.00
appliances1 809.00 174.29 4.64 0.00
garage1 686.97 127.99 5.37 0.00
property_conditionnew -3579.80 777.97 -4.60 0.00
property_conditionother -360.63 170.57 -2.11 0.03
energy_efficient1 541.69 142.92 3.79 0.00
exterior_typemetal -256.77 406.79 -0.63 0.53
exterior_typeother -27.04 169.04 -0.16 0.87
exterior_typevinyl 341.55 187.98 1.82 0.07
exterior_typewood -569.41 265.66 -2.14 0.03
exterior_featurescourtyard 2438.79 1426.75 1.71 0.09
exterior_featuresfence 1260.66 608.56 2.07 0.04
exterior_featuresnone 1842.62 609.82 3.02 0.00
exterior_featuresporch 1421.76 623.46 2.28 0.02
exterior_featurestennis_court 639.16 1745.89 0.37 0.71
fireplace1 278.51 132.59 2.10 0.04
foundation_typeslab 818.74 191.73 4.27 0.00
foundation_typeunspecified -259.45 231.20 -1.12 0.26
area_total -0.22 0.16 -1.40 0.16
beds_total1 -582.56 3224.41 -0.18 0.86
beds_total2 -1004.92 3193.29 -0.31 0.75
beds_total3 -366.70 3196.71 -0.11 0.91
beds_total4 461.92 3202.80 0.14 0.89
beds_total5 -737.65 3256.64 -0.23 0.82
bath_full1 2733.18 3407.19 0.80 0.42
bath_full2 3218.26 3407.00 0.94 0.34
bath_full3 2735.63 3414.85 0.80 0.42
bath_full4 -681.33 3773.16 -0.18 0.86
bath_full6 -3477.19 9338.85 -0.37 0.71
bath_half1 -403.38 167.59 -2.41 0.02
bath_half2 -1313.94 1082.00 -1.21 0.22
bath_half3 1774.80 6123.62 0.29 0.77
bath_half4 7105.57 8664.90 0.82 0.41
bath_half5 -9208.75 5008.29 -1.84 0.07
age -38.26 3.77 -10.14 0.00
dom -15.79 0.97 -16.33 0.00
sold_date 0.40 0.06 6.28 0.00
sewer_typeseptic -301.06 239.41 -1.26 0.21
sewer_typeunspecified 253.41 130.72 1.94 0.05
property_stylenot_mobile 2165.93 357.54 6.06 0.00
subdivision1 343.75 152.92 2.25 0.02
water_typewell 391.73 603.56 0.65 0.52
waterfront1 -1569.32 226.14 -6.94 0.00
-------------------------------------------------------------------------
# pre_alphaing for heteroskedasticity
# a. Graphically
par(mfrow = c(2,2))
plot(lm_pre_alpha)
#autoplot(lm_pre_alpha)
# b. Statistically
ols_test_breusch_pagan(lm_pre_alpha) # Breusch-Pagan test
Breusch Pagan Test for Heteroskedasticity
-----------------------------------------
Ho: the variance is constant
Ha: the variance is not constant
Data
--------------------------------------
Response : sold_price
Variables: fitted values of sold_price
Test Summary
--------------------------------
DF = 1
Chi2 = 1160.0835
Prob > Chi2 = 2.886679e-254
# - Resolving Heteroskedasticity using heteroskedasticity-consistent (HC) variance covariance matrix
# Compare models
stargazer(lm_pre_alpha,
coeftest(lm_pre_alpha, vcov = vcovHC(lm_pre_alpha, method = "White2", type = "HC0")),
coeftest(lm_pre_alpha, vcov = vcovHC(lm_pre_alpha, method = "White2", type = "HC1")),
type = "text")
==========================================================================================
Dependent variable:
------------------------------------------------------------
sold_price
OLS coefficient
test
(1) (2) (3)
------------------------------------------------------------------------------------------
property_typeDUP -1,382.690 -1,382.690 -1,382.690
(2,916.004) (2,558.605) (2,561.985)
property_typeOTH -2,350.658 -2,350.658 -2,350.658
(2,032.645) (2,541.983) (2,545.341)
property_typePAT -625.387 -625.387 -625.387
(939.728) (1,066.442) (1,067.851)
property_typeSGL 1,870.337*** 1,870.337*** 1,870.337***
(442.876) (360.729) (361.205)
property_typeTNH 743.219 743.219 743.219
(557.889) (455.183) (455.784)
ac_typenone -192.063 -192.063 -192.063
(386.126) (357.138) (357.610)
ac_typenot_central -1,641.509*** -1,641.509*** -1,641.509***
(247.971) (290.407) (290.790)
list_price 0.980*** 0.980*** 0.980***
(0.001) (0.002) (0.002)
patio1 827.416*** 827.416*** 827.416***
(128.033) (128.482) (128.652)
school_general1 410.866** 410.866** 410.866**
(162.687) (172.772) (173.001)
photo_count -50.957*** -50.957*** -50.957***
(7.607) (7.838) (7.848)
pool1 -53.006 -53.006 -53.006
(212.039) (200.351) (200.615)
roof_typeother 1,112.080*** 1,112.080*** 1,112.080***
(235.707) (271.355) (271.714)
roof_typeshingle 1,951.830*** 1,951.830*** 1,951.830***
(264.772) (302.520) (302.919)
roof_typeslate 309.464 309.464 309.464
(1,122.512) (930.886) (932.115)
gas_typenatural 4,341.763 4,341.763*** 4,341.763***
(8,665.751) (689.120) (690.030)
gas_typenone 3,266.696 3,266.696*** 3,266.696***
(8,661.789) (504.194) (504.860)
gas_typepropane -989.131 -989.131 -989.131
(8,865.135) (3,398.818) (3,403.308)
gas_typeunknown 2,898.613 2,898.613*** 2,898.613***
(8,660.781) (490.561) (491.209)
out_building1 -476.097*** -476.097*** -476.097***
(138.835) (148.434) (148.630)
area_living -0.823*** -0.823** -0.823**
(0.275) (0.342) (0.342)
land_acres -439.562*** -439.562*** -439.562***
(155.641) (167.158) (167.379)
appliances1 809.002*** 809.002*** 809.002***
(174.291) (194.646) (194.903)
garage1 686.971*** 686.971*** 686.971***
(127.988) (144.649) (144.840)
property_conditionnew -3,579.800*** -3,579.800* -3,579.800*
(777.974) (1,948.192) (1,950.765)
property_conditionother -360.630** -360.630* -360.630*
(170.567) (185.122) (185.367)
energy_efficient1 541.686*** 541.686*** 541.686***
(142.924) (150.854) (151.053)
exterior_typemetal -256.773 -256.773 -256.773
(406.790) (393.633) (394.153)
exterior_typeother -27.039 -27.039 -27.039
(169.040) (179.539) (179.776)
exterior_typevinyl 341.549* 341.549* 341.549*
(187.982) (183.114) (183.356)
exterior_typewood -569.409** -569.409* -569.409*
(265.661) (332.607) (333.046)
exterior_featurescourtyard 2,438.792* 2,438.792 2,438.792
(1,426.749) (2,316.895) (2,319.956)
exterior_featuresfence 1,260.658** 1,260.658* 1,260.658*
(608.558) (726.476) (727.435)
exterior_featuresnone 1,842.622*** 1,842.622** 1,842.622**
(609.818) (733.425) (734.394)
exterior_featuresporch 1,421.765** 1,421.765* 1,421.765*
(623.464) (754.579) (755.575)
exterior_featurestennis_court 639.160 639.160 639.160
(1,745.894) (1,455.059) (1,456.981)
fireplace1 278.509** 278.509** 278.509**
(132.591) (133.332) (133.508)
foundation_typeslab 818.738*** 818.738*** 818.738***
(191.730) (220.563) (220.854)
foundation_typeunspecified -259.453 -259.453 -259.453
(231.202) (263.505) (263.853)
area_total -0.224 -0.224 -0.224
(0.160) (0.187) (0.187)
beds_total1 -582.560 -582.560 -582.560
(3,224.412) (4,044.357) (4,049.699)
beds_total2 -1,004.923 -1,004.923 -1,004.923
(3,193.289) (4,044.035) (4,049.377)
beds_total3 -366.699 -366.699 -366.699
(3,196.708) (4,047.563) (4,052.909)
beds_total4 461.923 461.923 461.923
(3,202.804) (4,055.157) (4,060.513)
beds_total5 -737.647 -737.647 -737.647
(3,256.641) (4,190.722) (4,196.257)
bath_full1 2,733.181 2,733.181 2,733.181
(3,407.188) (2,916.875) (2,920.728)
bath_full2 3,218.264 3,218.264 3,218.264
(3,407.002) (2,915.962) (2,919.814)
bath_full3 2,735.627 2,735.627 2,735.627
(3,414.855) (2,931.150) (2,935.022)
bath_full4 -681.328 -681.328 -681.328
(3,773.160) (4,054.279) (4,059.635)
bath_full6 -3,477.192 -3,477.192 -3,477.192
(9,338.847) (3,175.022) (3,179.216)
bath_half1 -403.384** -403.384** -403.384**
(167.586) (176.907) (177.140)
bath_half2 -1,313.944 -1,313.944 -1,313.944
(1,081.997) (1,388.187) (1,390.021)
bath_half3 1,774.798 1,774.798*** 1,774.798***
(6,123.620) (419.185) (419.739)
bath_half4 7,105.572 7,105.572*** 7,105.572***
(8,664.904) (548.354) (549.078)
bath_half5 -9,208.754* -9,208.754** -9,208.754**
(5,008.286) (4,313.418) (4,319.116)
age -38.256*** -38.256*** -38.256***
(3.771) (4.660) (4.666)
dom -15.788*** -15.788*** -15.788***
(0.967) (0.949) (0.951)
sold_date 0.402*** 0.402*** 0.402***
(0.064) (0.065) (0.065)
sewer_typeseptic -301.061 -301.061 -301.061
(239.413) (262.165) (262.511)
sewer_typeunspecified 253.412* 253.412** 253.412**
(130.716) (123.113) (123.275)
property_stylenot_mobile 2,165.925*** 2,165.925*** 2,165.925***
(357.544) (328.752) (329.186)
subdivision1 343.747** 343.747* 343.747*
(152.920) (186.798) (187.045)
water_typewell 391.734 391.734 391.734
(603.556) (723.223) (724.179)
waterfront1 -1,569.322*** -1,569.322*** -1,569.322***
(226.139) (269.427) (269.783)
Constant -16,871.450* -16,871.450*** -16,871.450***
(9,645.531) (3,836.467) (3,841.534)
------------------------------------------------------------------------------------------
Observations 24,653
R2 0.991
Adjusted R2 0.990
Residual Std. Error 8,652.322 (df = 24588)
F Statistic 40,127.540*** (df = 64; 24588)
==========================================================================================
Note: *p<0.1; **p<0.05; ***p<0.01
Note: Advisor suggested not to inlude interaction terms except for specific testing.
# Age
ggplot(data_factor, aes(x = age , y = sold_price)) +
geom_point(aes(color = infections_period), alpha = 0.15) +
geom_smooth(aes(color = infections_period)) +
geom_smooth(color = "grey50", linetype = "dashed") +
theme_minimal()
`geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
# Actual vs. fit
# Model with non-linear addition
lm_pre_alpha_age <- lm(sold_price ~ . + I(age^2), data = data_factor_core)
summ(lm_pre_alpha_age)
MODEL INFO:
Observations: 24653 (19 missing obs. deleted)
Dependent Variable: sold_price
Type: OLS linear regression
MODEL FIT:
F(66,24586) = 39371.52, p = 0.00
R² = 0.99
Adj. R² = 0.99
Standard errors: OLS
-------------------------------------------------------------------------
Est. S.E. t val. p
----------------------------------- ----------- --------- -------- ------
(Intercept) -13239.80 9600.55 -1.38 0.17
property_typeDUP -1324.62 2899.14 -0.46 0.65
property_typeOTH -1899.10 2021.03 -0.94 0.35
property_typePAT -572.27 934.33 -0.61 0.54
property_typeSGL 1822.66 440.32 4.14 0.00
property_typeTNH 615.32 554.70 1.11 0.27
ac_typenone -41.40 384.08 -0.11 0.91
ac_typenot_central -1747.66 246.68 -7.08 0.00
list_price 0.98 0.00 919.48 0.00
patio1 752.74 127.49 5.90 0.00
school_general1 158.56 162.43 0.98 0.33
photo_count -29.81 7.66 -3.89 0.00
pool1 -29.75 210.98 -0.14 0.89
roof_typeother 1047.37 234.45 4.47 0.00
roof_typeshingle 1710.94 264.07 6.48 0.00
roof_typeslate 287.05 1116.16 0.26 0.80
gas_typenatural 4575.88 8615.67 0.53 0.60
gas_typenone 4069.39 8611.83 0.47 0.64
gas_typepropane 123.55 8814.03 0.01 0.99
gas_typeunknown 3713.42 8610.90 0.43 0.67
out_building1 -411.27 138.26 -2.97 0.00
area_living -0.78 0.27 -2.87 0.00
land_acres -295.56 155.10 -1.91 0.06
appliances1 802.20 173.58 4.62 0.00
garage1 575.32 127.59 4.51 0.00
property_conditionnew -4096.18 778.38 -5.26 0.00
property_conditionother -390.15 169.81 -2.30 0.02
energy_efficient1 586.82 142.13 4.13 0.00
exterior_typemetal -289.21 404.45 -0.72 0.47
exterior_typeother 36.20 168.16 0.22 0.83
exterior_typevinyl 390.37 186.96 2.09 0.04
exterior_typewood -636.40 264.17 -2.41 0.02
exterior_featurescourtyard 2097.82 1419.86 1.48 0.14
exterior_featuresfence 1279.50 605.04 2.11 0.03
exterior_featuresnone 1755.59 606.33 2.90 0.00
exterior_featuresporch 1221.06 620.26 1.97 0.05
exterior_featurestennis_court 562.34 1735.92 0.32 0.75
fireplace1 383.81 132.17 2.90 0.00
foundation_typeslab 987.84 192.24 5.14 0.00
foundation_typeunspecified -86.37 230.48 -0.37 0.71
area_total -0.19 0.16 -1.16 0.24
beds_total1 -439.62 3205.79 -0.14 0.89
beds_total2 -824.86 3174.95 -0.26 0.80
beds_total3 -190.38 3178.35 -0.06 0.95
beds_total4 660.82 3184.37 0.21 0.84
beds_total5 -505.87 3237.91 -0.16 0.88
bath_full1 2197.99 3387.71 0.65 0.52
bath_full2 2650.30 3387.52 0.78 0.43
bath_full3 2168.13 3395.34 0.64 0.52
bath_full4 -1298.13 3751.63 -0.35 0.73
bath_full6 -5311.36 9287.20 -0.57 0.57
bath_half1 -316.07 166.82 -1.89 0.06
bath_half2 -1279.61 1075.72 -1.19 0.23
bath_half3 1338.17 6088.15 0.22 0.83
bath_half4 8340.38 8615.01 0.97 0.33
bath_half5 -8462.17 4979.49 -1.70 0.09
age -123.32 11.06 -11.15 0.00
dom -8.32 1.07 -7.74 0.00
sold_date 0.17 0.07 2.55 0.01
sewer_typeseptic -198.43 238.38 -0.83 0.41
sewer_typeunspecified 276.87 129.97 2.13 0.03
property_stylenot_mobile 2190.82 355.48 6.16 0.00
subdivision1 421.66 152.11 2.77 0.01
water_typewell 338.76 600.25 0.56 0.57
waterfront1 -1590.45 224.89 -7.07 0.00
bottom25_dom1 2427.61 159.95 15.18 0.00
I(age^2) 1.14 0.14 8.18 0.00
-------------------------------------------------------------------------
# Marginal effects data frames
ggpredict_1 <- ggpredict(lm_pre_alpha, terms = "age")
ggpredict_2 <- ggpredict(lm_pre_alpha_age, terms = "age")
# Plots
ggplot(data_factor_core, aes( x = age)) +
geom_smooth(data_factor_core, mapping = aes(y = sold_price), color = "grey50") +
geom_smooth(ggpredict_1, mapping = aes(x, predicted), linetype = "dashed", color = "darkred") +
geom_smooth(ggpredict_2, mapping = aes(x, predicted), linetype = "dashed", color = "darkblue")
`geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula 'y ~ x'
`geom_smooth()` using method = 'loess' and formula 'y ~ x'
# Look at age & age^2 alone to see impact on more relevant y-axis scale
ggplot() +
geom_smooth(ggpredict_1, mapping = aes(x, predicted), linetype = "dashed", color = "darkred") +
geom_smooth(ggpredict_2, mapping = aes(x, predicted), linetype = "dashed", color = "darkblue")
`geom_smooth()` using method = 'loess' and formula 'y ~ x'
`geom_smooth()` using method = 'loess' and formula 'y ~ x'
# Living Area
# General graphing
ggplot(data_factor, aes(x = area_living , y = sold_price)) +
geom_point(aes(color = infections_period), alpha = 0.15) +
geom_smooth(aes(color = infections_period)) +
geom_smooth(color = "grey50", linetype = "dashed") +
theme_minimal()
`geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
ggplot(data_factor, aes(x = area_living , y = sold_price/area_living)) +
geom_point(aes(color = infections_period), alpha = 0.15) +
geom_smooth(aes(color = infections_period)) +
geom_smooth(color = "grey50", linetype = "dashed") +
theme_minimal()
`geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
# Actual vs. fit
# Model with non-linear addition
lm_pre_alpha_area <- lm(sold_price ~ . + I(area_living^4), data = data_factor_core)
summ(lm_pre_alpha_area)
MODEL INFO:
Observations: 24653 (19 missing obs. deleted)
Dependent Variable: sold_price
Type: OLS linear regression
MODEL FIT:
F(66,24586) = 39357.96, p = 0.00
R² = 0.99
Adj. R² = 0.99
Standard errors: OLS
-------------------------------------------------------------------------
Est. S.E. t val. p
----------------------------------- ----------- --------- -------- ------
(Intercept) -19474.39 9596.66 -2.03 0.04
property_typeDUP -1172.09 2899.83 -0.40 0.69
property_typeOTH -2054.62 2021.31 -1.02 0.31
property_typePAT -524.61 934.47 -0.56 0.57
property_typeSGL 1832.68 440.39 4.16 0.00
property_typeTNH 540.02 554.94 0.97 0.33
ac_typenone 76.30 384.32 0.20 0.84
ac_typenot_central -1573.32 247.00 -6.37 0.00
list_price 0.98 0.00 928.52 0.00
patio1 781.37 127.37 6.13 0.00
school_general1 247.09 162.24 1.52 0.13
photo_count -34.89 7.64 -4.57 0.00
pool1 -26.35 211.05 -0.12 0.90
roof_typeother 1050.78 234.49 4.48 0.00
roof_typeshingle 1839.24 263.37 6.98 0.00
roof_typeslate 417.56 1116.22 0.37 0.71
gas_typenatural 5196.97 8617.09 0.60 0.55
gas_typenone 4612.23 8613.37 0.54 0.59
gas_typepropane 210.62 8815.53 0.02 0.98
gas_typeunknown 4252.26 8612.37 0.49 0.62
out_building1 -475.06 138.05 -3.44 0.00
area_living 1.71 0.43 4.02 0.00
land_acres -278.57 155.12 -1.80 0.07
appliances1 876.39 173.37 5.06 0.00
garage1 618.81 127.36 4.86 0.00
property_conditionnew -3562.90 774.03 -4.60 0.00
property_conditionother -326.54 169.63 -1.93 0.05
energy_efficient1 591.03 142.16 4.16 0.00
exterior_typemetal -196.32 404.56 -0.49 0.63
exterior_typeother 54.44 168.18 0.32 0.75
exterior_typevinyl 423.87 186.99 2.27 0.02
exterior_typewood -560.69 264.21 -2.12 0.03
exterior_featurescourtyard 2611.75 1418.75 1.84 0.07
exterior_featuresfence 1318.77 605.14 2.18 0.03
exterior_featuresnone 1818.67 606.39 3.00 0.00
exterior_featuresporch 1404.34 619.95 2.27 0.02
exterior_featurestennis_court 876.95 1736.16 0.51 0.61
fireplace1 221.48 132.32 1.67 0.09
foundation_typeslab 794.33 190.67 4.17 0.00
foundation_typeunspecified -190.31 229.95 -0.83 0.41
area_total -0.31 0.16 -1.95 0.05
beds_total1 -823.90 3206.34 -0.26 0.80
beds_total2 -1857.92 3176.83 -0.58 0.56
beds_total3 -1553.41 3181.87 -0.49 0.63
beds_total4 -665.22 3187.83 -0.21 0.83
beds_total5 -1454.87 3239.53 -0.45 0.65
bath_full1 3383.86 3389.76 1.00 0.32
bath_full2 3485.81 3388.46 1.03 0.30
bath_full3 3470.17 3397.93 1.02 0.31
bath_full4 508.39 3756.34 0.14 0.89
bath_full6 -3628.65 9286.25 -0.39 0.70
bath_half1 -302.68 166.98 -1.81 0.07
bath_half2 -1096.77 1076.24 -1.02 0.31
bath_half3 1277.77 6089.23 0.21 0.83
bath_half4 7495.33 8617.16 0.87 0.38
bath_half5 -7936.23 4980.77 -1.59 0.11
age -37.56 3.75 -10.01 0.00
dom -8.60 1.07 -8.00 0.00
sold_date 0.27 0.06 4.18 0.00
sewer_typeseptic -318.03 238.07 -1.34 0.18
sewer_typeunspecified 267.67 129.98 2.06 0.04
property_stylenot_mobile 2075.23 355.73 5.83 0.00
subdivision1 422.34 152.14 2.78 0.01
water_typewell 271.25 600.25 0.45 0.65
waterfront1 -1547.24 224.87 -6.88 0.00
bottom25_dom1 2398.28 159.90 15.00 0.00
I(area_living^4) -0.00 0.00 -7.65 0.00
-------------------------------------------------------------------------
# Model with single-variable fit
lm_pre_alpha_area_single <- lm(sold_price ~ area_living, data = data_factor_core)
summ(lm_pre_alpha_area_single)
MODEL INFO:
Observations: 24672
Dependent Variable: sold_price
Type: OLS linear regression
MODEL FIT:
F(1,24670) = 14902.00, p = 0.00
R² = 0.38
Adj. R² = 0.38
Standard errors: OLS
-------------------------------------------------------
Est. S.E. t val. p
----------------- ----------- --------- -------- ------
(Intercept) -25058.51 1670.25 -15.00 0.00
area_living 116.89 0.96 122.07 0.00
-------------------------------------------------------
# Marginal effects data frames
ggpredict_1 <- ggpredict(lm_pre_alpha, terms = "area_living") # total model
ggpredict_2 <- ggpredict(lm_pre_alpha_area, terms = "area_living") # non-linear addition
ggpredict_3 <- ggpredict(lm_pre_alpha_area_single, terms = "area_living") # single-variable fit
# Plots
ggplot(data_factor_core, aes(x = area_living)) +
geom_smooth(data_factor, mapping = aes(y = sold_price), color = "grey50") +
geom_smooth(ggpredict_1, mapping = aes(x, predicted), linetype = "dashed", color = "darkred") +
geom_smooth(ggpredict_2, mapping = aes(x, predicted), linetype = "dashed", color = "darkblue") +
geom_smooth(ggpredict_3, mapping = aes(x, predicted), linetype = "dashed", color = "darkgreen")
`geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula 'y ~ x'
`geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula 'y ~ x'
# Look at age & age^2 alone to see impact on more relevant y-axis scale
ggplot() +
geom_smooth(ggpredict_1, mapping = aes(x, predicted), linetype = "dashed", color = "darkred") +
geom_smooth(ggpredict_2, mapping = aes(x, predicted), linetype = "dashed", color = "darkblue")
`geom_smooth()` using method = 'loess' and formula 'y ~ x'
`geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
# Conclusion
# General graphing
ggplot(data_factor, aes(x = land_acres , y = sold_price)) +
geom_point(aes(color = infections_period), alpha = 0.15) +
geom_smooth(aes(color = infections_period)) +
geom_smooth(color = "grey50", linetype = "dashed") +
theme_minimal()
`geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
ggplot(data_factor, aes(x = land_acres, y = sold_price/land_acres)) +
geom_point(aes(color = infections_period), alpha = 0.15) +
geom_smooth(aes(color = infections_period)) +
geom_smooth(color = "grey50", linetype = "dashed") +
theme_minimal()
`geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
#Additions
data_factor_core_clean <- data_factor_core
data_factor_core_clean$age_2 <- I(data_factor_core$age^2)
data_factor_core_clean$area_living_2 <- I(data_factor_core$area_living^2)
# Full model summary
summ(lm_pre_alpha)
MODEL INFO:
Observations: 24653 (19 missing obs. deleted)
Dependent Variable: sold_price
Type: OLS linear regression
MODEL FIT:
F(64,24588) = 40127.54, p = 0.00
R² = 0.99
Adj. R² = 0.99
Standard errors: OLS
-------------------------------------------------------------------------
Est. S.E. t val. p
----------------------------------- ----------- --------- -------- ------
(Intercept) -16871.45 9645.53 -1.75 0.08
property_typeDUP -1382.69 2916.00 -0.47 0.64
property_typeOTH -2350.66 2032.65 -1.16 0.25
property_typePAT -625.39 939.73 -0.67 0.51
property_typeSGL 1870.34 442.88 4.22 0.00
property_typeTNH 743.22 557.89 1.33 0.18
ac_typenone -192.06 386.13 -0.50 0.62
ac_typenot_central -1641.51 247.97 -6.62 0.00
list_price 0.98 0.00 926.47 0.00
patio1 827.42 128.03 6.46 0.00
school_general1 410.87 162.69 2.53 0.01
photo_count -50.96 7.61 -6.70 0.00
pool1 -53.01 212.04 -0.25 0.80
roof_typeother 1112.08 235.71 4.72 0.00
roof_typeshingle 1951.83 264.77 7.37 0.00
roof_typeslate 309.46 1122.51 0.28 0.78
gas_typenatural 4341.76 8665.75 0.50 0.62
gas_typenone 3266.70 8661.79 0.38 0.71
gas_typepropane -989.13 8865.14 -0.11 0.91
gas_typeunknown 2898.61 8660.78 0.33 0.74
out_building1 -476.10 138.84 -3.43 0.00
area_living -0.82 0.27 -3.00 0.00
land_acres -439.56 155.64 -2.82 0.00
appliances1 809.00 174.29 4.64 0.00
garage1 686.97 127.99 5.37 0.00
property_conditionnew -3579.80 777.97 -4.60 0.00
property_conditionother -360.63 170.57 -2.11 0.03
energy_efficient1 541.69 142.92 3.79 0.00
exterior_typemetal -256.77 406.79 -0.63 0.53
exterior_typeother -27.04 169.04 -0.16 0.87
exterior_typevinyl 341.55 187.98 1.82 0.07
exterior_typewood -569.41 265.66 -2.14 0.03
exterior_featurescourtyard 2438.79 1426.75 1.71 0.09
exterior_featuresfence 1260.66 608.56 2.07 0.04
exterior_featuresnone 1842.62 609.82 3.02 0.00
exterior_featuresporch 1421.76 623.46 2.28 0.02
exterior_featurestennis_court 639.16 1745.89 0.37 0.71
fireplace1 278.51 132.59 2.10 0.04
foundation_typeslab 818.74 191.73 4.27 0.00
foundation_typeunspecified -259.45 231.20 -1.12 0.26
area_total -0.22 0.16 -1.40 0.16
beds_total1 -582.56 3224.41 -0.18 0.86
beds_total2 -1004.92 3193.29 -0.31 0.75
beds_total3 -366.70 3196.71 -0.11 0.91
beds_total4 461.92 3202.80 0.14 0.89
beds_total5 -737.65 3256.64 -0.23 0.82
bath_full1 2733.18 3407.19 0.80 0.42
bath_full2 3218.26 3407.00 0.94 0.34
bath_full3 2735.63 3414.85 0.80 0.42
bath_full4 -681.33 3773.16 -0.18 0.86
bath_full6 -3477.19 9338.85 -0.37 0.71
bath_half1 -403.38 167.59 -2.41 0.02
bath_half2 -1313.94 1082.00 -1.21 0.22
bath_half3 1774.80 6123.62 0.29 0.77
bath_half4 7105.57 8664.90 0.82 0.41
bath_half5 -9208.75 5008.29 -1.84 0.07
age -38.26 3.77 -10.14 0.00
dom -15.79 0.97 -16.33 0.00
sold_date 0.40 0.06 6.28 0.00
sewer_typeseptic -301.06 239.41 -1.26 0.21
sewer_typeunspecified 253.41 130.72 1.94 0.05
property_stylenot_mobile 2165.93 357.54 6.06 0.00
subdivision1 343.75 152.92 2.25 0.02
water_typewell 391.73 603.56 0.65 0.52
waterfront1 -1569.32 226.14 -6.94 0.00
-------------------------------------------------------------------------
# Check VIF
VIF(lm_pre_alpha)
GVIF Df GVIF^(1/(2*Df))
property_type 1.657957 5 1.051859
ac_type 1.263888 2 1.060296
list_price 2.919899 1 1.708771
patio 1.349119 1 1.161516
school_general 1.899871 1 1.378358
photo_count 1.382061 1 1.175611
pool 1.129804 1 1.062922
roof_type 1.711856 3 1.093733
gas_type 1.931949 4 1.085799
out_building 1.177668 1 1.085204
area_living 5.374711 1 2.318342
land_acres 1.734112 1 1.316857
appliances 1.396715 1 1.181827
garage 1.337815 1 1.156639
property_condition 1.585798 2 1.122179
energy_efficient 1.512993 1 1.230038
exterior_type 2.438352 4 1.117859
exterior_features 1.630026 5 1.050073
fireplace 1.420374 1 1.191794
foundation_type 1.807844 2 1.159552
area_total 4.361061 1 2.088315
beds_total 2.975778 5 1.115219
bath_full 2.998067 5 1.116051
bath_half 1.321690 5 1.028284
age 1.424153 1 1.193379
dom 1.330203 1 1.153344
sold_date 1.854387 1 1.361759
sewer_type 1.317326 2 1.071330
property_style 1.288210 1 1.134994
subdivision 1.155996 1 1.075172
water_type 1.060962 1 1.030030
waterfront 1.098253 1 1.047976
alias(lm_pre_alpha)
Model :
sold_price ~ property_type + ac_type + list_price + patio + school_general +
photo_count + pool + roof_type + gas_type + out_building +
area_living + land_acres + appliances + garage + property_condition +
energy_efficient + exterior_type + exterior_features + fireplace +
foundation_type + area_total + beds_total + bath_full + bath_half +
age + dom + sold_date + sewer_type + property_style + subdivision +
water_type + waterfront
# Total area and living area are found to be significantly (i.e. VIF > 5) multicolinear (expected)
# Solution: Remove area_total
# Note the significant drop in R^2 from 0.99 to 0.86
lm_pre_alpha_cleaned <- lm(log(sold_price) ~ . - area_total ,data = data_factor_core)
summ(lm_pre_alpha_cleaned)
MODEL INFO:
Observations: 24653 (19 missing obs. deleted)
Dependent Variable: log(sold_price)
Type: OLS linear regression
MODEL FIT:
F(63,24589) = 2352.26, p = 0.00
R² = 0.86
Adj. R² = 0.86
Standard errors: OLS
------------------------------------------------------------------
Est. S.E. t val. p
----------------------------------- ------- ------ -------- ------
(Intercept) 10.65 0.29 36.65 0.00
property_typeDUP -0.26 0.09 -3.01 0.00
property_typeOTH 0.00 0.06 0.01 0.99
property_typePAT -0.09 0.03 -3.04 0.00
property_typeSGL -0.05 0.01 -3.84 0.00
property_typeTNH 0.02 0.02 1.06 0.29
ac_typenone -0.61 0.01 -52.82 0.00
ac_typenot_central -0.17 0.01 -22.14 0.00
list_price 0.00 0.00 197.52 0.00
patio1 0.02 0.00 4.33 0.00
school_general1 0.01 0.00 2.90 0.00
photo_count 0.00 0.00 6.34 0.00
pool1 -0.04 0.01 -5.70 0.00
roof_typeother 0.04 0.01 5.07 0.00
roof_typeshingle 0.05 0.01 6.22 0.00
roof_typeslate 0.06 0.03 1.73 0.08
gas_typenatural -0.09 0.26 -0.36 0.72
gas_typenone -0.03 0.26 -0.10 0.92
gas_typepropane -0.13 0.27 -0.50 0.62
gas_typeunknown -0.04 0.26 -0.14 0.89
out_building1 0.02 0.00 5.41 0.00
area_living -0.00 0.00 -8.70 0.00
land_acres 0.04 0.00 7.78 0.00
appliances1 0.14 0.01 26.21 0.00
garage1 0.02 0.00 4.50 0.00
property_conditionnew -0.10 0.02 -4.33 0.00
property_conditionother -0.05 0.01 -10.00 0.00
energy_efficient1 0.02 0.00 4.05 0.00
exterior_typemetal -0.05 0.01 -3.82 0.00
exterior_typeother -0.01 0.01 -2.46 0.01
exterior_typevinyl 0.02 0.01 2.89 0.00
exterior_typewood -0.03 0.01 -4.13 0.00
exterior_featurescourtyard -0.03 0.04 -0.73 0.47
exterior_featuresfence 0.06 0.02 3.41 0.00
exterior_featuresnone 0.07 0.02 3.54 0.00
exterior_featuresporch 0.07 0.02 3.60 0.00
exterior_featurestennis_court 0.04 0.05 0.80 0.42
fireplace1 -0.00 0.00 -0.69 0.49
foundation_typeslab 0.12 0.01 20.02 0.00
foundation_typeunspecified 0.07 0.01 10.75 0.00
beds_total1 -0.31 0.10 -3.21 0.00
beds_total2 -0.29 0.10 -2.98 0.00
beds_total3 -0.23 0.10 -2.44 0.01
beds_total4 -0.27 0.10 -2.75 0.01
beds_total5 -0.25 0.10 -2.51 0.01
bath_full1 -0.21 0.10 -2.05 0.04
bath_full2 -0.11 0.10 -1.05 0.30
bath_full3 -0.21 0.10 -2.00 0.05
bath_full4 -0.22 0.11 -1.94 0.05
bath_full6 0.22 0.28 0.77 0.44
bath_half1 -0.03 0.01 -5.93 0.00
bath_half2 -0.06 0.03 -1.69 0.09
bath_half3 -0.10 0.18 -0.53 0.59
bath_half4 -0.33 0.26 -1.26 0.21
bath_half5 -0.06 0.15 -0.42 0.67
age 0.00 0.00 3.79 0.00
dom -0.00 0.00 -4.38 0.00
sold_date 0.00 0.00 4.87 0.00
sewer_typeseptic 0.01 0.01 1.59 0.11
sewer_typeunspecified 0.01 0.00 2.69 0.01
property_stylenot_mobile 0.23 0.01 21.04 0.00
subdivision1 -0.01 0.00 -2.50 0.01
water_typewell -0.01 0.02 -0.80 0.42
waterfront1 -0.02 0.01 -2.67 0.01
------------------------------------------------------------------
VIF(lm_pre_alpha_cleaned)
GVIF Df GVIF^(1/(2*Df))
property_type 1.632824 5 1.050253
ac_type 1.262890 2 1.060087
list_price 2.844071 1 1.686437
patio 1.337542 1 1.156521
school_general 1.899871 1 1.378358
photo_count 1.381031 1 1.175173
pool 1.129758 1 1.062901
roof_type 1.696093 3 1.092048
gas_type 1.917232 4 1.084762
out_building 1.159800 1 1.076940
area_living 3.209116 1 1.791401
land_acres 1.713474 1 1.308997
appliances 1.396593 1 1.181775
garage 1.312878 1 1.145809
property_condition 1.576092 2 1.120457
energy_efficient 1.507662 1 1.227869
exterior_type 2.435445 4 1.117692
exterior_features 1.629146 5 1.050016
fireplace 1.420356 1 1.191787
foundation_type 1.803983 2 1.158932
beds_total 2.970643 5 1.115026
bath_full 2.987539 5 1.115659
bath_half 1.315695 5 1.027816
age 1.423463 1 1.193090
dom 1.328960 1 1.152805
sold_date 1.851205 1 1.360590
sewer_type 1.314995 2 1.070856
property_style 1.284402 1 1.133315
subdivision 1.155357 1 1.074875
water_type 1.059658 1 1.029397
waterfront 1.097917 1 1.047815
# Final pre_alpha
VIF(lm_pre_alpha_cleaned)
GVIF Df GVIF^(1/(2*Df))
property_type 1.632824 5 1.050253
ac_type 1.262890 2 1.060087
list_price 2.844071 1 1.686437
patio 1.337542 1 1.156521
school_general 1.899871 1 1.378358
photo_count 1.381031 1 1.175173
pool 1.129758 1 1.062901
roof_type 1.696093 3 1.092048
gas_type 1.917232 4 1.084762
out_building 1.159800 1 1.076940
area_living 3.209116 1 1.791401
land_acres 1.713474 1 1.308997
appliances 1.396593 1 1.181775
garage 1.312878 1 1.145809
property_condition 1.576092 2 1.120457
energy_efficient 1.507662 1 1.227869
exterior_type 2.435445 4 1.117692
exterior_features 1.629146 5 1.050016
fireplace 1.420356 1 1.191787
foundation_type 1.803983 2 1.158932
beds_total 2.970643 5 1.115026
bath_full 2.987539 5 1.115659
bath_half 1.315695 5 1.027816
age 1.423463 1 1.193090
dom 1.328960 1 1.152805
sold_date 1.851205 1 1.360590
sewer_type 1.314995 2 1.070856
property_style 1.284402 1 1.133315
subdivision 1.155357 1 1.074875
water_type 1.059658 1 1.029397
waterfront 1.097917 1 1.047815
alias(lm_pre_alpha_cleaned)
Model :
log(sold_price) ~ (property_type + ac_type + list_price + patio +
school_general + photo_count + pool + roof_type + gas_type +
out_building + area_living + land_acres + appliances + garage +
property_condition + energy_efficient + exterior_type + exterior_features +
fireplace + foundation_type + area_total + beds_total + bath_full +
bath_half + age + dom + sold_date + sewer_type + property_style +
subdivision + water_type + waterfront) - area_total
# Another way to check for multicollinearity is visually through the mcvis package
data_numeric <- select_if(data_factor_core, is.numeric) # Subset numeric columns with dplyr
mcvis_result <- mcvis(X = data_numeric)
plot(mcvis_result)
#Removals
data_numeric <- subset(data_numeric, select = -c(list_price))
mcvis_result <- mcvis(X = data_numeric)
plot(mcvis_result)
#Removals
data_numeric <- subset(data_numeric, select = -c(area_total))
mcvis_result <- mcvis(X = data_numeric)
plot(mcvis_result)
# Removals
# - Area_total
# - Listing price
data_factor_core_clean <- subset(data_factor_core_clean, select = -c(area_total, list_price))
# Finalized base model
lm_alpha <- lm(sold_price ~ . ,data = data_factor_core_clean)
summ(lm_alpha)
MODEL INFO:
Observations: 24653 (19 missing obs. deleted)
Dependent Variable: sold_price
Type: OLS linear regression
MODEL FIT:
F(64,24588) = 738.47, p = 0.00
R² = 0.66
Adj. R² = 0.66
Standard errors: OLS
---------------------------------------------------------------------------
Est. S.E. t val. p
----------------------------------- ------------ ---------- -------- ------
(Intercept) 121905.17 58138.81 2.10 0.04
property_typeDUP -50421.81 17513.85 -2.88 0.00
property_typeOTH 22755.99 12209.29 1.86 0.06
property_typePAT 15210.58 5641.07 2.70 0.01
property_typeSGL 22250.59 2641.10 8.42 0.00
property_typeTNH -3598.07 3351.44 -1.07 0.28
ac_typenone -45781.68 2302.34 -19.88 0.00
ac_typenot_central -14124.61 1492.02 -9.47 0.00
patio1 8219.22 765.83 10.73 0.00
school_general1 13925.87 974.74 14.29 0.00
photo_count 857.45 45.46 18.86 0.00
pool1 12879.34 1273.26 10.12 0.00
roof_typeother 3557.87 1411.24 2.52 0.01
roof_typeshingle 21306.39 1584.55 13.45 0.00
roof_typeslate 9936.36 6743.18 1.47 0.14
gas_typenatural -92957.25 52052.40 -1.79 0.07
gas_typenone -134836.16 52025.53 -2.59 0.01
gas_typepropane -108064.13 53249.14 -2.03 0.04
gas_typeunknown -140795.05 52018.83 -2.71 0.01
out_building1 -6209.58 828.49 -7.50 0.00
area_living 30.88 5.49 5.62 0.00
land_acres 1843.00 929.29 1.98 0.05
appliances1 24768.69 1036.86 23.89 0.00
garage1 12366.41 760.08 16.27 0.00
property_conditionnew -27283.63 4701.84 -5.80 0.00
property_conditionother -22077.29 1013.30 -21.79 0.00
energy_efficient1 14243.71 852.46 16.71 0.00
exterior_typemetal -674.62 2444.35 -0.28 0.78
exterior_typeother 11112.75 1012.99 10.97 0.00
exterior_typevinyl 4748.74 1128.94 4.21 0.00
exterior_typewood 4445.34 1595.71 2.79 0.01
exterior_featurescourtyard 34474.83 8576.00 4.02 0.00
exterior_featuresfence -32664.33 3649.19 -8.95 0.00
exterior_featuresnone -26048.51 3659.09 -7.12 0.00
exterior_featuresporch -33255.59 3741.08 -8.89 0.00
exterior_featurestennis_court -753.56 10489.35 -0.07 0.94
fireplace1 11644.16 797.05 14.61 0.00
foundation_typeslab 14822.42 1157.13 12.81 0.00
foundation_typeunspecified 7789.22 1390.99 5.60 0.00
beds_total1 -31106.47 19371.27 -1.61 0.11
beds_total2 -40119.14 19210.60 -2.09 0.04
beds_total3 -46514.92 19250.22 -2.42 0.02
beds_total4 -44053.78 19282.91 -2.28 0.02
beds_total5 -61840.56 19588.27 -3.16 0.00
bath_full1 -32364.08 20488.92 -1.58 0.11
bath_full2 -7087.55 20477.36 -0.35 0.73
bath_full3 19877.01 20538.60 0.97 0.33
bath_full4 22498.04 22703.08 0.99 0.32
bath_full6 18927.03 56111.91 0.34 0.74
bath_half1 13930.07 1004.37 13.87 0.00
bath_half2 37341.69 6489.96 5.75 0.00
bath_half3 57902.50 36783.72 1.57 0.12
bath_half4 80596.43 52052.19 1.55 0.12
bath_half5 -62415.19 30083.09 -2.07 0.04
age -1993.65 65.69 -30.35 0.00
dom -61.33 5.80 -10.58 0.00
sold_date 4.72 0.39 12.00 0.00
sewer_typeseptic -6668.81 1439.61 -4.63 0.00
sewer_typeunspecified -5255.63 783.80 -6.71 0.00
property_stylenot_mobile 68929.91 2103.67 32.77 0.00
subdivision1 3271.92 918.20 3.56 0.00
water_typewell 3009.83 3624.08 0.83 0.41
waterfront1 20272.74 1351.22 15.00 0.00
age_2 18.01 0.83 21.68 0.00
area_living_2 0.01 0.00 6.40 0.00
---------------------------------------------------------------------------
coeftest(lm_alpha, vcov = vcovHC(lm_alpha, method = "White2", type = "HC0"))
t test of coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.2191e+05 3.3148e+04 3.6776 0.0002359 ***
property_typeDUP -5.0422e+04 1.6342e+04 -3.0853 0.0020356 **
property_typeOTH 2.2756e+04 1.4577e+04 1.5610 0.1185253
property_typePAT 1.5211e+04 5.6037e+03 2.7144 0.0066448 **
property_typeSGL 2.2251e+04 2.6826e+03 8.2943 < 2.2e-16 ***
property_typeTNH -3.5981e+03 3.2923e+03 -1.0929 0.2744622
ac_typenone -4.5782e+04 1.9867e+03 -23.0435 < 2.2e-16 ***
ac_typenot_central -1.4125e+04 1.5987e+03 -8.8348 < 2.2e-16 ***
patio1 8.2192e+03 7.8268e+02 10.5013 < 2.2e-16 ***
school_general1 1.3926e+04 1.0356e+03 13.4466 < 2.2e-16 ***
photo_count 8.5745e+02 4.9039e+01 17.4852 < 2.2e-16 ***
pool1 1.2879e+04 1.4069e+03 9.1546 < 2.2e-16 ***
roof_typeother 3.5579e+03 1.4517e+03 2.4508 0.0142623 *
roof_typeshingle 2.1306e+04 1.6572e+03 12.8570 < 2.2e-16 ***
roof_typeslate 9.9364e+03 9.8011e+03 1.0138 0.3106873
gas_typenatural -9.2957e+04 3.5921e+03 -25.8781 < 2.2e-16 ***
gas_typenone -1.3484e+05 2.4717e+03 -54.5520 < 2.2e-16 ***
gas_typepropane -1.0806e+05 1.7973e+04 -6.0125 1.853e-09 ***
gas_typeunknown -1.4080e+05 2.3529e+03 -59.8380 < 2.2e-16 ***
out_building1 -6.2096e+03 8.3293e+02 -7.4551 9.276e-14 ***
area_living 3.0878e+01 6.1874e+00 4.9905 6.064e-07 ***
land_acres 1.8430e+03 9.4253e+02 1.9554 0.0505490 .
appliances1 2.4769e+04 1.1423e+03 21.6841 < 2.2e-16 ***
garage1 1.2366e+04 7.7824e+02 15.8903 < 2.2e-16 ***
property_conditionnew -2.7284e+04 6.5952e+03 -4.1369 3.532e-05 ***
property_conditionother -2.2077e+04 9.3933e+02 -23.5033 < 2.2e-16 ***
energy_efficient1 1.4244e+04 8.4610e+02 16.8346 < 2.2e-16 ***
exterior_typemetal -6.7462e+02 2.3639e+03 -0.2854 0.7753474
exterior_typeother 1.1113e+04 1.0793e+03 10.2965 < 2.2e-16 ***
exterior_typevinyl 4.7487e+03 1.1175e+03 4.2493 2.152e-05 ***
exterior_typewood 4.4453e+03 1.7872e+03 2.4873 0.0128775 *
exterior_featurescourtyard 3.4475e+04 1.4026e+04 2.4579 0.0139806 *
exterior_featuresfence -3.2664e+04 5.3290e+03 -6.1296 8.946e-10 ***
exterior_featuresnone -2.6049e+04 5.3360e+03 -4.8817 1.058e-06 ***
exterior_featuresporch -3.3256e+04 5.3935e+03 -6.1659 7.119e-10 ***
exterior_featurestennis_court -7.5356e+02 1.0638e+04 -0.0708 0.9435298
fireplace1 1.1644e+04 8.4038e+02 13.8558 < 2.2e-16 ***
foundation_typeslab 1.4822e+04 1.2994e+03 11.4070 < 2.2e-16 ***
foundation_typeunspecified 7.7892e+03 1.4350e+03 5.4280 5.753e-08 ***
beds_total1 -3.1106e+04 2.4541e+04 -1.2675 0.2049778
beds_total2 -4.0119e+04 2.4456e+04 -1.6405 0.1009210
beds_total3 -4.6515e+04 2.4522e+04 -1.8968 0.0578602 .
beds_total4 -4.4054e+04 2.4562e+04 -1.7936 0.0728970 .
beds_total5 -6.1841e+04 2.5017e+04 -2.4720 0.0134440 *
bath_full1 -3.2364e+04 2.3283e+04 -1.3900 0.1645321
bath_full2 -7.0876e+03 2.3272e+04 -0.3046 0.7607113
bath_full3 1.9877e+04 2.3369e+04 0.8506 0.3950129
bath_full4 2.2498e+04 2.9745e+04 0.7564 0.4494356
bath_full6 1.8927e+04 2.4130e+04 0.7844 0.4328247
bath_half1 1.3930e+04 1.1419e+03 12.1987 < 2.2e-16 ***
bath_half2 3.7342e+04 7.9737e+03 4.6831 2.841e-06 ***
bath_half3 5.7903e+04 1.1563e+04 5.0074 5.556e-07 ***
bath_half4 8.0596e+04 3.1855e+03 25.3007 < 2.2e-16 ***
bath_half5 -6.2415e+04 2.6838e+04 -2.3256 0.0200461 *
age -1.9936e+03 8.4928e+01 -23.4747 < 2.2e-16 ***
dom -6.1326e+01 5.8179e+00 -10.5410 < 2.2e-16 ***
sold_date 4.7155e+00 4.0415e-01 11.6676 < 2.2e-16 ***
sewer_typeseptic -6.6688e+03 1.4679e+03 -4.5431 5.569e-06 ***
sewer_typeunspecified -5.2556e+03 7.6196e+02 -6.8975 5.419e-12 ***
property_stylenot_mobile 6.8930e+04 1.7643e+03 39.0698 < 2.2e-16 ***
subdivision1 3.2719e+03 9.2380e+02 3.5418 0.0003981 ***
water_typewell 3.0098e+03 4.1119e+03 0.7320 0.4641849
waterfront1 2.0273e+04 1.5150e+03 13.3812 < 2.2e-16 ***
age_2 1.8014e+01 1.1938e+00 15.0897 < 2.2e-16 ***
area_living_2 9.3301e-03 1.7743e-03 5.2583 1.466e-07 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
stargazer(lm_pre_alpha, lm_alpha)
% Table created by stargazer v.5.2.2 by Marek Hlavac, Harvard University. E-mail: hlavac at fas.harvard.edu
% Date and time: Tue, Jan 18, 2022 - 13:16:51
\begin{table}[!htbp] \centering
\caption{}
\label{}
\begin{tabular}{@{\extracolsep{5pt}}lcc}
\\[-1.8ex]\hline
\hline \\[-1.8ex]
& \multicolumn{2}{c}{\textit{Dependent variable:}} \\
\cline{2-3}
\\[-1.8ex] & \multicolumn{2}{c}{sold\_price} \\
\\[-1.8ex] & (1) & (2)\\
\hline \\[-1.8ex]
property\_typeDUP & $-$1,382.690 & $-$50,421.810$^{***}$ \\
& (2,916.004) & (17,513.850) \\
& & \\
property\_typeOTH & $-$2,350.658 & 22,755.990$^{*}$ \\
& (2,032.645) & (12,209.290) \\
& & \\
property\_typePAT & $-$625.387 & 15,210.580$^{***}$ \\
& (939.728) & (5,641.066) \\
& & \\
property\_typeSGL & 1,870.337$^{***}$ & 22,250.590$^{***}$ \\
& (442.876) & (2,641.102) \\
& & \\
property\_typeTNH & 743.219 & $-$3,598.067 \\
& (557.889) & (3,351.443) \\
& & \\
ac\_typenone & $-$192.063 & $-$45,781.680$^{***}$ \\
& (386.126) & (2,302.340) \\
& & \\
ac\_typenot\_central & $-$1,641.509$^{***}$ & $-$14,124.600$^{***}$ \\
& (247.971) & (1,492.025) \\
& & \\
list\_price & 0.980$^{***}$ & \\
& (0.001) & \\
& & \\
patio1 & 827.416$^{***}$ & 8,219.218$^{***}$ \\
& (128.033) & (765.830) \\
& & \\
school\_general1 & 410.866$^{**}$ & 13,925.870$^{***}$ \\
& (162.687) & (974.744) \\
& & \\
photo\_count & $-$50.957$^{***}$ & 857.452$^{***}$ \\
& (7.607) & (45.463) \\
& & \\
pool1 & $-$53.006 & 12,879.340$^{***}$ \\
& (212.039) & (1,273.261) \\
& & \\
roof\_typeother & 1,112.080$^{***}$ & 3,557.871$^{**}$ \\
& (235.707) & (1,411.240) \\
& & \\
roof\_typeshingle & 1,951.830$^{***}$ & 21,306.380$^{***}$ \\
& (264.772) & (1,584.555) \\
& & \\
roof\_typeslate & 309.464 & 9,936.362 \\
& (1,122.512) & (6,743.180) \\
& & \\
gas\_typenatural & 4,341.763 & $-$92,957.250$^{*}$ \\
& (8,665.751) & (52,052.400) \\
& & \\
gas\_typenone & 3,266.696 & $-$134,836.200$^{***}$ \\
& (8,661.789) & (52,025.530) \\
& & \\
gas\_typepropane & $-$989.131 & $-$108,064.100$^{**}$ \\
& (8,865.135) & (53,249.140) \\
& & \\
gas\_typeunknown & 2,898.613 & $-$140,795.100$^{***}$ \\
& (8,660.781) & (52,018.830) \\
& & \\
out\_building1 & $-$476.097$^{***}$ & $-$6,209.579$^{***}$ \\
& (138.835) & (828.493) \\
& & \\
area\_living & $-$0.823$^{***}$ & 30.878$^{***}$ \\
& (0.275) & (5.492) \\
& & \\
land\_acres & $-$439.562$^{***}$ & 1,843.002$^{**}$ \\
& (155.641) & (929.291) \\
& & \\
appliances1 & 809.002$^{***}$ & 24,768.690$^{***}$ \\
& (174.291) & (1,036.856) \\
& & \\
garage1 & 686.971$^{***}$ & 12,366.410$^{***}$ \\
& (127.988) & (760.079) \\
& & \\
property\_conditionnew & $-$3,579.800$^{***}$ & $-$27,283.630$^{***}$ \\
& (777.974) & (4,701.840) \\
& & \\
property\_conditionother & $-$360.630$^{**}$ & $-$22,077.290$^{***}$ \\
& (170.567) & (1,013.301) \\
& & \\
energy\_efficient1 & 541.686$^{***}$ & 14,243.720$^{***}$ \\
& (142.924) & (852.459) \\
& & \\
exterior\_typemetal & $-$256.773 & $-$674.622 \\
& (406.790) & (2,444.346) \\
& & \\
exterior\_typeother & $-$27.039 & 11,112.750$^{***}$ \\
& (169.040) & (1,012.987) \\
& & \\
exterior\_typevinyl & 341.549$^{*}$ & 4,748.744$^{***}$ \\
& (187.982) & (1,128.941) \\
& & \\
exterior\_typewood & $-$569.409$^{**}$ & 4,445.337$^{***}$ \\
& (265.661) & (1,595.706) \\
& & \\
exterior\_featurescourtyard & 2,438.792$^{*}$ & 34,474.830$^{***}$ \\
& (1,426.749) & (8,575.997) \\
& & \\
exterior\_featuresfence & 1,260.658$^{**}$ & $-$32,664.330$^{***}$ \\
& (608.558) & (3,649.189) \\
& & \\
exterior\_featuresnone & 1,842.622$^{***}$ & $-$26,048.510$^{***}$ \\
& (609.818) & (3,659.093) \\
& & \\
exterior\_featuresporch & 1,421.765$^{**}$ & $-$33,255.590$^{***}$ \\
& (623.464) & (3,741.084) \\
& & \\
exterior\_featurestennis\_court & 639.160 & $-$753.565 \\
& (1,745.894) & (10,489.350) \\
& & \\
fireplace1 & 278.509$^{**}$ & 11,644.160$^{***}$ \\
& (132.591) & (797.046) \\
& & \\
foundation\_typeslab & 818.738$^{***}$ & 14,822.420$^{***}$ \\
& (191.730) & (1,157.134) \\
& & \\
foundation\_typeunspecified & $-$259.453 & 7,789.219$^{***}$ \\
& (231.202) & (1,390.994) \\
& & \\
area\_total & $-$0.224 & \\
& (0.160) & \\
& & \\
beds\_total1 & $-$582.560 & $-$31,106.470 \\
& (3,224.412) & (19,371.270) \\
& & \\
beds\_total2 & $-$1,004.923 & $-$40,119.140$^{**}$ \\
& (3,193.289) & (19,210.600) \\
& & \\
beds\_total3 & $-$366.699 & $-$46,514.920$^{**}$ \\
& (3,196.708) & (19,250.220) \\
& & \\
beds\_total4 & 461.923 & $-$44,053.780$^{**}$ \\
& (3,202.804) & (19,282.920) \\
& & \\
beds\_total5 & $-$737.647 & $-$61,840.560$^{***}$ \\
& (3,256.641) & (19,588.260) \\
& & \\
bath\_full1 & 2,733.181 & $-$32,364.080 \\
& (3,407.188) & (20,488.920) \\
& & \\
bath\_full2 & 3,218.264 & $-$7,087.551 \\
& (3,407.002) & (20,477.360) \\
& & \\
bath\_full3 & 2,735.627 & 19,877.010 \\
& (3,414.855) & (20,538.600) \\
& & \\
bath\_full4 & $-$681.328 & 22,498.030 \\
& (3,773.160) & (22,703.080) \\
& & \\
bath\_full6 & $-$3,477.192 & 18,927.030 \\
& (9,338.847) & (56,111.900) \\
& & \\
bath\_half1 & $-$403.384$^{**}$ & 13,930.080$^{***}$ \\
& (167.586) & (1,004.374) \\
& & \\
bath\_half2 & $-$1,313.944 & 37,341.690$^{***}$ \\
& (1,081.997) & (6,489.958) \\
& & \\
bath\_half3 & 1,774.798 & 57,902.500 \\
& (6,123.620) & (36,783.710) \\
& & \\
bath\_half4 & 7,105.572 & 80,596.430 \\
& (8,664.904) & (52,052.190) \\
& & \\
bath\_half5 & $-$9,208.754$^{*}$ & $-$62,415.190$^{**}$ \\
& (5,008.286) & (30,083.100) \\
& & \\
age & $-$38.256$^{***}$ & $-$1,993.649$^{***}$ \\
& (3.771) & (65.693) \\
& & \\
dom & $-$15.788$^{***}$ & $-$61.326$^{***}$ \\
& (0.967) & (5.799) \\
& & \\
sold\_date & 0.402$^{***}$ & 4.715$^{***}$ \\
& (0.064) & (0.393) \\
& & \\
sewer\_typeseptic & $-$301.061 & $-$6,668.805$^{***}$ \\
& (239.413) & (1,439.610) \\
& & \\
sewer\_typeunspecified & 253.412$^{*}$ & $-$5,255.630$^{***}$ \\
& (130.716) & (783.803) \\
& & \\
property\_stylenot\_mobile & 2,165.925$^{***}$ & 68,929.910$^{***}$ \\
& (357.544) & (2,103.665) \\
& & \\
subdivision1 & 343.747$^{**}$ & 3,271.917$^{***}$ \\
& (152.920) & (918.202) \\
& & \\
water\_typewell & 391.734 & 3,009.829 \\
& (603.556) & (3,624.083) \\
& & \\
waterfront1 & $-$1,569.322$^{***}$ & 20,272.740$^{***}$ \\
& (226.139) & (1,351.216) \\
& & \\
age\_2 & & 18.014$^{***}$ \\
& & (0.831) \\
& & \\
area\_living\_2 & & 0.009$^{***}$ \\
& & (0.001) \\
& & \\
Constant & $-$16,871.450$^{*}$ & 121,905.200$^{**}$ \\
& (9,645.531) & (58,138.810) \\
& & \\
\hline \\[-1.8ex]
Observations & 24,653 & 24,653 \\
R$^{2}$ & 0.991 & 0.658 \\
Adjusted R$^{2}$ & 0.990 & 0.657 \\
Residual Std. Error (df = 24588) & 8,652.322 & 51,975.670 \\
F Statistic (df = 64; 24588) & 40,127.540$^{***}$ & 738.467$^{***}$ \\
\hline
\hline \\[-1.8ex]
\textit{Note:} & \multicolumn{2}{r}{$^{*}$p$<$0.1; $^{**}$p$<$0.05; $^{***}$p$<$0.01} \\
\end{tabular}
\end{table}
# Waves of infection
ggplot(data_factor, aes(x = as.Date(sold_date), y = infections_3mma)) +
geom_point(color = "grey35") +
geom_smooth(linetype = "dashed", color = "gray46") +
theme_minimal() +
scale_x_date(limits = as.Date(c("2020-01-01", "2021-12-31"))) +
scale_y_continuous(limits = c(0,max(infections_3mma))) +
xlab(" ") +
ylab("Confirmed Infections per Day") +
labs(title = "Waves of Infection",
caption = "") +
geom_vline(xintercept = as.numeric(as.Date("2020-03-23")), linetype=4)
`geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
Warning: Removed 17871 rows containing non-finite values (stat_smooth).
Warning: Removed 17871 rows containing missing values (geom_point).
Warning: Removed 3 rows containing missing values (geom_smooth).
# Accumulation of infections
ggplot(data_factor, aes(x = as.Date(sold_date), y = I(infections_accum/1000))) +
geom_point(color = "grey35") +
geom_smooth(linetype = "dashed", color = "gray46") +
theme_minimal() +
scale_x_date(limits = as.Date(c("2020-01-01", "2021-12-31"))) +
scale_y_continuous(limits = c(0,max(I(infections_accum/1000)))) +
xlab(" ") +
ylab("Accumulation of Infections (in 000's") +
labs(title = "Accumulation of Infections",
caption = "")
`geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
Warning: Removed 17871 rows containing non-finite values (stat_smooth).
Warning: Removed 17871 rows containing missing values (geom_point).
Warning: Removed 3 rows containing missing values (geom_smooth).
# Infections and home prices
ggplot(data_factor, aes(x = I(infections_3mma/1000), y = sold_price)) +
#geom_point() +
geom_smooth(linetype = "dashed", color = "gray46") +
theme_minimal() +
scale_x_continuous( limits = c(0,max(I(infections_3mma/1000)))) +
xlab("3-Month Moving Average of Daily Infections (in 000's)") +
ylab("Sold Price (Actual)") +
labs(title = "Infections and Price",
caption = "")
`geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
#Price on Infections
ggplot(data_factor, aes(x = infections_period, y = sold_price, fill = infections_period)) +
geom_violin(alpha = 0.5) +
geom_boxplot(width=0.1) +
scale_fill_viridis(discrete = TRUE, alpha=0.6, option="D") +
coord_flip() +
theme_ipsum() +
theme(
legend.position="none",
plot.title = element_text(size=11)) +
ggtitle("Comparison of Sold Price") +
xlab("Infections Present (1 = yes)") +
scale_fill_manual(values=c("#ff6c67", "#00c2c6"))
Scale for 'fill' is already present. Adding another scale for 'fill', which will replace the existing scale.
# Testing Corona
lm_corona <- lm(sold_price ~ infections_3mma + .
,data = data_factor_core_clean)
summ(lm_corona)
MODEL INFO:
Observations: 24653 (19 missing obs. deleted)
Dependent Variable: sold_price
Type: OLS linear regression
MODEL FIT:
F(65,24587) = 740.89, p = 0.00
R² = 0.66
Adj. R² = 0.66
Standard errors: OLS
---------------------------------------------------------------------------
Est. S.E. t val. p
----------------------------------- ------------ ---------- -------- ------
(Intercept) 180768.74 57877.60 3.12 0.00
infections_3mma 9.67 0.55 17.53 0.00
property_typeDUP -51453.66 17405.89 -2.96 0.00
property_typeOTH 24615.51 12134.43 2.03 0.04
property_typePAT 16034.82 5606.46 2.86 0.00
property_typeSGL 22833.72 2625.02 8.70 0.00
property_typeTNH -3147.82 3330.86 -0.95 0.34
ac_typenone -45777.67 2288.13 -20.01 0.00
ac_typenot_central -13751.04 1482.97 -9.27 0.00
patio1 8117.83 761.13 10.67 0.00
school_general1 11371.01 979.63 11.61 0.00
photo_count 914.55 45.30 20.19 0.00
pool1 12939.44 1265.41 10.23 0.00
roof_typeother 3779.46 1402.59 2.69 0.01
roof_typeshingle 21166.81 1574.80 13.44 0.00
roof_typeslate 10025.75 6701.58 1.50 0.13
gas_typenatural -92572.23 51731.25 -1.79 0.07
gas_typenone -132478.82 51704.70 -2.56 0.01
gas_typepropane -105428.20 52920.81 -1.99 0.05
gas_typeunknown -137409.67 51698.24 -2.66 0.01
out_building1 -6076.37 823.42 -7.38 0.00
area_living 32.44 5.46 5.94 0.00
land_acres 2615.42 924.61 2.83 0.00
appliances1 24679.44 1030.47 23.95 0.00
garage1 11973.79 755.72 15.84 0.00
property_conditionnew -24640.48 4675.26 -5.27 0.00
property_conditionother -20596.44 1010.59 -20.38 0.00
energy_efficient1 14040.15 847.28 16.57 0.00
exterior_typemetal -37.33 2429.54 -0.02 0.99
exterior_typeother 11897.19 1007.73 11.81 0.00
exterior_typevinyl 5135.53 1122.19 4.58 0.00
exterior_typewood 3742.67 1586.37 2.36 0.02
exterior_featurescourtyard 34564.32 8523.08 4.06 0.00
exterior_featuresfence -32068.35 3626.83 -8.84 0.00
exterior_featuresnone -25089.98 3636.93 -6.90 0.00
exterior_featuresporch -32085.30 3718.60 -8.63 0.00
exterior_featurestennis_court -425.91 10424.65 -0.04 0.97
fireplace1 11695.55 792.13 14.76 0.00
foundation_typeslab 14759.89 1150.00 12.83 0.00
foundation_typeunspecified 8375.81 1382.82 6.06 0.00
beds_total1 -28431.74 19252.36 -1.48 0.14
beds_total2 -37258.25 19092.77 -1.95 0.05
beds_total3 -43522.59 19132.21 -2.27 0.02
beds_total4 -41182.09 19164.64 -2.15 0.03
beds_total5 -59183.00 19468.00 -3.04 0.00
bath_full1 -31961.75 20362.52 -1.57 0.12
bath_full2 -6980.82 20351.01 -0.34 0.73
bath_full3 19902.15 20411.88 0.98 0.33
bath_full4 22788.02 22563.01 1.01 0.31
bath_full6 20194.81 55765.74 0.36 0.72
bath_half1 14105.18 998.23 14.13 0.00
bath_half2 38562.72 6450.29 5.98 0.00
bath_half3 59379.75 36556.86 1.62 0.10
bath_half4 73612.69 51732.57 1.42 0.15
bath_half5 -61754.65 29897.51 -2.07 0.04
age -2017.22 65.30 -30.89 0.00
dom -61.39 5.76 -10.65 0.00
sold_date 0.50 0.46 1.08 0.28
sewer_typeseptic -6656.23 1430.73 -4.65 0.00
sewer_typeunspecified -5363.79 778.99 -6.89 0.00
property_stylenot_mobile 68394.40 2090.91 32.71 0.00
subdivision1 3395.40 912.56 3.72 0.00
water_typewell 1157.24 3603.27 0.32 0.75
waterfront1 20298.31 1342.88 15.12 0.00
age_2 18.30 0.83 22.16 0.00
area_living_2 0.01 0.00 6.16 0.00
---------------------------------------------------------------------------
coeftest(lm_corona, vcov = vcovHC(lm_corona, method = "White2", type = "HC0"))
t test of coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.8077e+05 3.3119e+04 5.4582 4.857e-08 ***
infections_3mma 9.6711e+00 5.7357e-01 16.8612 < 2.2e-16 ***
property_typeDUP -5.1454e+04 1.5523e+04 -3.3148 0.0009185 ***
property_typeOTH 2.4616e+04 1.4812e+04 1.6618 0.0965596 .
property_typePAT 1.6035e+04 5.5605e+03 2.8837 0.0039340 **
property_typeSGL 2.2834e+04 2.7157e+03 8.4081 < 2.2e-16 ***
property_typeTNH -3.1478e+03 3.3429e+03 -0.9416 0.3463877
ac_typenone -4.5778e+04 1.9684e+03 -23.2561 < 2.2e-16 ***
ac_typenot_central -1.3751e+04 1.5990e+03 -8.5998 < 2.2e-16 ***
patio1 8.1178e+03 7.7805e+02 10.4335 < 2.2e-16 ***
school_general1 1.1371e+04 1.0385e+03 10.9496 < 2.2e-16 ***
photo_count 9.1455e+02 4.8880e+01 18.7103 < 2.2e-16 ***
pool1 1.2939e+04 1.4018e+03 9.2307 < 2.2e-16 ***
roof_typeother 3.7795e+03 1.4476e+03 2.6109 0.0090365 **
roof_typeshingle 2.1167e+04 1.6503e+03 12.8259 < 2.2e-16 ***
roof_typeslate 1.0026e+04 9.8722e+03 1.0156 0.3098516
gas_typenatural -9.2572e+04 3.6053e+03 -25.6768 < 2.2e-16 ***
gas_typenone -1.3248e+05 2.4622e+03 -53.8049 < 2.2e-16 ***
gas_typepropane -1.0543e+05 1.8139e+04 -5.8123 6.237e-09 ***
gas_typeunknown -1.3741e+05 2.3502e+03 -58.4673 < 2.2e-16 ***
out_building1 -6.0764e+03 8.2748e+02 -7.3432 2.150e-13 ***
area_living 3.2442e+01 6.1755e+00 5.2533 1.506e-07 ***
land_acres 2.6154e+03 9.3633e+02 2.7933 0.0052217 **
appliances1 2.4679e+04 1.1339e+03 21.7658 < 2.2e-16 ***
garage1 1.1974e+04 7.7362e+02 15.4777 < 2.2e-16 ***
property_conditionnew -2.4640e+04 6.4509e+03 -3.8197 0.0001340 ***
property_conditionother -2.0596e+04 9.4498e+02 -21.7957 < 2.2e-16 ***
energy_efficient1 1.4040e+04 8.4263e+02 16.6623 < 2.2e-16 ***
exterior_typemetal -3.7329e+01 2.3648e+03 -0.0158 0.9874058
exterior_typeother 1.1897e+04 1.0773e+03 11.0436 < 2.2e-16 ***
exterior_typevinyl 5.1355e+03 1.1145e+03 4.6080 4.086e-06 ***
exterior_typewood 3.7427e+03 1.7848e+03 2.0970 0.0360022 *
exterior_featurescourtyard 3.4564e+04 1.4123e+04 2.4474 0.0143969 *
exterior_featuresfence -3.2068e+04 5.3581e+03 -5.9850 2.194e-09 ***
exterior_featuresnone -2.5090e+04 5.3651e+03 -4.6766 2.933e-06 ***
exterior_featuresporch -3.2085e+04 5.4215e+03 -5.9182 3.299e-09 ***
exterior_featurestennis_court -4.2591e+02 1.0542e+04 -0.0404 0.9677739
fireplace1 1.1696e+04 8.3445e+02 14.0158 < 2.2e-16 ***
foundation_typeslab 1.4760e+04 1.2931e+03 11.4146 < 2.2e-16 ***
foundation_typeunspecified 8.3758e+03 1.4303e+03 5.8559 4.806e-09 ***
beds_total1 -2.8432e+04 2.5251e+04 -1.1260 0.2601957
beds_total2 -3.7258e+04 2.5163e+04 -1.4807 0.1387039
beds_total3 -4.3523e+04 2.5227e+04 -1.7253 0.0844946 .
beds_total4 -4.1182e+04 2.5265e+04 -1.6300 0.1031127
beds_total5 -5.9183e+04 2.5704e+04 -2.3025 0.0213170 *
bath_full1 -3.1962e+04 2.4096e+04 -1.3264 0.1847120
bath_full2 -6.9808e+03 2.4086e+04 -0.2898 0.7719459
bath_full3 1.9902e+04 2.4179e+04 0.8231 0.4104509
bath_full4 2.2788e+04 3.0301e+04 0.7521 0.4520199
bath_full6 2.0195e+04 2.4906e+04 0.8108 0.4174683
bath_half1 1.4105e+04 1.1369e+03 12.4062 < 2.2e-16 ***
bath_half2 3.8563e+04 7.8980e+03 4.8826 1.054e-06 ***
bath_half3 5.9380e+04 1.0913e+04 5.4414 5.336e-08 ***
bath_half4 7.3613e+04 3.2038e+03 22.9767 < 2.2e-16 ***
bath_half5 -6.1755e+04 2.7625e+04 -2.2355 0.0253948 *
age -2.0172e+03 8.4747e+01 -23.8030 < 2.2e-16 ***
dom -6.1395e+01 5.7883e+00 -10.6067 < 2.2e-16 ***
sold_date 4.9735e-01 4.7529e-01 1.0464 0.2953845
sewer_typeseptic -6.6562e+03 1.4638e+03 -4.5472 5.463e-06 ***
sewer_typeunspecified -5.3638e+03 7.5612e+02 -7.0938 1.340e-12 ***
property_stylenot_mobile 6.8394e+04 1.7615e+03 38.8270 < 2.2e-16 ***
subdivision1 3.3954e+03 9.2014e+02 3.6901 0.0002247 ***
water_typewell 1.1572e+03 4.0744e+03 0.2840 0.7763914
waterfront1 2.0298e+04 1.5074e+03 13.4654 < 2.2e-16 ***
age_2 1.8303e+01 1.1918e+00 15.3579 < 2.2e-16 ***
area_living_2 8.9354e-03 1.7703e-03 5.0473 4.512e-07 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# Visualizing marginal effect per positive tests on price
lm_corona_single <- lm(sold_price ~ infections_3mma
,data = data_factor_core_clean)
summ(lm_corona_single)
MODEL INFO:
Observations: 24672
Dependent Variable: sold_price
Type: OLS linear regression
MODEL FIT:
F(1,24670) = 1003.58, p = 0.00
R² = 0.04
Adj. R² = 0.04
Standard errors: OLS
----------------------------------------------------------
Est. S.E. t val. p
--------------------- ----------- -------- -------- ------
(Intercept) 162738.68 618.07 263.30 0.00
infections_3mma 21.53 0.68 31.68 0.00
----------------------------------------------------------
ggpredict_1 <- ggpredict(lm_corona, terms = "infections_3mma")
ggpredict_2 <- ggpredict(lm_corona_single, terms = "infections_3mma")
# Plots
ggplot(data_factor_core, aes(x = infections_3mma)) +
geom_smooth(data_factor_core, mapping = aes(y = sold_price), color = "grey50") + # Actual Data
geom_smooth(ggpredict_1, mapping = aes(x, predicted), linetype = "dashed", color = "darkred") + # Controlled model
geom_smooth(ggpredict_2, mapping = aes(x, predicted), linetype = "dashed", color = "darkblue") + # Best single fit
ggtitle("Model Fit Overview")
`geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula 'y ~ x'
`geom_smooth()` using method = 'loess' and formula 'y ~ x'
# Predicting infections with house prices
lm_flip <- lm_flip <- lm(infections_3mma ~ sold_price, data = data_factor)
summ(lm_flip)
MODEL INFO:
Observations: 24672
Dependent Variable: infections_3mma
Type: OLS linear regression
MODEL FIT:
F(1,24670) = 1003.58, p = 0.00
R² = 0.04
Adj. R² = 0.04
Standard errors: OLS
-------------------------------------------------
Est. S.E. t val. p
----------------- ------- ------- -------- ------
(Intercept) 92.28 11.06 8.34 0.00
sold_price 0.00 0.00 31.68 0.00
-------------------------------------------------
ggpredict_flip <- ggpredict(lm_flip, terms = "sold_price")
ggplot(data_factor, aes(x = sold_price)) +
geom_smooth(data_factor, mapping = aes(y = infections_3mma), color = "grey50") +
geom_smooth(ggpredict_flip, mapping = aes(x, predicted), linetype = "dashed", color = "darkred") +
labs(title = "Flipped Regression", subtitle = "Explining Infections using Variations in Price",
caption = "")
`geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula 'y ~ x'
# ----------------------------------------
# Distribution
# Find the mean of each group
library(plyr)
data_factor$beds_total <- as.numeric(data_factor$beds_total)
room_mean <- ddply(data_factor, "infections_period", summarise, beds_mean=mean(beds_total, na.rm = TRUE))
ggplot(data_factor, aes(x=beds_total, fill = infections_period, color = infections_period)) +
geom_density(alpha = 0.5, position = "identity") +
labs(title = "Distibution of Number of Bedrooms") +
geom_vline(data=room_mean, aes(xintercept = room_mean[2,2]), linetype="dashed", size= 0.4, color = "darkblue", alpha = 0.5) +
geom_vline(data=room_mean, aes(xintercept = room_mean[1,2]), linetype="dashed", size= 0.4, alpha = 0.5)
# Distribution of total price and number of beds
data_factor$beds_total <- as.factor(data_factor$beds_total)
ggplot(data = subset(data_factor, !is.na(beds_total)), aes(x = beds_total, y = sold_price, fill = beds_total)) +
geom_violin(alpha = 0.5) +
geom_boxplot(width=0.1) +
scale_fill_viridis(discrete = TRUE, alpha=0.6, option="D") +
#coord_flip() +
theme_ipsum() +
theme(
legend.position="none",
plot.title = element_text(size=11)) +
labs(title = "Distribution of Sold Price and Bedrooms", subtitle = "",
caption = "") +
xlab("Number of Bedrooms")
# Distribution of price and number of beds before and after corona period
ggplot(data = subset(data_factor, !is.na(beds_total)), aes(x = beds_total, y = sold_price, fill = beds_total)) +
geom_violin(data = subset(data_factor, !is.na(beds_total)), mapping = aes(alpha = 0.5, fill = infections_period)) +
geom_boxplot(width=0.1) +
scale_fill_viridis(discrete = TRUE, alpha=0.6, option="D") +
#coord_flip() +
theme_ipsum() +
theme(
legend.position="none",
plot.title = element_text(size=11)) +
labs( title = "Distribution of Sold Price and Bedrooms", subtitle = "Sold Price Per Square Foot Pre vs. Post Infection Period",
caption = "") +
xlab("Number of Bedrooms")
# Distribution of price per sqft. and number of beds
data_factor$beds_total <- as.factor(data_factor$beds_total)
ggplot(data = subset(data_factor, !is.na(beds_total)), aes(x = beds_total, y = sold_price/area_living, fill = beds_total)) +
geom_violin(alpha = 0.5) +
geom_boxplot(width=0.1) +
scale_fill_viridis(discrete = TRUE, alpha=0.6, option="D") +
#coord_flip() +
theme_ipsum() +
theme(
legend.position="none",
plot.title = element_text(size=11)) +
labs( title = "Distribution of Sold Price and Bedrooms", subtitle = "Sold Price Per Square Foot",
caption = "") +
xlab("Number of Bedrooms")
# Distribution of price per sqft. and number of beds before and after corona period
ggplot(data = subset(data_factor, !is.na(beds_total)), aes(x = beds_total, y = sold_price/area_living , fill = beds_total)) +
geom_violin(data = subset(data_factor, !is.na(beds_total)), mapping = aes(alpha = 0.5, fill = infections_period)) +
geom_boxplot(width=0.1) +
scale_fill_viridis(discrete = TRUE, alpha=0.6, option="D") +
#coord_flip() +
theme_ipsum() +
theme(
legend.position="none",
plot.title = element_text(size=11)) +
labs( title = "Distribution of Sold Price and Bedrooms", subtitle = "Sold Price Per Square Foot Pre vs. Post Infection Period",
caption = "") +
xlab("Number of Bedrooms")
Ideas
# Note on bedroom's relationship with all other size-related features:
# - The interpretation of the coefficient is dependent on the other fixed size features, especially area_living. In the case that total area is fixed, the interpretation of this coefficient become the effect of more bedrooms for a fixed size. No one wants a 500 sqft. house with 8 bedrooms.
# - For this reason, when analyzing changes in bedrooms, total size is excluded
# Change data structure to factor
data_factor_core_clean$beds_total <- as.factor(data_factor_core_clean$beds_total)
# Single Model: Factor
lm_corona_bedrooms_single <- lm(sold_price ~ + beds_total ,data = data_factor_core_clean)
summ(lm_corona_bedrooms_single)
MODEL INFO:
Observations: 24655 (17 missing obs. deleted)
Dependent Variable: sold_price
Type: OLS linear regression
MODEL FIT:
F(5,24649) = 998.17, p = 0.00
R² = 0.17
Adj. R² = 0.17
Standard errors: OLS
--------------------------------------------------------
Est. S.E. t val. p
----------------- ----------- ---------- -------- ------
(Intercept) 107050.00 28611.08 3.74 0.00
beds_total1 -15727.00 29067.06 -0.54 0.59
beds_total2 1484.15 28652.92 0.05 0.96
beds_total3 56568.93 28618.08 1.98 0.05
beds_total4 124635.87 28633.57 4.35 0.00
beds_total5 122396.70 29104.41 4.21 0.00
--------------------------------------------------------
coeftest(lm_corona_bedrooms_single, vcov = vcovHC(lm_corona_bedrooms_single, method = "White2", type = "HC0"))
t test of coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 107050.0 23281.1 4.5981 4.284e-06 ***
beds_total1 -15727.0 23657.4 -0.6648 0.50620
beds_total2 1484.1 23319.7 0.0636 0.94925
beds_total3 56568.9 23288.8 2.4290 0.01515 *
beds_total4 124635.9 23321.2 5.3443 9.157e-08 ***
beds_total5 122396.7 24457.6 5.0044 5.641e-07 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# Basic Test: Few Controls
lm_corona_bedrooms_basic <- lm(sold_price ~
+ data_factor$infections_3mma + beds_total + data_factor$infections_3mma*beds_total
# Removals
- area_living
- area_living_2
- bath_full
- bath_half
- land_acres
- sold_date
- garage
- property_type
,data = data_factor_core_clean)
summ(lm_corona_bedrooms_basic)
MODEL INFO:
Observations: 24653 (19 missing obs. deleted)
Dependent Variable: sold_price
Type: OLS linear regression
MODEL FIT:
F(11,24641) = 586.89, p = 0.00
R² = 0.21
Adj. R² = 0.21
Standard errors: OLS
------------------------------------------------------------------------------------
Est. S.E. t val. p
--------------------------------------------- ----------- ---------- -------- ------
(Intercept) 100535.26 36052.94 2.79 0.01
data_factor$infections_3mma 6.57 22.98 0.29 0.78
beds_total1 -20928.46 36521.79 -0.57 0.57
beds_total2 1294.48 36092.89 0.04 0.97
beds_total3 54725.57 36059.48 1.52 0.13
beds_total4 120869.29 36074.42 3.35 0.00
beds_total5 115326.38 36546.21 3.16 0.00
data_factor$infections_3mma:beds_total1 13.32 23.53 0.57 0.57
data_factor$infections_3mma:beds_total2 8.96 23.05 0.39 0.70
data_factor$infections_3mma:beds_total3 15.03 22.99 0.65 0.51
data_factor$infections_3mma:beds_total4 17.53 23.02 0.76 0.45
data_factor$infections_3mma:beds_total5 20.62 23.72 0.87 0.38
------------------------------------------------------------------------------------
coeftest(lm_corona_bedrooms_basic, vcov = vcovHC(lm_corona_bedrooms_basic, method = "White2", type = "HC0"))
t test of coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 100535.2613 37001.0832 2.7171 0.006590 **
data_factor$infections_3mma 6.5668 15.4170 0.4259 0.670152
beds_total1 -20928.4594 37179.1743 -0.5629 0.573503
beds_total2 1294.4818 37026.6809 0.0350 0.972111
beds_total3 54725.5657 37006.4876 1.4788 0.139204
beds_total4 120869.2879 37031.9892 3.2639 0.001100 **
beds_total5 115326.3773 37924.3384 3.0410 0.002361 **
data_factor$infections_3mma:beds_total1 13.3210 16.1197 0.8264 0.408597
data_factor$infections_3mma:beds_total2 8.9620 15.5089 0.5779 0.563362
data_factor$infections_3mma:beds_total3 15.0285 15.4355 0.9736 0.330249
data_factor$infections_3mma:beds_total4 17.5256 15.4914 1.1313 0.257933
data_factor$infections_3mma:beds_total5 20.6195 17.5485 1.1750 0.240005
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# General Model: Controlled
lm_corona_bedrooms <- lm(sold_price ~ . +
# test variable(s)
+ data_factor$infections_3mma + beds_total + data_factor$infections_3mma*beds_total
# Removals
- area_living
- area_living_2
- bath_full
- bath_half
- land_acres
- sold_date
- garage
- property_type
,data = data_factor_core_clean)
summ(lm_corona_bedrooms)
MODEL INFO:
Observations: 24653 (19 missing obs. deleted)
Dependent Variable: sold_price
Type: OLS linear regression
MODEL FIT:
F(50,24602) = 629.36, p = 0.00
R² = 0.56
Adj. R² = 0.56
Standard errors: OLS
-------------------------------------------------------------------------------------
Est. S.E. t val. p
--------------------------------------------- ------------ ---------- -------- ------
(Intercept) 247764.21 64935.31 3.82 0.00
ac_typenone -56116.33 2590.77 -21.66 0.00
ac_typenot_central -21395.87 1667.46 -12.83 0.00
patio1 12549.71 858.45 14.62 0.00
school_general1 9579.29 1087.92 8.81 0.00
photo_count 1316.37 48.08 27.38 0.00
pool1 21208.14 1412.87 15.01 0.00
roof_typeother 7796.67 1588.67 4.91 0.00
roof_typeshingle 28462.42 1778.69 16.00 0.00
roof_typeslate 18896.15 7629.10 2.48 0.01
gas_typenatural -101066.72 58912.32 -1.72 0.09
gas_typenone -142020.02 58882.22 -2.41 0.02
gas_typepropane -99808.81 60267.42 -1.66 0.10
gas_typeunknown -141624.52 58874.38 -2.41 0.02
out_building1 -5825.79 928.21 -6.28 0.00
appliances1 25486.45 1166.68 21.85 0.00
property_conditionnew -23228.18 5302.89 -4.38 0.00
property_conditionother -21236.05 1143.74 -18.57 0.00
energy_efficient1 19237.22 947.15 20.31 0.00
exterior_typemetal -3946.36 2764.55 -1.43 0.15
exterior_typeother 14493.88 1145.65 12.65 0.00
exterior_typevinyl 3232.82 1274.78 2.54 0.01
exterior_typewood 2105.97 1795.90 1.17 0.24
exterior_featurescourtyard 37098.74 9714.57 3.82 0.00
exterior_featuresfence -32078.45 3979.45 -8.06 0.00
exterior_featuresnone -22203.96 4002.57 -5.55 0.00
exterior_featuresporch -28729.61 4105.49 -7.00 0.00
exterior_featurestennis_court 12094.32 11802.38 1.02 0.31
fireplace1 32916.73 843.72 39.01 0.00
foundation_typeslab 20096.51 1289.62 15.58 0.00
foundation_typeunspecified 9388.20 1565.80 6.00 0.00
beds_total1 -69914.30 27269.92 -2.56 0.01
beds_total2 -50169.24 26952.93 -1.86 0.06
beds_total3 -24160.71 26936.87 -0.90 0.37
beds_total4 17109.47 26949.94 0.63 0.53
beds_total5 26765.81 27300.44 0.98 0.33
age -2284.00 71.72 -31.85 0.00
dom -35.79 6.44 -5.56 0.00
sewer_typeseptic -4872.44 1605.94 -3.03 0.00
sewer_typeunspecified -5167.55 869.33 -5.94 0.00
property_stylenot_mobile 73419.27 2345.93 31.30 0.00
subdivision1 2409.66 1036.00 2.33 0.02
water_typewell -1726.95 4095.50 -0.42 0.67
waterfront1 29108.03 1521.32 19.13 0.00
age_2 20.72 0.91 22.66 0.00
data_factor$infections_3mma -27.00 17.19 -1.57 0.12
beds_total1:data_factor$infections_3mma 23.29 17.57 1.33 0.19
beds_total2:data_factor$infections_3mma 31.47 17.24 1.83 0.07
beds_total3:data_factor$infections_3mma 35.90 17.20 2.09 0.04
beds_total4:data_factor$infections_3mma 36.76 17.22 2.13 0.03
beds_total5:data_factor$infections_3mma 45.99 17.75 2.59 0.01
-------------------------------------------------------------------------------------
coeftest(lm_corona_bedrooms, vcov = vcovHC(lm_corona_bedrooms, method = "White2", type = "HC0"))
t test of coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 2.4776e+05 2.9950e+04 8.2726 < 2.2e-16 ***
ac_typenone -5.6116e+04 1.9719e+03 -28.4581 < 2.2e-16 ***
ac_typenot_central -2.1396e+04 1.7984e+03 -11.8972 < 2.2e-16 ***
patio1 1.2550e+04 8.6935e+02 14.4358 < 2.2e-16 ***
school_general1 9.5793e+03 1.1390e+03 8.4102 < 2.2e-16 ***
photo_count 1.3164e+03 5.2185e+01 25.2250 < 2.2e-16 ***
pool1 2.1208e+04 1.5874e+03 13.3605 < 2.2e-16 ***
roof_typeother 7.7967e+03 1.5121e+03 5.1561 2.541e-07 ***
roof_typeshingle 2.8462e+04 1.7549e+03 16.2185 < 2.2e-16 ***
roof_typeslate 1.8896e+04 9.9617e+03 1.8969 0.0578545 .
gas_typenatural -1.0107e+05 3.6709e+03 -27.5316 < 2.2e-16 ***
gas_typenone -1.4202e+05 2.3211e+03 -61.1860 < 2.2e-16 ***
gas_typepropane -9.9809e+04 1.8136e+04 -5.5034 3.763e-08 ***
gas_typeunknown -1.4162e+05 2.1590e+03 -65.5982 < 2.2e-16 ***
out_building1 -5.8258e+03 9.2193e+02 -6.3192 2.675e-10 ***
appliances1 2.5486e+04 1.2330e+03 20.6704 < 2.2e-16 ***
property_conditionnew -2.3228e+04 6.7244e+03 -3.4543 0.0005527 ***
property_conditionother -2.1236e+04 1.0801e+03 -19.6609 < 2.2e-16 ***
energy_efficient1 1.9237e+04 9.2813e+02 20.7269 < 2.2e-16 ***
exterior_typemetal -3.9464e+03 2.5047e+03 -1.5756 0.1151323
exterior_typeother 1.4494e+04 1.2073e+03 12.0049 < 2.2e-16 ***
exterior_typevinyl 3.2328e+03 1.2554e+03 2.5751 0.0100260 *
exterior_typewood 2.1060e+03 1.9850e+03 1.0609 0.2887255
exterior_featurescourtyard 3.7099e+04 1.4742e+04 2.5166 0.0118550 *
exterior_featuresfence -3.2078e+04 5.9856e+03 -5.3593 8.430e-08 ***
exterior_featuresnone -2.2204e+04 5.9969e+03 -3.7026 0.0002139 ***
exterior_featuresporch -2.8730e+04 6.0661e+03 -4.7361 2.191e-06 ***
exterior_featurestennis_court 1.2094e+04 1.3905e+04 0.8698 0.3844197
fireplace1 3.2917e+04 8.6870e+02 37.8919 < 2.2e-16 ***
foundation_typeslab 2.0097e+04 1.3612e+03 14.7636 < 2.2e-16 ***
foundation_typeunspecified 9.3882e+03 1.5132e+03 6.2042 5.587e-10 ***
beds_total1 -6.9914e+04 2.9402e+04 -2.3779 0.0174185 *
beds_total2 -5.0169e+04 2.9144e+04 -1.7214 0.0851827 .
beds_total3 -2.4161e+04 2.9143e+04 -0.8291 0.4070831
beds_total4 1.7109e+04 2.9166e+04 0.5866 0.5574625
beds_total5 2.6766e+04 2.9743e+04 0.8999 0.3681774
age -2.2840e+03 8.5578e+01 -26.6889 < 2.2e-16 ***
dom -3.5794e+01 6.3773e+00 -5.6128 2.012e-08 ***
sewer_typeseptic -4.8724e+03 1.5741e+03 -3.0955 0.0019673 **
sewer_typeunspecified -5.1675e+03 8.4585e+02 -6.1093 1.016e-09 ***
property_stylenot_mobile 7.3419e+04 1.8556e+03 39.5664 < 2.2e-16 ***
subdivision1 2.4097e+03 1.0162e+03 2.3712 0.0177365 *
water_typewell -1.7269e+03 4.7569e+03 -0.3630 0.7165787
waterfront1 2.9108e+04 1.7101e+03 17.0217 < 2.2e-16 ***
age_2 2.0720e+01 1.1683e+00 17.7342 < 2.2e-16 ***
data_factor$infections_3mma -2.7000e+01 1.5318e+01 -1.7626 0.0779746 .
beds_total1:data_factor$infections_3mma 2.3287e+01 1.5739e+01 1.4796 0.1390006
beds_total2:data_factor$infections_3mma 3.1473e+01 1.5368e+01 2.0480 0.0405680 *
beds_total3:data_factor$infections_3mma 3.5902e+01 1.5330e+01 2.3420 0.0191906 *
beds_total4:data_factor$infections_3mma 3.6758e+01 1.5373e+01 2.3911 0.0168045 *
beds_total5:data_factor$infections_3mma 4.5991e+01 1.6466e+01 2.7931 0.0052244 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# Find the mean of each group
library(plyr)
price_means <- ddply(data_factor, "infections_period", summarise, price_mean = mean(sold_price, na.rm = TRUE))
# Distribution: Total
ggplot(data_factor, aes(x = sold_price)) +
geom_density(alpha = 0.5, position = "identity", fill = "#ff6c67") +
ggtitle("Price Distributions") +
geom_vline(data=price_means, aes(xintercept = mean(sold_price)), linetype="dashed", size= 0.4, color = "#ff6c67", alpha = 0.8)
# Distribution: Infection
ggplot(data_factor, aes(x = sold_price, fill = infections_period)) +
geom_density(alpha = 0.5, position = "identity") +
ggtitle("Price Distributions") +
geom_vline(data=price_means, aes(xintercept = price_means[2,2]), linetype="dashed", size= 0.4, color = "#00c2c6", alpha = 0.8) +
geom_vline(data = price_means, aes(xintercept = price_means[1,2]), linetype="dashed", size= 0.4, color = "#ff6c67", alpha = 0.8)
# Distribution: Top vs. Bottom
ggplot(data_factor) +
geom_density(aes(x = sold_price, fill = infections_period), alpha = 0.5, position = "identity") +
facet_grid(vars(top25_sold_price, bottom25_sold_price), scales = "free") +
ggtitle("Price Distributions")
#Price and Infections
ggplot(data_factor, aes(x = infections_period, y = sold_price, fill = infections_period)) +
geom_violin(alpha = 0.5) +
geom_boxplot(width=0.1) +
scale_fill_viridis(discrete = TRUE, alpha=0.6, option="D") +
coord_flip() +
theme_ipsum() +
theme(
legend.position="none",
plot.title = element_text(size=11)) +
ggtitle("Comparison of Sold Price") +
xlab("Infections Present (1 = yes)") +
scale_fill_manual(values=c("#ff6c67", "#00c2c6"))
Scale for 'fill' is already present. Adding another scale for 'fill', which will replace the existing scale.
# Testing Corona, top 25% in price ---------------------------------------------------------------------
# Single Var Test
lm_corona_price_top_single <- lm(sold_price ~ +
# test variable(s)
+ top25_sold_price
# Removals
,data = data_factor)
summ(lm_corona_price_top_single)
MODEL INFO:
Observations: 24672
Dependent Variable: sold_price
Type: OLS linear regression
MODEL FIT:
F(1,24670) = 31477.66, p = 0.00
R² = 0.56
Adj. R² = 0.56
Standard errors: OLS
------------------------------------------------------------
Est. S.E. t val. p
----------------------- ----------- -------- -------- ------
(Intercept) 137610.40 420.25 327.45 0.00
top25_sold_price1 164397.16 926.60 177.42 0.00
------------------------------------------------------------
coeftest(lm_corona_price_top_single, vcov = vcovHC(lm_corona_price_top_single, method = "White2", type = "HC0"))
t test of coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 137610.40 428.11 321.44 < 2.2e-16 ***
top25_sold_price1 164397.16 874.97 187.89 < 2.2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# General Model: No Controls
lm_corona_price_top_basic <- lm(sold_price ~ +
# test variable(s)
+ data_factor$infections_3mma + top25_sold_price + data_factor$infections_3mma*top25_sold_price
# Removals
,data = data_factor)
summ(lm_corona_price_top_basic)
MODEL INFO:
Observations: 24672
Dependent Variable: sold_price
Type: OLS linear regression
MODEL FIT:
F(3,24668) = 10799.92, p = 0.00
R² = 0.57
Adj. R² = 0.57
Standard errors: OLS
-----------------------------------------------------------------------------------------
Est. S.E. t val. p
--------------------------------------------------- ----------- --------- -------- ------
(Intercept) 133983.36 457.01 293.17 0.00
data_factor$infections_3mma 10.73 0.55 19.36 0.00
top25_sold_price1 164952.94 1086.17 151.87 0.00
data_factor$infections_3mma:top25_sold_price1 -6.05 1.00 -6.04 0.00
-----------------------------------------------------------------------------------------
coeftest(lm_corona_price_top_basic, vcov = vcovHC(lm_corona_price_top_basic, method = "White2", type = "HC0"))
t test of coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.3398e+05 4.6647e+02 287.2295 < 2.2e-16 ***
data_factor$infections_3mma 1.0731e+01 5.4410e-01 19.7221 < 2.2e-16 ***
top25_sold_price1 1.6495e+05 9.9939e+02 165.0537 < 2.2e-16 ***
data_factor$infections_3mma:top25_sold_price1 -6.0513e+00 9.8084e-01 -6.1695 6.956e-10 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# General Model: With Controls
lm_corona_price_top <- lm(sold_price ~ . +
# test variable(s)
+ data_factor$infections_3mma + top25_sold_price + data_factor$infections_3mma*top25_sold_price
# Removals
,data = data_factor_core_clean)
summ(lm_corona_price_top)
MODEL INFO:
Observations: 24653 (19 missing obs. deleted)
Dependent Variable: sold_price
Type: OLS linear regression
MODEL FIT:
F(67,24585) = 1336.00, p = 0.00
R² = 0.78
Adj. R² = 0.78
Standard errors: OLS
-----------------------------------------------------------------------------------------
Est. S.E. t val. p
-------------------------------------------------- ----------- ---------- -------- ------
(Intercept) 107216.58 46220.13 2.32 0.02
property_typeDUP -48684.57 13898.28 -3.50 0.00
property_typeOTH 26543.73 9689.31 2.74 0.01
property_typePAT 8858.66 4478.66 1.98 0.05
property_typeSGL 12862.28 2098.58 6.13 0.00
property_typeTNH 2236.29 2660.12 0.84 0.40
ac_typenone -47065.15 1827.06 -25.76 0.00
ac_typenot_central -15054.06 1184.19 -12.71 0.00
patio1 6624.49 607.88 10.90 0.00
school_general1 8340.70 782.64 10.66 0.00
photo_count 610.11 36.27 16.82 0.00
pool1 6296.48 1011.97 6.22 0.00
roof_typeother 4375.45 1119.95 3.91 0.00
roof_typeshingle 15992.69 1258.21 12.71 0.00
roof_typeslate 11123.40 5351.12 2.08 0.04
gas_typenatural -59032.17 41307.81 -1.43 0.15
gas_typenone -78255.91 41289.43 -1.90 0.06
gas_typepropane -71885.40 42257.50 -1.70 0.09
gas_typeunknown -82689.07 41284.10 -2.00 0.05
out_building1 -1443.73 658.66 -2.19 0.03
area_living 41.04 4.36 9.40 0.00
land_acres 3793.78 738.74 5.14 0.00
appliances1 23153.32 823.03 28.13 0.00
garage1 8804.34 604.04 14.58 0.00
property_conditionnew -28097.40 3733.70 -7.53 0.00
property_conditionother -16135.48 808.56 -19.96 0.00
energy_efficient1 8707.55 678.06 12.84 0.00
exterior_typemetal -2048.83 1940.03 -1.06 0.29
exterior_typeother 6476.05 806.32 8.03 0.00
exterior_typevinyl 4478.13 896.29 5.00 0.00
exterior_typewood -55.09 1267.11 -0.04 0.97
exterior_featurescourtyard 25768.96 6806.67 3.79 0.00
exterior_featuresfence -19436.45 2898.07 -6.71 0.00
exterior_featuresnone -14426.24 2905.78 -4.96 0.00
exterior_featuresporch -19604.06 2971.51 -6.60 0.00
exterior_featurestennis_court -3035.97 8325.18 -0.36 0.72
fireplace1 5005.82 635.10 7.88 0.00
foundation_typeslab 16018.88 918.45 17.44 0.00
foundation_typeunspecified 9639.72 1104.26 8.73 0.00
beds_total1 -21761.56 15373.23 -1.42 0.16
beds_total2 -27537.70 15245.76 -1.81 0.07
beds_total3 -28172.90 15277.57 -1.84 0.07
beds_total4 -31839.33 15303.13 -2.08 0.04
beds_total5 -40013.28 15546.25 -2.57 0.01
bath_full1 -28461.10 16260.15 -1.75 0.08
bath_full2 -4668.16 16250.82 -0.29 0.77
bath_full3 7061.57 16299.40 0.43 0.66
bath_full4 28381.48 18016.69 1.58 0.12
bath_full6 18302.02 44527.88 0.41 0.68
bath_half1 3485.62 802.41 4.34 0.00
bath_half2 21749.43 5152.81 4.22 0.00
bath_half3 -11134.69 29197.82 -0.38 0.70
bath_half4 31389.15 41315.62 0.76 0.45
bath_half5 -61467.22 23872.75 -2.57 0.01
age -1264.98 52.61 -24.05 0.00
dom -40.25 4.61 -8.74 0.00
sold_date 0.62 0.37 1.68 0.09
sewer_typeseptic -3289.83 1142.76 -2.88 0.00
sewer_typeunspecified -1657.43 622.90 -2.66 0.01
property_stylenot_mobile 59348.70 1671.36 35.51 0.00
subdivision1 2074.48 728.84 2.85 0.00
water_typewell 1671.40 2877.15 0.58 0.56
waterfront1 9734.84 1076.00 9.05 0.00
age_2 11.98 0.66 18.09 0.00
area_living_2 -0.00 0.00 -0.81 0.42
data_factor$infections_3mma 8.02 0.50 16.20 0.00
top25_sold_price 103522.76 943.52 109.72 0.00
data_factor$infections_3mma:top25_sold_price -5.82 0.73 -8.03 0.00
-----------------------------------------------------------------------------------------
coeftest(lm_corona_price_top, vcov = vcovHC(lm_corona_price_top, method = "White2", type = "HC0"))
t test of coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.0722e+05 2.4009e+04 4.4657 8.015e-06 ***
property_typeDUP -4.8685e+04 1.3407e+04 -3.6312 0.0002827 ***
property_typeOTH 2.6544e+04 1.2041e+04 2.2044 0.0275072 *
property_typePAT 8.8587e+03 4.3912e+03 2.0174 0.0436682 *
property_typeSGL 1.2862e+04 2.0789e+03 6.1869 6.231e-10 ***
property_typeTNH 2.2363e+03 2.5365e+03 0.8816 0.3779845
ac_typenone -4.7065e+04 1.5710e+03 -29.9596 < 2.2e-16 ***
ac_typenot_central -1.5054e+04 1.3123e+03 -11.4717 < 2.2e-16 ***
patio1 6.6245e+03 6.0804e+02 10.8949 < 2.2e-16 ***
school_general1 8.3407e+03 8.2400e+02 10.1222 < 2.2e-16 ***
photo_count 6.1011e+02 3.7944e+01 16.0794 < 2.2e-16 ***
pool1 6.2965e+03 1.0849e+03 5.8039 6.558e-09 ***
roof_typeother 4.3755e+03 1.1287e+03 3.8765 0.0001063 ***
roof_typeshingle 1.5993e+04 1.2743e+03 12.5497 < 2.2e-16 ***
roof_typeslate 1.1123e+04 7.1439e+03 1.5570 0.1194715
gas_typenatural -5.9032e+04 2.8259e+03 -20.8897 < 2.2e-16 ***
gas_typenone -7.8256e+04 2.1036e+03 -37.2009 < 2.2e-16 ***
gas_typepropane -7.1885e+04 1.3177e+04 -5.4552 4.939e-08 ***
gas_typeunknown -8.2689e+04 2.0080e+03 -41.1795 < 2.2e-16 ***
out_building1 -1.4437e+03 6.5656e+02 -2.1989 0.0278932 *
area_living 4.1036e+01 4.8224e+00 8.5095 < 2.2e-16 ***
land_acres 3.7938e+03 7.5173e+02 5.0467 4.527e-07 ***
appliances1 2.3153e+04 9.3153e+02 24.8552 < 2.2e-16 ***
garage1 8.8043e+03 6.0963e+02 14.4422 < 2.2e-16 ***
property_conditionnew -2.8097e+04 5.3251e+03 -5.2764 1.329e-07 ***
property_conditionother -1.6135e+04 7.2672e+02 -22.2033 < 2.2e-16 ***
energy_efficient1 8.7075e+03 6.6653e+02 13.0640 < 2.2e-16 ***
exterior_typemetal -2.0488e+03 1.8753e+03 -1.0925 0.2746024
exterior_typeother 6.4760e+03 8.4834e+02 7.6338 2.363e-14 ***
exterior_typevinyl 4.4781e+03 8.8491e+02 5.0605 4.211e-07 ***
exterior_typewood -5.5087e+01 1.3964e+03 -0.0394 0.9685322
exterior_featurescourtyard 2.5769e+04 1.0056e+04 2.5626 0.0103944 *
exterior_featuresfence -1.9436e+04 3.9018e+03 -4.9815 6.353e-07 ***
exterior_featuresnone -1.4426e+04 3.9087e+03 -3.6908 0.0002240 ***
exterior_featuresporch -1.9604e+04 3.9585e+03 -4.9524 7.379e-07 ***
exterior_featurestennis_court -3.0360e+03 8.3598e+03 -0.3632 0.7164859
fireplace1 5.0058e+03 6.5468e+02 7.6462 2.145e-14 ***
foundation_typeslab 1.6019e+04 1.0139e+03 15.8000 < 2.2e-16 ***
foundation_typeunspecified 9.6397e+03 1.1647e+03 8.2764 < 2.2e-16 ***
beds_total1 -2.1762e+04 1.7365e+04 -1.2532 0.2101433
beds_total2 -2.7538e+04 1.7283e+04 -1.5934 0.1110913
beds_total3 -2.8173e+04 1.7327e+04 -1.6259 0.1039753
beds_total4 -3.1839e+04 1.7358e+04 -1.8343 0.0666245 .
beds_total5 -4.0013e+04 1.7722e+04 -2.2579 0.0239610 *
bath_full1 -2.8461e+04 1.7351e+04 -1.6403 0.1009602
bath_full2 -4.6682e+03 1.7345e+04 -0.2691 0.7878296
bath_full3 7.0616e+03 1.7410e+04 0.4056 0.6850411
bath_full4 2.8381e+04 2.1906e+04 1.2956 0.1951208
bath_full6 1.8302e+04 1.8035e+04 1.0148 0.3102081
bath_half1 3.4856e+03 8.6324e+02 4.0379 5.411e-05 ***
bath_half2 2.1749e+04 5.9162e+03 3.6762 0.0002372 ***
bath_half3 -1.1135e+04 3.5830e+03 -3.1076 0.0018881 **
bath_half4 3.1389e+04 2.6991e+03 11.6296 < 2.2e-16 ***
bath_half5 -6.1467e+04 2.0640e+04 -2.9781 0.0029029 **
age -1.2650e+03 6.3557e+01 -19.9031 < 2.2e-16 ***
dom -4.0254e+01 4.5458e+00 -8.8551 < 2.2e-16 ***
sold_date 6.1805e-01 3.7630e-01 1.6424 0.1005131
sewer_typeseptic -3.2898e+03 1.1562e+03 -2.8454 0.0044393 **
sewer_typeunspecified -1.6574e+03 6.0948e+02 -2.7194 0.0065445 **
property_stylenot_mobile 5.9349e+04 1.4129e+03 42.0039 < 2.2e-16 ***
subdivision1 2.0745e+03 7.4389e+02 2.7887 0.0052961 **
water_typewell 1.6714e+03 3.2317e+03 0.5172 0.6050235
waterfront1 9.7348e+03 1.1531e+03 8.4421 < 2.2e-16 ***
age_2 1.1978e+01 8.7813e-01 13.6405 < 2.2e-16 ***
area_living_2 -9.3602e-04 1.3526e-03 -0.6920 0.4889450
data_factor$infections_3mma 8.0185e+00 4.7036e-01 17.0476 < 2.2e-16 ***
top25_sold_price 1.0352e+05 1.0338e+03 100.1342 < 2.2e-16 ***
data_factor$infections_3mma:top25_sold_price -5.8199e+00 8.7294e-01 -6.6670 2.666e-11 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# Testing Corona, Bottom 25% in price ------------------------------------------------------------------
# Single Var Test
lm_corona_price_bottom_single <- lm(sold_price ~ +
# test variable(s)
+ bottom25_sold_price
# Removals
,data = data_factor_core_clean)
summ(lm_corona_price_bottom)
MODEL INFO:
Observations: 24653 (19 missing obs. deleted)
Dependent Variable: sold_price
Type: OLS linear regression
MODEL FIT:
F(66,24586) = 1103.26, p = 0.00
R² = 0.75
Adj. R² = 0.75
Standard errors: OLS
---------------------------------------------------------------------------------------------
Est. S.E. t val. p
----------------------------------------------------- ------------ ---------- -------- ------
(Intercept) 278572.83 49522.29 5.63 0.00
property_typeDUP -21975.26 15045.71 -1.46 0.14
property_typeOTH 14584.46 10486.43 1.39 0.16
property_typePAT 10163.40 4843.93 2.10 0.04
property_typeSGL 18551.81 2270.84 8.17 0.00
property_typeTNH -4443.98 2879.53 -1.54 0.12
ac_typenone -25551.80 1990.46 -12.84 0.00
ac_typenot_central -3360.67 1286.64 -2.61 0.01
patio1 4170.98 658.75 6.33 0.00
school_general1 7796.68 839.18 9.29 0.00
photo_count 568.04 37.33 15.22 0.00
pool1 11680.10 1093.40 10.68 0.00
roof_typeother -270.74 1212.34 -0.22 0.82
roof_typeshingle 11414.19 1365.17 8.36 0.00
roof_typeslate 5849.65 5791.47 1.01 0.31
gas_typenatural -66364.07 44707.49 -1.48 0.14
gas_typenone -106993.75 44684.57 -2.39 0.02
gas_typepropane -73201.52 45735.97 -1.60 0.11
gas_typeunknown -108426.64 44679.21 -2.43 0.02
out_building1 -6696.89 709.03 -9.45 0.00
area_living -18.31 4.75 -3.86 0.00
land_acres 1606.77 758.69 2.12 0.03
appliances1 10362.80 902.97 11.48 0.00
garage1 6943.56 654.26 10.61 0.00
property_conditionnew -9646.79 4043.49 -2.39 0.02
property_conditionother -10476.91 877.11 -11.94 0.00
energy_efficient1 10733.01 732.95 14.64 0.00
exterior_typemetal -685.33 2100.19 -0.33 0.74
exterior_typeother 8769.28 871.55 10.06 0.00
exterior_typevinyl 2180.72 970.57 2.25 0.02
exterior_typewood 3671.39 1368.83 2.68 0.01
exterior_featurescourtyard 23334.15 7367.19 3.17 0.00
exterior_featuresfence -31846.82 3134.41 -10.16 0.00
exterior_featuresnone -27200.10 3143.02 -8.65 0.00
exterior_featuresporch -31925.87 3213.70 -9.93 0.00
exterior_featurestennis_court -8249.74 9008.01 -0.92 0.36
fireplace1 10616.38 684.11 15.52 0.00
foundation_typeslab 4098.81 1000.76 4.10 0.00
foundation_typeunspecified 2120.33 1194.05 1.78 0.08
beds_total1 -6976.98 16640.85 -0.42 0.68
beds_total2 -13761.26 16502.60 -0.83 0.40
beds_total3 -22255.19 16536.14 -1.35 0.18
beds_total4 -17413.81 16564.55 -1.05 0.29
beds_total5 -35118.05 16826.66 -2.09 0.04
bath_full1 -16852.11 17602.90 -0.96 0.34
bath_full2 -8935.56 17591.76 -0.51 0.61
bath_full3 16747.25 17644.21 0.95 0.34
bath_full4 15692.91 19503.32 0.80 0.42
bath_full6 40307.89 48193.71 0.84 0.40
bath_half1 13387.94 862.68 15.52 0.00
bath_half2 30999.22 5575.03 5.56 0.00
bath_half3 59626.81 31592.73 1.89 0.06
bath_half4 94037.59 44709.13 2.10 0.04
bath_half5 -31270.97 25838.70 -1.21 0.23
age -1620.02 55.29 -29.30 0.00
dom -40.07 4.92 -8.14 0.00
sewer_typeseptic -6332.63 1233.09 -5.14 0.00
sewer_typeunspecified -4983.26 673.22 -7.40 0.00
property_stylenot_mobile 28897.37 1857.95 15.55 0.00
subdivision1 2210.02 788.75 2.80 0.01
water_typewell 2881.36 3113.91 0.93 0.35
waterfront1 17853.96 1160.32 15.39 0.00
age_2 14.56 0.70 20.80 0.00
area_living_2 0.02 0.00 15.67 0.00
data_factor$infections_3mma 8.65 0.44 19.62 0.00
bottom25_sold_price -79842.92 925.29 -86.29 0.00
data_factor$infections_3mma:bottom25_sold_price -6.27 0.97 -6.47 0.00
---------------------------------------------------------------------------------------------
coeftest(lm_corona_price_bottom_single, vcov = vcovHC(lm_corona_price_bottom_single, method = "White2", type = "HC0"))
t test of coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 209108.22 524.33 398.81 < 2.2e-16 ***
bottom25_sold_price -142785.86 644.23 -221.64 < 2.2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# General Model: No controls
lm_corona_price_bottom_basic <- lm(sold_price ~ +
# test variable(s)
+ data_factor$infections_3mma + bottom25_sold_price +
data_factor$infections_3mma*bottom25_sold_price
# Removals
,data = data_factor_core_clean)
summ(lm_corona_price_bottom_basic)
MODEL INFO:
Observations: 24672
Dependent Variable: sold_price
Type: OLS linear regression
MODEL FIT:
F(3,24668) = 8805.53, p = 0.00
R² = 0.52
Adj. R² = 0.52
Standard errors: OLS
--------------------------------------------------------------------------------------------
Est. S.E. t val. p
----------------------------------------------------- ------------ -------- --------- ------
(Intercept) 202505.11 519.18 390.05 0.00
data_factor$infections_3mma 14.28 0.53 26.94 0.00
bottom25_sold_price -136793.88 968.10 -141.30 0.00
data_factor$infections_3mma:bottom25_sold_price -11.72 1.32 -8.89 0.00
--------------------------------------------------------------------------------------------
coeftest(lm_corona_price_bottom_basic, vcov = vcovHC(lm_corona_price_bottom_basic, method = "White2", type = "HC0"))
t test of coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 2.0251e+05 5.6524e+02 358.261 < 2.2e-16 ***
data_factor$infections_3mma 1.4280e+01 6.4887e-01 22.007 < 2.2e-16 ***
bottom25_sold_price -1.3679e+05 6.9305e+02 -197.379 < 2.2e-16 ***
data_factor$infections_3mma:bottom25_sold_price -1.1724e+01 8.6004e-01 -13.632 < 2.2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# General Model: No controls
lm_corona_price_bottom <- lm(sold_price ~ . +
# test variable(s)
+ data_factor$infections_3mma + bottom25_sold_price +
data_factor$infections_3mma*bottom25_sold_price
# Removals
- sold_date
,data = data_factor_core_clean)
summ(lm_corona_price_bottom)
MODEL INFO:
Observations: 24653 (19 missing obs. deleted)
Dependent Variable: sold_price
Type: OLS linear regression
MODEL FIT:
F(66,24586) = 1103.26, p = 0.00
R² = 0.75
Adj. R² = 0.75
Standard errors: OLS
---------------------------------------------------------------------------------------------
Est. S.E. t val. p
----------------------------------------------------- ------------ ---------- -------- ------
(Intercept) 278572.83 49522.29 5.63 0.00
property_typeDUP -21975.26 15045.71 -1.46 0.14
property_typeOTH 14584.46 10486.43 1.39 0.16
property_typePAT 10163.40 4843.93 2.10 0.04
property_typeSGL 18551.81 2270.84 8.17 0.00
property_typeTNH -4443.98 2879.53 -1.54 0.12
ac_typenone -25551.80 1990.46 -12.84 0.00
ac_typenot_central -3360.67 1286.64 -2.61 0.01
patio1 4170.98 658.75 6.33 0.00
school_general1 7796.68 839.18 9.29 0.00
photo_count 568.04 37.33 15.22 0.00
pool1 11680.10 1093.40 10.68 0.00
roof_typeother -270.74 1212.34 -0.22 0.82
roof_typeshingle 11414.19 1365.17 8.36 0.00
roof_typeslate 5849.65 5791.47 1.01 0.31
gas_typenatural -66364.07 44707.49 -1.48 0.14
gas_typenone -106993.75 44684.57 -2.39 0.02
gas_typepropane -73201.52 45735.97 -1.60 0.11
gas_typeunknown -108426.64 44679.21 -2.43 0.02
out_building1 -6696.89 709.03 -9.45 0.00
area_living -18.31 4.75 -3.86 0.00
land_acres 1606.77 758.69 2.12 0.03
appliances1 10362.80 902.97 11.48 0.00
garage1 6943.56 654.26 10.61 0.00
property_conditionnew -9646.79 4043.49 -2.39 0.02
property_conditionother -10476.91 877.11 -11.94 0.00
energy_efficient1 10733.01 732.95 14.64 0.00
exterior_typemetal -685.33 2100.19 -0.33 0.74
exterior_typeother 8769.28 871.55 10.06 0.00
exterior_typevinyl 2180.72 970.57 2.25 0.02
exterior_typewood 3671.39 1368.83 2.68 0.01
exterior_featurescourtyard 23334.15 7367.19 3.17 0.00
exterior_featuresfence -31846.82 3134.41 -10.16 0.00
exterior_featuresnone -27200.10 3143.02 -8.65 0.00
exterior_featuresporch -31925.87 3213.70 -9.93 0.00
exterior_featurestennis_court -8249.74 9008.01 -0.92 0.36
fireplace1 10616.38 684.11 15.52 0.00
foundation_typeslab 4098.81 1000.76 4.10 0.00
foundation_typeunspecified 2120.33 1194.05 1.78 0.08
beds_total1 -6976.98 16640.85 -0.42 0.68
beds_total2 -13761.26 16502.60 -0.83 0.40
beds_total3 -22255.19 16536.14 -1.35 0.18
beds_total4 -17413.81 16564.55 -1.05 0.29
beds_total5 -35118.05 16826.66 -2.09 0.04
bath_full1 -16852.11 17602.90 -0.96 0.34
bath_full2 -8935.56 17591.76 -0.51 0.61
bath_full3 16747.25 17644.21 0.95 0.34
bath_full4 15692.91 19503.32 0.80 0.42
bath_full6 40307.89 48193.71 0.84 0.40
bath_half1 13387.94 862.68 15.52 0.00
bath_half2 30999.22 5575.03 5.56 0.00
bath_half3 59626.81 31592.73 1.89 0.06
bath_half4 94037.59 44709.13 2.10 0.04
bath_half5 -31270.97 25838.70 -1.21 0.23
age -1620.02 55.29 -29.30 0.00
dom -40.07 4.92 -8.14 0.00
sewer_typeseptic -6332.63 1233.09 -5.14 0.00
sewer_typeunspecified -4983.26 673.22 -7.40 0.00
property_stylenot_mobile 28897.37 1857.95 15.55 0.00
subdivision1 2210.02 788.75 2.80 0.01
water_typewell 2881.36 3113.91 0.93 0.35
waterfront1 17853.96 1160.32 15.39 0.00
age_2 14.56 0.70 20.80 0.00
area_living_2 0.02 0.00 15.67 0.00
data_factor$infections_3mma 8.65 0.44 19.62 0.00
bottom25_sold_price -79842.92 925.29 -86.29 0.00
data_factor$infections_3mma:bottom25_sold_price -6.27 0.97 -6.47 0.00
---------------------------------------------------------------------------------------------
coeftest(lm_corona_price_bottom, vcov = vcovHC(lm_corona_price_bottom, method = "White2", type = "HC0"))
t test of coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 2.7857e+05 2.2480e+04 12.3920 < 2.2e-16 ***
property_typeDUP -2.1975e+04 1.6374e+04 -1.3421 0.1795756
property_typeOTH 1.4584e+04 1.2380e+04 1.1781 0.2387656
property_typePAT 1.0163e+04 4.9850e+03 2.0388 0.0414796 *
property_typeSGL 1.8552e+04 2.3641e+03 7.8474 4.420e-15 ***
property_typeTNH -4.4440e+03 3.0234e+03 -1.4699 0.1416099
ac_typenone -2.5552e+04 1.3619e+03 -18.7624 < 2.2e-16 ***
ac_typenot_central -3.3607e+03 1.2777e+03 -2.6302 0.0085391 **
patio1 4.1710e+03 6.7317e+02 6.1960 5.882e-10 ***
school_general1 7.7967e+03 8.8654e+02 8.7945 < 2.2e-16 ***
photo_count 5.6804e+02 4.0920e+01 13.8818 < 2.2e-16 ***
pool1 1.1680e+04 1.3071e+03 8.9360 < 2.2e-16 ***
roof_typeother -2.7074e+02 1.1928e+03 -0.2270 0.8204422
roof_typeshingle 1.1414e+04 1.4048e+03 8.1253 4.672e-16 ***
roof_typeslate 5.8497e+03 8.3957e+03 0.6967 0.4859696
gas_typenatural -6.6364e+04 3.2084e+03 -20.6848 < 2.2e-16 ***
gas_typenone -1.0699e+05 2.1142e+03 -50.6067 < 2.2e-16 ***
gas_typepropane -7.3202e+04 1.5062e+04 -4.8601 1.181e-06 ***
gas_typeunknown -1.0843e+05 2.0384e+03 -53.1917 < 2.2e-16 ***
out_building1 -6.6969e+03 7.1902e+02 -9.3140 < 2.2e-16 ***
area_living -1.8309e+01 5.5182e+00 -3.3179 0.0009081 ***
land_acres 1.6068e+03 7.6658e+02 2.0960 0.0360904 *
appliances1 1.0363e+04 8.8813e+02 11.6681 < 2.2e-16 ***
garage1 6.9436e+03 6.6603e+02 10.4254 < 2.2e-16 ***
property_conditionnew -9.6468e+03 5.8477e+03 -1.6497 0.0990228 .
property_conditionother -1.0477e+04 8.6301e+02 -12.1400 < 2.2e-16 ***
energy_efficient1 1.0733e+04 7.4567e+02 14.3938 < 2.2e-16 ***
exterior_typemetal -6.8533e+02 1.9199e+03 -0.3570 0.7211248
exterior_typeother 8.7693e+03 9.3197e+02 9.4094 < 2.2e-16 ***
exterior_typevinyl 2.1807e+03 9.6058e+02 2.2702 0.0232035 *
exterior_typewood 3.6714e+03 1.4550e+03 2.5232 0.0116338 *
exterior_featurescourtyard 2.3334e+04 1.2856e+04 1.8151 0.0695255 .
exterior_featuresfence -3.1847e+04 4.8489e+03 -6.5679 5.206e-11 ***
exterior_featuresnone -2.7200e+04 4.8484e+03 -5.6101 2.043e-08 ***
exterior_featuresporch -3.1926e+04 4.8992e+03 -6.5165 7.334e-11 ***
exterior_featurestennis_court -8.2497e+03 9.9486e+03 -0.8292 0.4069776
fireplace1 1.0616e+04 7.1079e+02 14.9359 < 2.2e-16 ***
foundation_typeslab 4.0988e+03 1.0575e+03 3.8759 0.0001065 ***
foundation_typeunspecified 2.1203e+03 1.1394e+03 1.8609 0.0627696 .
beds_total1 -6.9770e+03 2.1265e+04 -0.3281 0.7428376
beds_total2 -1.3761e+04 2.1173e+04 -0.6499 0.5157434
beds_total3 -2.2255e+04 2.1202e+04 -1.0497 0.2938691
beds_total4 -1.7414e+04 2.1228e+04 -0.8203 0.4120491
beds_total5 -3.5118e+04 2.1647e+04 -1.6223 0.1047492
bath_full1 -1.6852e+04 1.3865e+04 -1.2154 0.2242251
bath_full2 -8.9356e+03 1.3844e+04 -0.6454 0.5186491
bath_full3 1.6747e+04 1.3974e+04 1.1984 0.2307573
bath_full4 1.5693e+04 2.1486e+04 0.7304 0.4651680
bath_full6 4.0308e+04 1.4910e+04 2.7034 0.0068690 **
bath_half1 1.3388e+04 1.0236e+03 13.0790 < 2.2e-16 ***
bath_half2 3.0999e+04 8.0343e+03 3.8584 0.0001144 ***
bath_half3 5.9627e+04 8.9836e+03 6.6373 3.262e-11 ***
bath_half4 9.4038e+04 2.9045e+03 32.3760 < 2.2e-16 ***
bath_half5 -3.1271e+04 2.1658e+04 -1.4439 0.1487886
age -1.6200e+03 7.0930e+01 -22.8398 < 2.2e-16 ***
dom -4.0071e+01 4.9024e+00 -8.1738 3.132e-16 ***
sewer_typeseptic -6.3326e+03 1.2071e+03 -5.2461 1.567e-07 ***
sewer_typeunspecified -4.9833e+03 6.5197e+02 -7.6433 2.194e-14 ***
property_stylenot_mobile 2.8897e+04 1.5948e+03 18.1201 < 2.2e-16 ***
subdivision1 2.2100e+03 7.7041e+02 2.8686 0.0041258 **
water_typewell 2.8814e+03 3.4386e+03 0.8379 0.4020708
waterfront1 1.7854e+04 1.3436e+03 13.2880 < 2.2e-16 ***
age_2 1.4555e+01 9.7616e-01 14.9108 < 2.2e-16 ***
area_living_2 1.9719e-02 1.6137e-03 12.2194 < 2.2e-16 ***
data_factor$infections_3mma 8.6517e+00 4.9113e-01 17.6161 < 2.2e-16 ***
bottom25_sold_price -7.9843e+04 8.2900e+02 -96.3119 < 2.2e-16 ***
data_factor$infections_3mma:bottom25_sold_price -6.2653e+00 7.9397e-01 -7.8911 3.120e-15 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# Conditional Mean
library(plyr)
age_mean_data <- ddply(data_factor, "infections_period", summarise, age_mean = mean(age, na.rm = TRUE))
# Distribution: Total
ggplot(data_factor, aes(x = age)) +
geom_density(alpha = 0.5, position = "identity", fill = "#ff6c67") +
ggtitle("Age Distributions") +
geom_vline(aes(xintercept = mean(age)), linetype="dashed", size= 0.4, alpha = 0.5)
# Distribution: Infection
ggplot(data_factor, aes(x = age, fill = infections_period)) +
geom_density(alpha = 0.5, position = "identity") +
ggtitle("Age Distributions") +
geom_vline(data = age_mean_data, aes(xintercept = age_mean_data[2,2]), linetype="dashed", size= 0.5, color = "#00c2c6", alpha = 0.8) +
geom_vline(data = age_mean_data, aes(xintercept = age_mean_data[1,2]), linetype="dashed", size= 0.5, alpha = 0.8, color = "#ff6c67")
# Distribution: Top vs. Bottom
ggplot(data_factor) +
geom_density(aes(x = age, fill = infections_period), alpha = 0.5, position = "identity") +
facet_grid(vars(top25_age, bottom25_age), scales = "free") +
ggtitle("Age Distributions")
#Age on Infections
ggplot(data_factor, aes(x = infections_period, y = age, fill = infections_period)) +
geom_violin(alpha = 0.5) +
geom_boxplot(width=0.1) +
scale_fill_viridis(discrete = TRUE, alpha=0.6, option="D") +
coord_flip() +
theme_ipsum() +
theme(
legend.position="none",
plot.title = element_text(size=11)) +
ggtitle("Comparison of Age") +
xlab("Infections Present (1 = yes)") +
scale_fill_manual(values=c("#ff6c67", "#00c2c6"))
Scale for 'fill' is already present. Adding another scale for 'fill', which will replace the existing scale.
# Testing Corona, top 25% in age
lm_corona_age_top_single <- lm(sold_price ~
# test variable(s)
+ top25_age
# Removals
- age
- age_2
- property_type
,data = data_factor_core_clean)
coeftest(lm_corona_age_top_single, vcov = vcovHC(lm_corona_age_top_single, method = "White2", type = "HC0"))
t test of coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 179976.63 653.39 275.452 < 2.2e-16 ***
top25_age -34907.19 1240.59 -28.138 < 2.2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
lm_corona_age_top <- lm(sold_price ~ .
# test variable(s)
+ data_factor$infections_3mma + top25_age + data_factor$infections_3mma*top25_age
# Removals
- age
- age_2
- property_type
,data = data_factor_core_clean)
coeftest(lm_corona_age_top, vcov = vcovHC(lm_corona_age_top, method = "White2", type = "HC0"))
t test of coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 8.7663e+04 3.3074e+04 2.6505 0.008043 **
ac_typenone -4.5325e+04 2.0573e+03 -22.0312 < 2.2e-16 ***
ac_typenot_central -1.2765e+04 1.6380e+03 -7.7929 6.805e-15 ***
patio1 9.8770e+03 8.0022e+02 12.3429 < 2.2e-16 ***
school_general1 1.5035e+04 1.0665e+03 14.0967 < 2.2e-16 ***
photo_count 7.9518e+02 4.9617e+01 16.0263 < 2.2e-16 ***
pool1 9.8379e+03 1.4299e+03 6.8802 6.119e-12 ***
roof_typeother 3.8048e+03 1.4811e+03 2.5690 0.010206 *
roof_typeshingle 2.6555e+04 1.6923e+03 15.6917 < 2.2e-16 ***
roof_typeslate 1.1186e+04 9.9027e+03 1.1296 0.258672
gas_typenatural -1.0008e+05 3.7634e+03 -26.5918 < 2.2e-16 ***
gas_typenone -1.4327e+05 2.5141e+03 -56.9852 < 2.2e-16 ***
gas_typepropane -1.1972e+05 1.7362e+04 -6.8955 5.496e-12 ***
gas_typeunknown -1.4613e+05 2.3963e+03 -60.9786 < 2.2e-16 ***
out_building1 -8.7089e+03 8.4100e+02 -10.3554 < 2.2e-16 ***
area_living 3.9302e+01 6.3373e+00 6.2018 5.671e-10 ***
land_acres 4.1959e+03 9.8188e+02 4.2734 1.933e-05 ***
appliances1 2.7105e+04 1.1666e+03 23.2354 < 2.2e-16 ***
garage1 1.6488e+04 7.8121e+02 21.1056 < 2.2e-16 ***
property_conditionnew 2.4694e+02 6.9316e+03 0.0356 0.971581
property_conditionother -1.9512e+04 9.7390e+02 -20.0349 < 2.2e-16 ***
energy_efficient1 1.5388e+04 8.7268e+02 17.6332 < 2.2e-16 ***
exterior_typemetal -1.9638e+02 2.4148e+03 -0.0813 0.935185
exterior_typeother 1.2149e+04 1.1288e+03 10.7625 < 2.2e-16 ***
exterior_typevinyl 5.6024e+03 1.1480e+03 4.8801 1.067e-06 ***
exterior_typewood 3.8875e+03 1.8563e+03 2.0942 0.036249 *
exterior_featurescourtyard 4.5183e+04 1.5770e+04 2.8650 0.004173 **
exterior_featuresfence -2.3109e+04 5.7398e+03 -4.0260 5.689e-05 ***
exterior_featuresnone -1.4656e+04 5.7530e+03 -2.5475 0.010855 *
exterior_featuresporch -1.8320e+04 5.8022e+03 -3.1574 0.001594 **
exterior_featurestennis_court 1.1765e+04 1.1363e+04 1.0354 0.300486
fireplace1 9.9727e+03 8.5435e+02 11.6728 < 2.2e-16 ***
foundation_typeslab 1.2748e+04 1.3207e+03 9.6523 < 2.2e-16 ***
foundation_typeunspecified 6.1488e+03 1.4624e+03 4.2048 2.623e-05 ***
beds_total1 -3.0637e+04 2.6634e+04 -1.1503 0.250036
beds_total2 -3.7947e+04 2.6507e+04 -1.4316 0.152270
beds_total3 -3.8270e+04 2.6544e+04 -1.4418 0.149383
beds_total4 -3.3982e+04 2.6579e+04 -1.2785 0.201074
beds_total5 -5.3363e+04 2.7014e+04 -1.9754 0.048232 *
bath_full1 -2.5755e+04 2.5301e+04 -1.0179 0.308714
bath_full2 -1.1187e+03 2.5290e+04 -0.0442 0.964718
bath_full3 2.7028e+04 2.5383e+04 1.0648 0.286961
bath_full4 2.9337e+04 3.1409e+04 0.9340 0.350288
bath_full6 9.9616e+03 2.5902e+04 0.3846 0.700542
bath_half1 1.1658e+04 1.1624e+03 10.0288 < 2.2e-16 ***
bath_half2 3.8181e+04 7.7169e+03 4.9477 7.560e-07 ***
bath_half3 6.5448e+04 3.6714e+03 17.8265 < 2.2e-16 ***
bath_half4 7.5416e+04 3.5915e+03 20.9986 < 2.2e-16 ***
bath_half5 -6.1818e+04 2.6138e+04 -2.3651 0.018032 *
dom -6.9720e+01 5.8816e+00 -11.8539 < 2.2e-16 ***
sold_date 3.6380e+00 4.7050e-01 7.7320 1.099e-14 ***
sewer_typeseptic -7.0535e+03 1.4916e+03 -4.7289 2.270e-06 ***
sewer_typeunspecified -3.3914e+03 7.6453e+02 -4.4359 9.208e-06 ***
property_stylenot_mobile 6.4467e+04 1.7508e+03 36.8208 < 2.2e-16 ***
subdivision1 4.1091e+03 9.4953e+02 4.3275 1.514e-05 ***
water_typewell 1.6001e+03 4.1028e+03 0.3900 0.696543
waterfront1 2.3618e+04 1.5203e+03 15.5353 < 2.2e-16 ***
area_living_2 7.3187e-03 1.8136e-03 4.0355 5.466e-05 ***
data_factor$infections_3mma 9.9554e+00 6.6111e-01 15.0587 < 2.2e-16 ***
top25_age -1.1077e+04 9.1623e+02 -12.0897 < 2.2e-16 ***
data_factor$infections_3mma:top25_age -2.7534e+00 1.0786e+00 -2.5528 0.010691 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# Testing Corona, bottom 25% in age
lm_corona_age_bottom_single <- lm(sold_price ~
# test variable(s)
+ bottom25_age
# Removals
- age
- age_2
- property_type
,data = data_factor_core_clean)
coeftest(lm_corona_age_bottom, vcov = vcovHC(lm_corona_age_bottom, method = "White2", type = "HC0"))
t test of coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.3341e+05 3.2081e+04 4.1586 3.213e-05 ***
ac_typenone -4.5686e+04 1.9758e+03 -23.1223 < 2.2e-16 ***
ac_typenot_central -1.3725e+04 1.6034e+03 -8.5599 < 2.2e-16 ***
patio1 8.8777e+03 7.8834e+02 11.2611 < 2.2e-16 ***
school_general1 1.2233e+04 1.0519e+03 11.6291 < 2.2e-16 ***
photo_count 8.3004e+02 4.9235e+01 16.8587 < 2.2e-16 ***
pool1 9.7246e+03 1.4036e+03 6.9282 4.368e-12 ***
roof_typeother 3.4687e+03 1.4601e+03 2.3756 0.0175271 *
roof_typeshingle 2.2548e+04 1.6702e+03 13.5004 < 2.2e-16 ***
roof_typeslate 1.0875e+04 9.8409e+03 1.1051 0.2691232
gas_typenatural -8.5473e+04 3.7766e+03 -22.6323 < 2.2e-16 ***
gas_typenone -1.2673e+05 2.5713e+03 -49.2845 < 2.2e-16 ***
gas_typepropane -9.7511e+04 1.8583e+04 -5.2472 1.557e-07 ***
gas_typeunknown -1.3010e+05 2.4694e+03 -52.6863 < 2.2e-16 ***
out_building1 -6.6527e+03 8.3095e+02 -8.0061 1.236e-15 ***
land_acres 3.1612e+03 9.5672e+02 3.3042 0.0009539 ***
appliances1 2.5020e+04 1.1462e+03 21.8287 < 2.2e-16 ***
garage1 1.4086e+04 7.7556e+02 18.1622 < 2.2e-16 ***
property_conditionnew -6.1690e+03 6.6511e+03 -0.9275 0.3536702
property_conditionother -2.0673e+04 9.6156e+02 -21.4998 < 2.2e-16 ***
energy_efficient1 1.5373e+04 8.5713e+02 17.9354 < 2.2e-16 ***
exterior_typemetal -2.4707e+02 2.4198e+03 -0.1021 0.9186751
exterior_typeother 1.2851e+04 1.1016e+03 11.6659 < 2.2e-16 ***
exterior_typevinyl 5.8691e+03 1.1316e+03 5.1867 2.157e-07 ***
exterior_typewood 4.8121e+03 1.8249e+03 2.6370 0.0083702 **
exterior_featurescourtyard 4.5337e+04 1.5197e+04 2.9833 0.0028542 **
exterior_featuresfence -2.2494e+04 5.5120e+03 -4.0810 4.499e-05 ***
exterior_featuresnone -1.4390e+04 5.5240e+03 -2.6049 0.0091955 **
exterior_featuresporch -2.0275e+04 5.5771e+03 -3.6353 0.0002782 ***
exterior_featurestennis_court 8.8427e+03 1.0725e+04 0.8245 0.4096642
fireplace1 1.1842e+04 8.3865e+02 14.1201 < 2.2e-16 ***
foundation_typeslab 1.2592e+04 1.3040e+03 9.6567 < 2.2e-16 ***
foundation_typeunspecified 6.6525e+03 1.4485e+03 4.5926 4.400e-06 ***
beds_total1 -2.4476e+04 2.7523e+04 -0.8893 0.3738489
beds_total2 -2.5550e+04 2.7331e+04 -0.9348 0.3498804
beds_total3 -2.4087e+04 2.7328e+04 -0.8814 0.3781066
beds_total4 -2.0511e+04 2.7360e+04 -0.7497 0.4534551
beds_total5 -3.9284e+04 2.7797e+04 -1.4133 0.1575900
bath_full1 -3.8188e+04 2.4744e+04 -1.5433 0.1227657
bath_full2 -1.2393e+04 2.4737e+04 -0.5010 0.6163953
bath_full3 1.2200e+04 2.4816e+04 0.4916 0.6229929
bath_full4 1.3770e+04 3.0986e+04 0.4444 0.6567506
bath_full6 -7.2112e+03 2.5341e+04 -0.2846 0.7759828
bath_half1 1.2440e+04 1.1424e+03 10.8891 < 2.2e-16 ***
bath_half2 3.7417e+04 7.6533e+03 4.8890 1.020e-06 ***
bath_half3 6.4543e+04 8.3666e+03 7.7144 1.261e-14 ***
bath_half4 7.6590e+04 3.2113e+03 23.8501 < 2.2e-16 ***
bath_half5 -5.6216e+04 2.5008e+04 -2.2479 0.0245917 *
dom -6.2854e+01 5.8220e+00 -10.7959 < 2.2e-16 ***
sold_date 1.4337e+00 4.6958e-01 3.0531 0.0022670 **
sewer_typeseptic -6.4102e+03 1.4716e+03 -4.3560 1.330e-05 ***
sewer_typeunspecified -4.3032e+03 7.5897e+02 -5.6697 1.446e-08 ***
property_stylenot_mobile 6.9807e+04 1.7731e+03 39.3696 < 2.2e-16 ***
subdivision1 3.1875e+03 9.3573e+02 3.4065 0.0006592 ***
water_typewell 2.0497e+02 4.1549e+03 0.0493 0.9606545
waterfront1 2.0545e+04 1.5256e+03 13.4665 < 2.2e-16 ***
area_living_2 1.7648e-02 4.2033e-04 41.9858 < 2.2e-16 ***
data_factor$infections_3mma 9.0607e+00 7.2102e-01 12.5664 < 2.2e-16 ***
bottom25_age 2.5730e+04 9.6686e+02 26.6121 < 2.2e-16 ***
data_factor$infections_3mma:bottom25_age 1.5468e+00 9.1535e-01 1.6898 0.0910714 .
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
lm_corona_age_bottom <- lm(sold_price ~ .
# test variable(s)
+ data_factor$infections_3mma + bottom25_age + data_factor$infections_3mma*bottom25_age
# Removals
- age
- age_2
- property_type
- area_living
,data = data_factor_core_clean)
coeftest(lm_corona_age_bottom, vcov = vcovHC(lm_corona_age_bottom, method = "White2", type = "HC0"))
t test of coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.3341e+05 3.2081e+04 4.1586 3.213e-05 ***
ac_typenone -4.5686e+04 1.9758e+03 -23.1223 < 2.2e-16 ***
ac_typenot_central -1.3725e+04 1.6034e+03 -8.5599 < 2.2e-16 ***
patio1 8.8777e+03 7.8834e+02 11.2611 < 2.2e-16 ***
school_general1 1.2233e+04 1.0519e+03 11.6291 < 2.2e-16 ***
photo_count 8.3004e+02 4.9235e+01 16.8587 < 2.2e-16 ***
pool1 9.7246e+03 1.4036e+03 6.9282 4.368e-12 ***
roof_typeother 3.4687e+03 1.4601e+03 2.3756 0.0175271 *
roof_typeshingle 2.2548e+04 1.6702e+03 13.5004 < 2.2e-16 ***
roof_typeslate 1.0875e+04 9.8409e+03 1.1051 0.2691232
gas_typenatural -8.5473e+04 3.7766e+03 -22.6323 < 2.2e-16 ***
gas_typenone -1.2673e+05 2.5713e+03 -49.2845 < 2.2e-16 ***
gas_typepropane -9.7511e+04 1.8583e+04 -5.2472 1.557e-07 ***
gas_typeunknown -1.3010e+05 2.4694e+03 -52.6863 < 2.2e-16 ***
out_building1 -6.6527e+03 8.3095e+02 -8.0061 1.236e-15 ***
land_acres 3.1612e+03 9.5672e+02 3.3042 0.0009539 ***
appliances1 2.5020e+04 1.1462e+03 21.8287 < 2.2e-16 ***
garage1 1.4086e+04 7.7556e+02 18.1622 < 2.2e-16 ***
property_conditionnew -6.1690e+03 6.6511e+03 -0.9275 0.3536702
property_conditionother -2.0673e+04 9.6156e+02 -21.4998 < 2.2e-16 ***
energy_efficient1 1.5373e+04 8.5713e+02 17.9354 < 2.2e-16 ***
exterior_typemetal -2.4707e+02 2.4198e+03 -0.1021 0.9186751
exterior_typeother 1.2851e+04 1.1016e+03 11.6659 < 2.2e-16 ***
exterior_typevinyl 5.8691e+03 1.1316e+03 5.1867 2.157e-07 ***
exterior_typewood 4.8121e+03 1.8249e+03 2.6370 0.0083702 **
exterior_featurescourtyard 4.5337e+04 1.5197e+04 2.9833 0.0028542 **
exterior_featuresfence -2.2494e+04 5.5120e+03 -4.0810 4.499e-05 ***
exterior_featuresnone -1.4390e+04 5.5240e+03 -2.6049 0.0091955 **
exterior_featuresporch -2.0275e+04 5.5771e+03 -3.6353 0.0002782 ***
exterior_featurestennis_court 8.8427e+03 1.0725e+04 0.8245 0.4096642
fireplace1 1.1842e+04 8.3865e+02 14.1201 < 2.2e-16 ***
foundation_typeslab 1.2592e+04 1.3040e+03 9.6567 < 2.2e-16 ***
foundation_typeunspecified 6.6525e+03 1.4485e+03 4.5926 4.400e-06 ***
beds_total1 -2.4476e+04 2.7523e+04 -0.8893 0.3738489
beds_total2 -2.5550e+04 2.7331e+04 -0.9348 0.3498804
beds_total3 -2.4087e+04 2.7328e+04 -0.8814 0.3781066
beds_total4 -2.0511e+04 2.7360e+04 -0.7497 0.4534551
beds_total5 -3.9284e+04 2.7797e+04 -1.4133 0.1575900
bath_full1 -3.8188e+04 2.4744e+04 -1.5433 0.1227657
bath_full2 -1.2393e+04 2.4737e+04 -0.5010 0.6163953
bath_full3 1.2200e+04 2.4816e+04 0.4916 0.6229929
bath_full4 1.3770e+04 3.0986e+04 0.4444 0.6567506
bath_full6 -7.2112e+03 2.5341e+04 -0.2846 0.7759828
bath_half1 1.2440e+04 1.1424e+03 10.8891 < 2.2e-16 ***
bath_half2 3.7417e+04 7.6533e+03 4.8890 1.020e-06 ***
bath_half3 6.4543e+04 8.3666e+03 7.7144 1.261e-14 ***
bath_half4 7.6590e+04 3.2113e+03 23.8501 < 2.2e-16 ***
bath_half5 -5.6216e+04 2.5008e+04 -2.2479 0.0245917 *
dom -6.2854e+01 5.8220e+00 -10.7959 < 2.2e-16 ***
sold_date 1.4337e+00 4.6958e-01 3.0531 0.0022670 **
sewer_typeseptic -6.4102e+03 1.4716e+03 -4.3560 1.330e-05 ***
sewer_typeunspecified -4.3032e+03 7.5897e+02 -5.6697 1.446e-08 ***
property_stylenot_mobile 6.9807e+04 1.7731e+03 39.3696 < 2.2e-16 ***
subdivision1 3.1875e+03 9.3573e+02 3.4065 0.0006592 ***
water_typewell 2.0497e+02 4.1549e+03 0.0493 0.9606545
waterfront1 2.0545e+04 1.5256e+03 13.4665 < 2.2e-16 ***
area_living_2 1.7648e-02 4.2033e-04 41.9858 < 2.2e-16 ***
data_factor$infections_3mma 9.0607e+00 7.2102e-01 12.5664 < 2.2e-16 ***
bottom25_age 2.5730e+04 9.6686e+02 26.6121 < 2.2e-16 ***
data_factor$infections_3mma:bottom25_age 1.5468e+00 9.1535e-01 1.6898 0.0910714 .
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# Conditional Mean
library(plyr)
area_living_mean_data <- ddply(data_factor, "infections_period", summarise, area_living_mean = mean(area_living, na.rm = TRUE))
# Distribution: Total
ggplot(data_factor, aes(x = area_living)) +
geom_density(alpha = 0.5, position = "identity", fill = "#ff6c67") +
ggtitle("area_living Distributions") +
geom_vline(aes(xintercept = mean(area_living)), linetype="dashed", size= 0.4, alpha = 0.5)
# Distribution: Infection
ggplot(data_factor, aes(x = area_living, fill = infections_period)) +
geom_density(alpha = 0.5, position = "identity") +
ggtitle("area_living Distributions") +
geom_vline(data = area_living_mean_data, aes(xintercept = area_living_mean_data[2,2]), linetype="dashed", size= 0.5, color = "#00c2c6", alpha = 0.8) +
geom_vline(data = area_living_mean_data, aes(xintercept = area_living_mean_data[1,2]), linetype="dashed", size= 0.5, alpha = 0.8, color = "#ff6c67")
# Distribution: Top vs. Bottom
ggplot(data_factor) +
geom_density(aes(x = area_living, fill = infections_period), alpha = 0.5, position = "identity") +
facet_grid(vars(top25_area_living, bottom25_area_living), scales = "free") +
ggtitle("area_living Distributions")
#area_living on Infections
ggplot(data_factor, aes(x = infections_period, y = area_living, fill = infections_period)) +
geom_violin(alpha = 0.5) +
geom_boxplot(width=0.1) +
scale_fill_viridis(discrete = TRUE, alpha=0.6, option="D") +
coord_flip() +
theme_ipsum() +
theme(
legend.position="none",
plot.title = element_text(size=11)) +
ggtitle("Comparison of area_living") +
xlab("Infections Present (1 = yes)") +
scale_fill_manual(values=c("#ff6c67", "#00c2c6"))
Scale for 'fill' is already present. Adding another scale for 'fill', which will replace the existing scale.
# Testing Corona, top 25% in area_living
lm_corona_area_living_top_single <- lm(sold_price ~ .
# test variable(s)
+ top25_area_living
# Removals
- area_living
- area_living_2
- beds_total
- property_type
,data = data_factor_core_clean)
coeftest(lm_corona_area_living_top_single, vcov = vcovHC(lm_corona_area_living_top_single, method = "White2", type = "HC0"))
t test of coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.4725e+05 2.1765e+04 6.7654 1.359e-11 ***
ac_typenone -4.5584e+04 1.9669e+03 -23.1749 < 2.2e-16 ***
ac_typenot_central -1.5099e+04 1.6329e+03 -9.2466 < 2.2e-16 ***
patio1 9.0405e+03 8.1207e+02 11.1326 < 2.2e-16 ***
school_general1 1.2210e+04 1.0732e+03 11.3770 < 2.2e-16 ***
photo_count 9.5621e+02 5.1046e+01 18.7324 < 2.2e-16 ***
pool1 1.1829e+04 1.4499e+03 8.1585 3.554e-16 ***
roof_typeother 5.5740e+03 1.4427e+03 3.8636 0.0001120 ***
roof_typeshingle 2.4145e+04 1.6728e+03 14.4344 < 2.2e-16 ***
roof_typeslate 1.0492e+04 9.6887e+03 1.0829 0.2788508
gas_typenatural -9.1110e+04 3.6876e+03 -24.7068 < 2.2e-16 ***
gas_typenone -1.3877e+05 2.5421e+03 -54.5879 < 2.2e-16 ***
gas_typepropane -1.1341e+05 1.6946e+04 -6.6924 2.242e-11 ***
gas_typeunknown -1.3884e+05 2.4070e+03 -57.6846 < 2.2e-16 ***
out_building1 -4.9117e+03 8.6124e+02 -5.7030 1.191e-08 ***
land_acres 4.3201e+03 9.7368e+02 4.4369 9.168e-06 ***
appliances1 2.3632e+04 1.1624e+03 20.3297 < 2.2e-16 ***
garage1 1.5670e+04 7.9852e+02 19.6241 < 2.2e-16 ***
property_conditionnew -2.2635e+04 7.0005e+03 -3.2333 0.0012253 **
property_conditionother -2.1448e+04 9.9076e+02 -21.6483 < 2.2e-16 ***
energy_efficient1 1.5062e+04 8.7777e+02 17.1598 < 2.2e-16 ***
exterior_typemetal -3.3851e+03 2.4379e+03 -1.3885 0.1649913
exterior_typeother 1.1068e+04 1.1186e+03 9.8941 < 2.2e-16 ***
exterior_typevinyl 2.7742e+03 1.1614e+03 2.3887 0.0169164 *
exterior_typewood 2.4579e+03 1.8319e+03 1.3417 0.1797004
exterior_featurescourtyard 4.3361e+04 1.3984e+04 3.1008 0.0019319 **
exterior_featuresfence -1.5592e+04 5.7130e+03 -2.7293 0.0063520 **
exterior_featuresnone -8.5931e+03 5.7295e+03 -1.4998 0.1336798
exterior_featuresporch -1.6198e+04 5.7884e+03 -2.7983 0.0051412 **
exterior_featurestennis_court 1.1998e+04 1.2031e+04 0.9973 0.3186239
fireplace1 1.9923e+04 8.3303e+02 23.9162 < 2.2e-16 ***
foundation_typeslab 1.3863e+04 1.3049e+03 10.6236 < 2.2e-16 ***
foundation_typeunspecified 6.5194e+03 1.4525e+03 4.4884 7.208e-06 ***
bath_full1 -6.3319e+04 1.8922e+04 -3.3463 0.0008201 ***
bath_full2 -1.9278e+04 1.8921e+04 -1.0189 0.3082761
bath_full3 2.1183e+04 1.9023e+04 1.1135 0.2654903
bath_full4 3.5789e+04 2.7225e+04 1.3146 0.1886714
bath_full6 -2.6419e+04 1.9226e+04 -1.3742 0.1694057
bath_half1 2.0598e+04 1.1458e+03 17.9780 < 2.2e-16 ***
bath_half2 4.8801e+04 8.0303e+03 6.0771 1.242e-09 ***
bath_half3 7.6240e+04 6.5716e+03 11.6015 < 2.2e-16 ***
bath_half4 5.6444e+04 3.1725e+03 17.7917 < 2.2e-16 ***
bath_half5 -4.2226e+04 4.5558e+04 -0.9269 0.3540042
age -2.0721e+03 8.4024e+01 -24.6609 < 2.2e-16 ***
dom -5.3931e+01 6.0075e+00 -8.9773 < 2.2e-16 ***
sold_date 4.9489e+00 4.1996e-01 11.7844 < 2.2e-16 ***
sewer_typeseptic -6.2148e+03 1.4993e+03 -4.1451 3.408e-05 ***
sewer_typeunspecified -5.1530e+03 7.9188e+02 -6.5073 7.799e-11 ***
property_stylenot_mobile 7.3123e+04 1.7698e+03 41.3167 < 2.2e-16 ***
subdivision1 2.7262e+03 9.5041e+02 2.8685 0.0041283 **
water_typewell 5.0830e+03 4.2750e+03 1.1890 0.2344413
waterfront1 2.0562e+04 1.5699e+03 13.0979 < 2.2e-16 ***
age_2 1.9387e+01 1.1571e+00 16.7551 < 2.2e-16 ***
top25_area_living 4.4613e+04 1.2765e+03 34.9508 < 2.2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
lm_corona_area_living_top <- lm(sold_price ~ .
# test variable(s)
+ data_factor$infections_3mma + top25_area_living + data_factor$infections_3mma*top25_area_living
# Removals
- area_living
- area_living_2
- property_type
,data = data_factor_core_clean)
coeftest(lm_corona_area_living_top, vcov = vcovHC(lm_corona_area_living_top, method = "White2", type = "HC0"))
t test of coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 2.2868e+05 3.2458e+04 7.0454 1.898e-12 ***
ac_typenone -4.5983e+04 1.9685e+03 -23.3597 < 2.2e-16 ***
ac_typenot_central -1.4252e+04 1.6382e+03 -8.6997 < 2.2e-16 ***
patio1 8.9829e+03 8.0380e+02 11.1755 < 2.2e-16 ***
school_general1 9.6622e+03 1.0732e+03 9.0032 < 2.2e-16 ***
photo_count 1.0177e+03 5.0699e+01 20.0729 < 2.2e-16 ***
pool1 1.2655e+04 1.4334e+03 8.8287 < 2.2e-16 ***
roof_typeother 4.5135e+03 1.4481e+03 3.1170 0.0018293 **
roof_typeshingle 2.2635e+04 1.6699e+03 13.5544 < 2.2e-16 ***
roof_typeslate 1.1154e+04 9.8214e+03 1.1357 0.2560884
gas_typenatural -9.4084e+04 3.7489e+03 -25.0965 < 2.2e-16 ***
gas_typenone -1.3766e+05 2.5461e+03 -54.0677 < 2.2e-16 ***
gas_typepropane -1.1259e+05 1.7010e+04 -6.6188 3.696e-11 ***
gas_typeunknown -1.3756e+05 2.4309e+03 -56.5901 < 2.2e-16 ***
out_building1 -4.8625e+03 8.5306e+02 -5.7001 1.211e-08 ***
land_acres 4.8537e+03 9.6270e+02 5.0417 4.646e-07 ***
appliances1 2.3952e+04 1.1554e+03 20.7316 < 2.2e-16 ***
garage1 1.4712e+04 7.9181e+02 18.5805 < 2.2e-16 ***
property_conditionnew -1.9981e+04 6.7752e+03 -2.9491 0.0031899 **
property_conditionother -2.0238e+04 9.9115e+02 -20.4186 < 2.2e-16 ***
energy_efficient1 1.4745e+04 8.6928e+02 16.9626 < 2.2e-16 ***
exterior_typemetal -2.2330e+03 2.4160e+03 -0.9243 0.3553498
exterior_typeother 1.2236e+04 1.1117e+03 11.0059 < 2.2e-16 ***
exterior_typevinyl 3.4181e+03 1.1514e+03 2.9687 0.0029930 **
exterior_typewood 2.5865e+03 1.8393e+03 1.4063 0.1596607
exterior_featurescourtyard 4.2334e+04 1.4235e+04 2.9740 0.0029426 **
exterior_featuresfence -2.0803e+04 5.6711e+03 -3.6682 0.0002447 ***
exterior_featuresnone -1.3359e+04 5.6816e+03 -2.3512 0.0187198 *
exterior_featuresporch -2.0560e+04 5.7390e+03 -3.5825 0.0003410 ***
exterior_featurestennis_court 8.7989e+03 1.1731e+04 0.7501 0.4532126
fireplace1 1.9552e+04 8.2518e+02 23.6946 < 2.2e-16 ***
foundation_typeslab 1.2563e+04 1.3139e+03 9.5614 < 2.2e-16 ***
foundation_typeunspecified 6.7507e+03 1.4516e+03 4.6504 3.330e-06 ***
beds_total1 -2.3587e+04 2.8561e+04 -0.8258 0.4088979
beds_total2 -1.7681e+04 2.8389e+04 -0.6228 0.5334006
beds_total3 -6.5354e+03 2.8382e+04 -0.2303 0.8178851
beds_total4 4.2790e+03 2.8401e+04 0.1507 0.8802419
beds_total5 -3.3027e+03 2.8823e+04 -0.1146 0.9087758
bath_full1 -6.1489e+04 2.6290e+04 -2.3389 0.0193500 *
bath_full2 -2.1927e+04 2.6289e+04 -0.8341 0.4042567
bath_full3 1.3858e+04 2.6368e+04 0.5256 0.5991889
bath_full4 2.8357e+04 3.2651e+04 0.8685 0.3851291
bath_full6 -3.1095e+04 2.6968e+04 -1.1530 0.2489081
bath_half1 1.8886e+04 1.1482e+03 16.4476 < 2.2e-16 ***
bath_half2 4.8238e+04 7.8696e+03 6.1297 8.941e-10 ***
bath_half3 7.2731e+04 9.2986e+03 7.8216 5.422e-15 ***
bath_half4 5.4252e+04 3.7348e+03 14.5260 < 2.2e-16 ***
bath_half5 -4.6137e+04 4.3195e+04 -1.0681 0.2854800
age -2.0686e+03 8.4213e+01 -24.5646 < 2.2e-16 ***
dom -5.5304e+01 5.9400e+00 -9.3105 < 2.2e-16 ***
sold_date 7.3968e-01 4.9301e-01 1.5003 0.1335451
sewer_typeseptic -6.2849e+03 1.4903e+03 -4.2172 2.482e-05 ***
sewer_typeunspecified -5.5157e+03 7.8378e+02 -7.0373 2.012e-12 ***
property_stylenot_mobile 7.3942e+04 1.7829e+03 41.4730 < 2.2e-16 ***
subdivision1 2.6493e+03 9.4525e+02 2.8027 0.0050715 **
water_typewell 3.0202e+03 4.2309e+03 0.7138 0.4753287
waterfront1 2.1510e+04 1.5564e+03 13.8205 < 2.2e-16 ***
age_2 1.9446e+01 1.1628e+00 16.7228 < 2.2e-16 ***
data_factor$infections_3mma 9.2081e+00 6.1300e-01 15.0215 < 2.2e-16 ***
top25_area_living 4.0139e+04 1.4153e+03 28.3605 < 2.2e-16 ***
data_factor$infections_3mma:top25_area_living 2.0383e+00 1.3222e+00 1.5416 0.1231878
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# Testing Corona, bottom 25% in area_living
lm_corona_area_living_bottom_single <- lm(sold_price ~ .
# test variable(s)
+ bottom25_area_living
# Removals
- area_living
- area_living_2
- beds_total
- property_type
,data = data_factor_core_clean)
coeftest(lm_corona_area_living_bottom_single, vcov = vcovHC(lm_corona_area_living_bottom_single, method = "White2", type = "HC0"))
t test of coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.4623e+05 2.4998e+04 5.8495 4.994e-09 ***
ac_typenone -4.3131e+04 1.9986e+03 -21.5804 < 2.2e-16 ***
ac_typenot_central -1.1880e+04 1.6531e+03 -7.1866 6.831e-13 ***
patio1 8.1355e+03 8.2430e+02 9.8696 < 2.2e-16 ***
school_general1 1.2600e+04 1.0891e+03 11.5695 < 2.2e-16 ***
photo_count 1.0088e+03 5.2232e+01 19.3134 < 2.2e-16 ***
pool1 1.5147e+04 1.4943e+03 10.1371 < 2.2e-16 ***
roof_typeother 4.6006e+03 1.4644e+03 3.1415 0.0016826 **
roof_typeshingle 2.4305e+04 1.6960e+03 14.3305 < 2.2e-16 ***
roof_typeslate 1.3619e+04 1.0266e+04 1.3266 0.1846620
gas_typenatural -6.4630e+04 3.6131e+03 -17.8879 < 2.2e-16 ***
gas_typenone -1.1360e+05 2.5199e+03 -45.0824 < 2.2e-16 ***
gas_typepropane -8.2205e+04 1.7647e+04 -4.6583 3.206e-06 ***
gas_typeunknown -1.1427e+05 2.3822e+03 -47.9700 < 2.2e-16 ***
out_building1 -4.5896e+03 8.8030e+02 -5.2137 1.866e-07 ***
land_acres 5.1522e+03 9.9255e+02 5.1908 2.110e-07 ***
appliances1 2.3044e+04 1.1784e+03 19.5551 < 2.2e-16 ***
garage1 1.5142e+04 8.1452e+02 18.5898 < 2.2e-16 ***
property_conditionnew -2.7414e+04 6.6885e+03 -4.0986 4.170e-05 ***
property_conditionother -2.2299e+04 1.0076e+03 -22.1304 < 2.2e-16 ***
energy_efficient1 1.5563e+04 8.9168e+02 17.4532 < 2.2e-16 ***
exterior_typemetal -2.5429e+03 2.3807e+03 -1.0682 0.2854612
exterior_typeother 1.1513e+04 1.1344e+03 10.1487 < 2.2e-16 ***
exterior_typevinyl 2.6720e+03 1.1781e+03 2.2680 0.0233390 *
exterior_typewood 3.9957e+03 1.8656e+03 2.1418 0.0322230 *
exterior_featurescourtyard 4.5991e+04 1.3706e+04 3.3555 0.0007933 ***
exterior_featuresfence -1.6005e+04 5.7564e+03 -2.7804 0.0054335 **
exterior_featuresnone -9.2429e+03 5.7742e+03 -1.6007 0.1094517
exterior_featuresporch -1.6564e+04 5.8349e+03 -2.8388 0.0045314 **
exterior_featurestennis_court 1.9290e+04 1.2593e+04 1.5319 0.1255637
fireplace1 2.1790e+04 8.4710e+02 25.7227 < 2.2e-16 ***
foundation_typeslab 1.2466e+04 1.3070e+03 9.5379 < 2.2e-16 ***
foundation_typeunspecified 6.5096e+03 1.4556e+03 4.4721 7.780e-06 ***
bath_full1 -5.9228e+04 2.2435e+04 -2.6400 0.0082970 **
bath_full2 -2.1396e+04 2.2433e+04 -0.9538 0.3402153
bath_full3 4.2221e+04 2.2514e+04 1.8753 0.0607589 .
bath_full4 5.8583e+04 3.0423e+04 1.9256 0.0541616 .
bath_full6 -2.0476e+02 2.2655e+04 -0.0090 0.9927888
bath_half1 3.0893e+04 1.1617e+03 26.5934 < 2.2e-16 ***
bath_half2 6.0766e+04 9.1825e+03 6.6176 3.726e-11 ***
bath_half3 6.2928e+04 6.4641e+03 9.7350 < 2.2e-16 ***
bath_half4 6.3182e+04 3.2458e+03 19.4655 < 2.2e-16 ***
bath_half5 -2.4624e+04 4.1344e+04 -0.5956 0.5514641
age -1.9493e+03 8.5339e+01 -22.8419 < 2.2e-16 ***
dom -5.1163e+01 6.1034e+00 -8.3828 < 2.2e-16 ***
sold_date 4.7273e+00 4.2935e-01 11.0105 < 2.2e-16 ***
sewer_typeseptic -6.6769e+03 1.5254e+03 -4.3772 1.207e-05 ***
sewer_typeunspecified -6.0742e+03 8.0293e+02 -7.5650 4.014e-14 ***
property_stylenot_mobile 6.6014e+04 1.7163e+03 38.4628 < 2.2e-16 ***
subdivision1 2.4811e+03 9.6233e+02 2.5782 0.0099368 **
water_typewell 4.3589e+03 4.2998e+03 1.0137 0.3107158
waterfront1 2.0595e+04 1.6200e+03 12.7130 < 2.2e-16 ***
age_2 1.8138e+01 1.1732e+00 15.4604 < 2.2e-16 ***
bottom25_area_living -2.8878e+04 8.6531e+02 -33.3730 < 2.2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
lm_corona_area_living_bottom <- lm(sold_price ~ .
# test variable(s)
+ data_factor$infections_3mma + bottom25_area_living + data_factor$infections_3mma*bottom25_area_living
# Removals
- area_living
- area_living_2
,data = data_factor_core_clean)
coeftest(lm_corona_area_living_bottom, vcov = vcovHC(lm_corona_area_living_bottom, method = "White2", type = "HC0"))
t test of coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 2.1339e+05 3.3909e+04 6.2930 3.167e-10 ***
property_typeDUP -4.1450e+04 1.3956e+04 -2.9700 0.002980 **
property_typeOTH 3.2243e+04 1.5969e+04 2.0191 0.043490 *
property_typePAT 1.6802e+04 6.1298e+03 2.7411 0.006129 **
property_typeSGL 3.1499e+04 2.8575e+03 11.0232 < 2.2e-16 ***
property_typeTNH -1.0751e+03 3.6228e+03 -0.2968 0.766651
ac_typenone -4.5749e+04 1.9656e+03 -23.2750 < 2.2e-16 ***
ac_typenot_central -1.3048e+04 1.6571e+03 -7.8737 3.585e-15 ***
patio1 8.2691e+03 8.1088e+02 10.1977 < 2.2e-16 ***
school_general1 1.0025e+04 1.0796e+03 9.2861 < 2.2e-16 ***
photo_count 1.0654e+03 5.1381e+01 20.7345 < 2.2e-16 ***
pool1 1.7630e+04 1.4758e+03 11.9461 < 2.2e-16 ***
roof_typeother 5.8738e+03 1.4607e+03 4.0213 5.805e-05 ***
roof_typeshingle 2.4781e+04 1.6803e+03 14.7482 < 2.2e-16 ***
roof_typeslate 1.5016e+04 1.0401e+04 1.4437 0.148832
gas_typenatural -7.2088e+04 3.6703e+03 -19.6407 < 2.2e-16 ***
gas_typenone -1.1453e+05 2.5305e+03 -45.2579 < 2.2e-16 ***
gas_typepropane -8.4275e+04 1.7473e+04 -4.8232 1.421e-06 ***
gas_typeunknown -1.1604e+05 2.4100e+03 -48.1506 < 2.2e-16 ***
out_building1 -5.3839e+03 8.6629e+02 -6.2148 5.220e-10 ***
land_acres 5.1387e+03 9.7520e+02 5.2694 1.380e-07 ***
appliances1 2.3783e+04 1.1649e+03 20.4166 < 2.2e-16 ***
garage1 1.3445e+04 8.0352e+02 16.7324 < 2.2e-16 ***
property_conditionnew -2.4761e+04 6.4570e+03 -3.8347 0.000126 ***
property_conditionother -2.0736e+04 9.9837e+02 -20.7701 < 2.2e-16 ***
energy_efficient1 1.4537e+04 8.7617e+02 16.5912 < 2.2e-16 ***
exterior_typemetal -1.8255e+03 2.3499e+03 -0.7768 0.437268
exterior_typeother 1.2592e+04 1.1204e+03 11.2388 < 2.2e-16 ***
exterior_typevinyl 3.1157e+03 1.1613e+03 2.6830 0.007302 **
exterior_typewood 3.0180e+03 1.8587e+03 1.6237 0.104449
exterior_featurescourtyard 3.7328e+04 1.3936e+04 2.6785 0.007400 **
exterior_featuresfence -3.2656e+04 5.6094e+03 -5.8217 5.897e-09 ***
exterior_featuresnone -2.5255e+04 5.6117e+03 -4.5004 6.814e-06 ***
exterior_featuresporch -3.2058e+04 5.6736e+03 -5.6505 1.618e-08 ***
exterior_featurestennis_court 5.4193e+03 1.2188e+04 0.4447 0.656574
fireplace1 2.0496e+04 8.3541e+02 24.5339 < 2.2e-16 ***
foundation_typeslab 1.3667e+04 1.3123e+03 10.4143 < 2.2e-16 ***
foundation_typeunspecified 7.7983e+03 1.4477e+03 5.3867 7.242e-08 ***
beds_total1 -2.4930e+04 2.6346e+04 -0.9463 0.344019
beds_total2 -2.8425e+04 2.6173e+04 -1.0860 0.277468
beds_total3 -3.1603e+04 2.6194e+04 -1.2065 0.227639
beds_total4 -1.3294e+04 2.6225e+04 -0.5069 0.612212
beds_total5 -1.7741e+04 2.6701e+04 -0.6644 0.506431
bath_full1 -4.9882e+04 2.7936e+04 -1.7856 0.074177 .
bath_full2 -1.2439e+04 2.7934e+04 -0.4453 0.656094
bath_full3 4.0427e+04 2.8004e+04 1.4436 0.148852
bath_full4 5.4599e+04 3.4427e+04 1.5859 0.112770
bath_full6 3.2827e+04 2.8680e+04 1.1446 0.252383
bath_half1 2.8883e+04 1.1610e+03 24.8787 < 2.2e-16 ***
bath_half2 5.8058e+04 8.7735e+03 6.6175 3.729e-11 ***
bath_half3 5.9695e+04 1.3787e+04 4.3299 1.498e-05 ***
bath_half4 6.4025e+04 3.3800e+03 18.9422 < 2.2e-16 ***
bath_half5 -3.7625e+04 3.9698e+04 -0.9478 0.343252
age -1.9340e+03 8.6008e+01 -22.4866 < 2.2e-16 ***
dom -5.2607e+01 5.9970e+00 -8.7722 < 2.2e-16 ***
sold_date 6.8952e-01 4.9820e-01 1.3840 0.166363
sewer_typeseptic -7.5605e+03 1.5115e+03 -5.0021 5.710e-07 ***
sewer_typeunspecified -6.8537e+03 7.9062e+02 -8.6688 < 2.2e-16 ***
property_stylenot_mobile 6.8228e+04 1.7363e+03 39.2941 < 2.2e-16 ***
subdivision1 2.6809e+03 9.5201e+02 2.8161 0.004866 **
water_typewell 2.2071e+03 4.2381e+03 0.5208 0.602522
waterfront1 2.1468e+04 1.5887e+03 13.5129 < 2.2e-16 ***
age_2 1.7967e+01 1.1910e+00 15.0862 < 2.2e-16 ***
data_factor$infections_3mma 1.0638e+01 6.7630e-01 15.7293 < 2.2e-16 ***
bottom25_area_living -2.3386e+04 9.1376e+02 -25.5936 < 2.2e-16 ***
data_factor$infections_3mma:bottom25_area_living -3.8844e+00 8.7552e-01 -4.4366 9.178e-06 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# Testing Corona, top 25% in dom
lm_corona_dom_top_single <- lm(sold_price ~ .
# test variable(s)
+ top25_dom
# Removals
- dom
- property_type
,data = data_factor_core_clean)
coeftest(lm_corona_dom_top_single, vcov = vcovHC(lm_corona_dom_top_single, method = "White2", type = "HC0"))
t test of coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.2470e+05 3.2991e+04 3.7800 0.0001572 ***
ac_typenone -4.4847e+04 1.9992e+03 -22.4322 < 2.2e-16 ***
ac_typenot_central -1.3445e+04 1.6029e+03 -8.3880 < 2.2e-16 ***
patio1 8.0691e+03 7.8569e+02 10.2702 < 2.2e-16 ***
school_general1 1.4857e+04 1.0368e+03 14.3292 < 2.2e-16 ***
photo_count 8.3099e+02 4.9333e+01 16.8447 < 2.2e-16 ***
pool1 1.1089e+04 1.3982e+03 7.9307 2.271e-15 ***
roof_typeother 2.7272e+03 1.4548e+03 1.8746 0.0608529 .
roof_typeshingle 2.0883e+04 1.6609e+03 12.5728 < 2.2e-16 ***
roof_typeslate 9.6412e+03 9.7100e+03 0.9929 0.3207621
gas_typenatural -9.4865e+04 3.6049e+03 -26.3158 < 2.2e-16 ***
gas_typenone -1.3907e+05 2.4664e+03 -56.3876 < 2.2e-16 ***
gas_typepropane -1.1056e+05 1.7803e+04 -6.2102 5.375e-10 ***
gas_typeunknown -1.4437e+05 2.3535e+03 -61.3424 < 2.2e-16 ***
out_building1 -5.2648e+03 8.3549e+02 -6.3014 2.999e-10 ***
area_living 3.1019e+01 6.2202e+00 4.9869 6.178e-07 ***
land_acres 1.8828e+03 9.4401e+02 1.9944 0.0461176 *
appliances1 2.4311e+04 1.1457e+03 21.2200 < 2.2e-16 ***
garage1 1.2957e+04 7.7896e+02 16.6333 < 2.2e-16 ***
property_conditionnew -2.7158e+04 6.6441e+03 -4.0875 4.374e-05 ***
property_conditionother -2.2154e+04 9.4462e+02 -23.4530 < 2.2e-16 ***
energy_efficient1 1.4143e+04 8.4891e+02 16.6600 < 2.2e-16 ***
exterior_typemetal -8.5264e+02 2.3831e+03 -0.3578 0.7205107
exterior_typeother 1.0680e+04 1.0827e+03 9.8638 < 2.2e-16 ***
exterior_typevinyl 4.5067e+03 1.1210e+03 4.0204 5.828e-05 ***
exterior_typewood 4.3375e+03 1.7978e+03 2.4126 0.0158453 *
exterior_featurescourtyard 4.0243e+04 1.4153e+04 2.8435 0.0044657 **
exterior_featuresfence -2.3246e+04 5.4232e+03 -4.2864 1.823e-05 ***
exterior_featuresnone -1.7002e+04 5.4354e+03 -3.1280 0.0017623 **
exterior_featuresporch -2.4225e+04 5.4915e+03 -4.4113 1.032e-05 ***
exterior_featurestennis_court 7.1824e+03 1.0842e+04 0.6625 0.5076678
fireplace1 1.1784e+04 8.4492e+02 13.9469 < 2.2e-16 ***
foundation_typeslab 1.3607e+04 1.3042e+03 10.4331 < 2.2e-16 ***
foundation_typeunspecified 6.9839e+03 1.4409e+03 4.8468 1.262e-06 ***
beds_total1 -3.1548e+04 2.6184e+04 -1.2048 0.2282745
beds_total2 -3.6745e+04 2.6085e+04 -1.4087 0.1589396
beds_total3 -3.7465e+04 2.6123e+04 -1.4341 0.1515431
beds_total4 -3.4453e+04 2.6157e+04 -1.3171 0.1878044
beds_total5 -5.2479e+04 2.6588e+04 -1.9738 0.0484159 *
bath_full1 -3.4078e+04 2.3250e+04 -1.4657 0.1427488
bath_full2 -1.0838e+04 2.3237e+04 -0.4664 0.6409256
bath_full3 1.5039e+04 2.3333e+04 0.6446 0.5192196
bath_full4 1.8535e+04 2.9735e+04 0.6233 0.5330666
bath_full6 -1.5995e+04 2.3944e+04 -0.6680 0.5041164
bath_half1 1.2379e+04 1.1391e+03 10.8674 < 2.2e-16 ***
bath_half2 3.7064e+04 7.9628e+03 4.6546 3.263e-06 ***
bath_half3 5.8505e+04 9.5532e+03 6.1241 9.257e-10 ***
bath_half4 8.5916e+04 3.1807e+03 27.0116 < 2.2e-16 ***
bath_half5 -6.3161e+04 2.6195e+04 -2.4112 0.0159057 *
age -2.0104e+03 8.4462e+01 -23.8026 < 2.2e-16 ***
sold_date 5.0869e+00 4.0026e-01 12.7090 < 2.2e-16 ***
sewer_typeseptic -5.9494e+03 1.4742e+03 -4.0358 5.459e-05 ***
sewer_typeunspecified -4.7149e+03 7.6262e+02 -6.1825 6.408e-10 ***
property_stylenot_mobile 6.8797e+04 1.7776e+03 38.7029 < 2.2e-16 ***
subdivision1 3.0392e+03 9.2692e+02 3.2788 0.0010439 **
water_typewell 4.2467e+03 4.1489e+03 1.0236 0.3060557
waterfront1 2.0239e+04 1.5226e+03 13.2922 < 2.2e-16 ***
age_2 1.8290e+01 1.1850e+00 15.4341 < 2.2e-16 ***
area_living_2 9.6112e-03 1.7842e-03 5.3870 7.232e-08 ***
top25_dom -5.4788e+03 8.3697e+02 -6.5460 6.025e-11 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
lm_corona_dom_top <- lm(sold_price ~ .
# test variable(s)
+ data_factor$infections_3mma + top25_dom + data_factor$infections_3mma*top25_dom
# Removals
- dom
- property_type
,data = data_factor_core_clean)
coeftest(lm_corona_dom_top, vcov = vcovHC(lm_corona_dom_top, method = "White2", type = "HC0"))
t test of coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.7948e+05 3.3205e+04 5.4050 6.541e-08 ***
ac_typenone -4.4730e+04 1.9805e+03 -22.5854 < 2.2e-16 ***
ac_typenot_central -1.3054e+04 1.6034e+03 -8.1416 4.084e-16 ***
patio1 7.9080e+03 7.8073e+02 10.1290 < 2.2e-16 ***
school_general1 1.2213e+04 1.0387e+03 11.7583 < 2.2e-16 ***
photo_count 8.8849e+02 4.9152e+01 18.0765 < 2.2e-16 ***
pool1 1.1060e+04 1.3941e+03 7.9333 2.224e-15 ***
roof_typeother 2.7811e+03 1.4512e+03 1.9164 0.0553315 .
roof_typeshingle 2.0583e+04 1.6549e+03 12.4373 < 2.2e-16 ***
roof_typeslate 9.5185e+03 9.7679e+03 0.9745 0.3298348
gas_typenatural -9.4433e+04 3.6198e+03 -26.0878 < 2.2e-16 ***
gas_typenone -1.3610e+05 2.4576e+03 -55.3814 < 2.2e-16 ***
gas_typepropane -1.0752e+05 1.7875e+04 -6.0153 1.821e-09 ***
gas_typeunknown -1.4034e+05 2.3519e+03 -59.6721 < 2.2e-16 ***
out_building1 -5.0394e+03 8.2968e+02 -6.0739 1.267e-09 ***
area_living 3.2463e+01 6.2066e+00 5.2305 1.705e-07 ***
land_acres 3.1448e+03 9.4134e+02 3.3408 0.0008365 ***
appliances1 2.4289e+04 1.1365e+03 21.3720 < 2.2e-16 ***
garage1 1.2562e+04 7.7409e+02 16.2281 < 2.2e-16 ***
property_conditionnew -2.4544e+04 6.4894e+03 -3.7821 0.0001558 ***
property_conditionother -2.0626e+04 9.5003e+02 -21.7113 < 2.2e-16 ***
energy_efficient1 1.3893e+04 8.4555e+02 16.4307 < 2.2e-16 ***
exterior_typemetal -1.4238e+02 2.3829e+03 -0.0598 0.9523530
exterior_typeother 1.1436e+04 1.0807e+03 10.5821 < 2.2e-16 ***
exterior_typevinyl 4.8014e+03 1.1179e+03 4.2950 1.754e-05 ***
exterior_typewood 3.4028e+03 1.7980e+03 1.8926 0.0584240 .
exterior_featurescourtyard 4.0103e+04 1.4241e+04 2.8160 0.0048663 **
exterior_featuresfence -2.2495e+04 5.4678e+03 -4.1141 3.899e-05 ***
exterior_featuresnone -1.5931e+04 5.4798e+03 -2.9072 0.0036503 **
exterior_featuresporch -2.2860e+04 5.5346e+03 -4.1304 3.634e-05 ***
exterior_featurestennis_court 7.6760e+03 1.0757e+04 0.7136 0.4754853
fireplace1 1.1863e+04 8.3861e+02 14.1460 < 2.2e-16 ***
foundation_typeslab 1.3443e+04 1.2971e+03 10.3637 < 2.2e-16 ***
foundation_typeunspecified 7.7274e+03 1.4361e+03 5.3809 7.479e-08 ***
beds_total1 -2.8749e+04 2.7079e+04 -1.0617 0.2883917
beds_total2 -3.3427e+04 2.6976e+04 -1.2391 0.2153123
beds_total3 -3.3912e+04 2.7012e+04 -1.2554 0.2093403
beds_total4 -3.1091e+04 2.7044e+04 -1.1496 0.2503041
beds_total5 -4.9261e+04 2.7459e+04 -1.7940 0.0728228 .
bath_full1 -3.3557e+04 2.4476e+04 -1.3710 0.1703787
bath_full2 -1.0693e+04 2.4464e+04 -0.4371 0.6620550
bath_full3 1.5054e+04 2.4556e+04 0.6131 0.5398357
bath_full4 1.8395e+04 3.0632e+04 0.6005 0.5481560
bath_full6 -1.0150e+04 2.5149e+04 -0.4036 0.6865202
bath_half1 1.2557e+04 1.1350e+03 11.0641 < 2.2e-16 ***
bath_half2 3.8142e+04 7.8947e+03 4.8313 1.364e-06 ***
bath_half3 6.0182e+04 8.8394e+03 6.8084 1.010e-11 ***
bath_half4 7.8079e+04 3.2124e+03 24.3053 < 2.2e-16 ***
bath_half5 -6.1970e+04 2.7087e+04 -2.2879 0.0221543 *
age -2.0486e+03 8.4283e+01 -24.3066 < 2.2e-16 ***
sold_date 1.0370e+00 4.7266e-01 2.1940 0.0282462 *
sewer_typeseptic -6.1036e+03 1.4684e+03 -4.1566 3.241e-05 ***
sewer_typeunspecified -4.9187e+03 7.5653e+02 -6.5016 8.098e-11 ***
property_stylenot_mobile 6.8413e+04 1.7752e+03 38.5373 < 2.2e-16 ***
subdivision1 3.2389e+03 9.2307e+02 3.5088 0.0004509 ***
water_typewell 2.3943e+03 4.0983e+03 0.5842 0.5590784
waterfront1 2.0324e+04 1.5150e+03 13.4154 < 2.2e-16 ***
age_2 1.8778e+01 1.1829e+00 15.8751 < 2.2e-16 ***
area_living_2 9.2711e-03 1.7800e-03 5.2084 1.921e-07 ***
data_factor$infections_3mma 1.0252e+01 5.9160e-01 17.3288 < 2.2e-16 ***
top25_dom -4.2113e+03 8.6133e+02 -4.8893 1.018e-06 ***
data_factor$infections_3mma:top25_dom -8.4965e+00 1.6547e+00 -5.1347 2.847e-07 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# Testing Corona, bottom 25% in dom
lm_corona_dom_bottom_single <- lm(sold_price ~ .
# test variable(s)
+ bottom25_dom
# Removals
- dom
- property_type
,data = data_factor_core_clean)
coeftest(lm_corona_dom_bottom_single, vcov = vcovHC(lm_corona_dom_bottom_single, method = "White2", type = "HC0"))
t test of coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.2706e+05 3.2132e+04 3.9542 7.701e-05 ***
ac_typenone -4.3428e+04 2.0007e+03 -21.7065 < 2.2e-16 ***
ac_typenot_central -1.3572e+04 1.5888e+03 -8.5425 < 2.2e-16 ***
patio1 7.8861e+03 7.8137e+02 10.0927 < 2.2e-16 ***
school_general1 1.3144e+04 1.0313e+03 12.7454 < 2.2e-16 ***
photo_count 9.3706e+02 4.9300e+01 19.0074 < 2.2e-16 ***
pool1 1.0660e+04 1.3955e+03 7.6388 2.273e-14 ***
roof_typeother 2.5955e+03 1.4415e+03 1.8006 0.0717797 .
roof_typeshingle 2.0010e+04 1.6493e+03 12.1320 < 2.2e-16 ***
roof_typeslate 1.0006e+04 9.9080e+03 1.0099 0.3125725
gas_typenatural -9.0333e+04 3.6160e+03 -24.9811 < 2.2e-16 ***
gas_typenone -1.3101e+05 2.5090e+03 -52.2177 < 2.2e-16 ***
gas_typepropane -1.0235e+05 1.7750e+04 -5.7665 8.191e-09 ***
gas_typeunknown -1.3585e+05 2.4032e+03 -56.5283 < 2.2e-16 ***
out_building1 -5.2509e+03 8.3121e+02 -6.3172 2.710e-10 ***
area_living 3.1698e+01 6.2022e+00 5.1108 3.231e-07 ***
land_acres 2.9660e+03 9.4722e+02 3.1312 0.0017428 **
appliances1 2.4602e+04 1.1398e+03 21.5846 < 2.2e-16 ***
garage1 1.2645e+04 7.7359e+02 16.3455 < 2.2e-16 ***
property_conditionnew -2.5917e+04 6.6600e+03 -3.8914 9.995e-05 ***
property_conditionother -2.1850e+04 9.4271e+02 -23.1777 < 2.2e-16 ***
energy_efficient1 1.4567e+04 8.4541e+02 17.2310 < 2.2e-16 ***
exterior_typemetal -6.8937e+02 2.3682e+03 -0.2911 0.7709792
exterior_typeother 1.1311e+04 1.0766e+03 10.5065 < 2.2e-16 ***
exterior_typevinyl 5.1421e+03 1.1141e+03 4.6153 3.945e-06 ***
exterior_typewood 4.3924e+03 1.7826e+03 2.4641 0.0137444 *
exterior_featurescourtyard 4.0656e+04 1.4367e+04 2.8298 0.0046612 **
exterior_featuresfence -2.2879e+04 5.4335e+03 -4.2108 2.553e-05 ***
exterior_featuresnone -1.7045e+04 5.4452e+03 -3.1302 0.0017488 **
exterior_featuresporch -2.4256e+04 5.5006e+03 -4.4097 1.040e-05 ***
exterior_featurestennis_court 7.3513e+03 1.0947e+04 0.6715 0.5018936
fireplace1 1.1889e+04 8.3930e+02 14.1654 < 2.2e-16 ***
foundation_typeslab 1.3348e+04 1.2933e+03 10.3208 < 2.2e-16 ***
foundation_typeunspecified 7.2714e+03 1.4323e+03 5.0767 3.869e-07 ***
beds_total1 -3.1021e+04 2.6293e+04 -1.1798 0.2380877
beds_total2 -3.6603e+04 2.6199e+04 -1.3971 0.1623987
beds_total3 -3.7346e+04 2.6237e+04 -1.4234 0.1546284
beds_total4 -3.4058e+04 2.6270e+04 -1.2964 0.1948332
beds_total5 -5.1862e+04 2.6692e+04 -1.9430 0.0520310 .
bath_full1 -3.4740e+04 2.2065e+04 -1.5744 0.1154034
bath_full2 -1.1989e+04 2.2049e+04 -0.5438 0.5866066
bath_full3 1.3823e+04 2.2148e+04 0.6241 0.5325379
bath_full4 1.6881e+04 2.8566e+04 0.5910 0.5545589
bath_full6 -1.6755e+04 2.2777e+04 -0.7356 0.4619952
bath_half1 1.2478e+04 1.1356e+03 10.9880 < 2.2e-16 ***
bath_half2 3.6771e+04 7.8471e+03 4.6859 2.802e-06 ***
bath_half3 5.6501e+04 1.2623e+04 4.4760 7.640e-06 ***
bath_half4 9.1527e+04 3.1697e+03 28.8756 < 2.2e-16 ***
bath_half5 -5.7957e+04 2.6445e+04 -2.1916 0.0284204 *
age -2.0216e+03 8.4070e+01 -24.0462 < 2.2e-16 ***
sold_date 4.0865e+00 4.0490e-01 10.0925 < 2.2e-16 ***
sewer_typeseptic -5.8848e+03 1.4616e+03 -4.0262 5.686e-05 ***
sewer_typeunspecified -4.5694e+03 7.5987e+02 -6.0134 1.843e-09 ***
property_stylenot_mobile 6.8383e+04 1.7723e+03 38.5834 < 2.2e-16 ***
subdivision1 3.4985e+03 9.2266e+02 3.7918 0.0001499 ***
water_typewell 3.1693e+03 4.0651e+03 0.7796 0.4356106
waterfront1 2.0223e+04 1.5104e+03 13.3887 < 2.2e-16 ***
age_2 1.8513e+01 1.1798e+00 15.6919 < 2.2e-16 ***
area_living_2 9.3801e-03 1.7797e-03 5.2706 1.372e-07 ***
bottom25_dom 1.4126e+04 9.0523e+02 15.6044 < 2.2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
lm_corona_dom_bottom <- lm(sold_price ~ .
# test variable(s)
+ data_factor$infections_3mma + bottom25_dom + data_factor$infections_3mma*bottom25_dom
# Removals
- dom
- property_type
,data = data_factor_core_clean)
coeftest(lm_corona_dom_bottom, vcov = vcovHC(lm_corona_dom_bottom, method = "White2", type = "HC0"))
t test of coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.8708e+05 3.2369e+04 5.7796 7.578e-09 ***
ac_typenone -4.3502e+04 1.9826e+03 -21.9419 < 2.2e-16 ***
ac_typenot_central -1.3181e+04 1.5901e+03 -8.2895 < 2.2e-16 ***
patio1 7.7980e+03 7.7727e+02 10.0326 < 2.2e-16 ***
school_general1 1.0761e+04 1.0337e+03 10.4104 < 2.2e-16 ***
photo_count 9.9320e+02 4.9250e+01 20.1664 < 2.2e-16 ***
pool1 1.0726e+04 1.3912e+03 7.7098 1.307e-14 ***
roof_typeother 2.7998e+03 1.4391e+03 1.9455 0.0517306 .
roof_typeshingle 1.9954e+04 1.6443e+03 12.1353 < 2.2e-16 ***
roof_typeslate 1.0039e+04 9.9523e+03 1.0087 0.3131423
gas_typenatural -9.0369e+04 3.6267e+03 -24.9175 < 2.2e-16 ***
gas_typenone -1.2972e+05 2.5068e+03 -51.7475 < 2.2e-16 ***
gas_typepropane -1.0043e+05 1.7888e+04 -5.6147 1.991e-08 ***
gas_typeunknown -1.3365e+05 2.4104e+03 -55.4476 < 2.2e-16 ***
out_building1 -5.1575e+03 8.2715e+02 -6.2352 4.585e-10 ***
area_living 3.3177e+01 6.1916e+00 5.3584 8.472e-08 ***
land_acres 3.3123e+03 9.5344e+02 3.4740 0.0005136 ***
appliances1 2.4473e+04 1.1320e+03 21.6202 < 2.2e-16 ***
garage1 1.2334e+04 7.6942e+02 16.0305 < 2.2e-16 ***
property_conditionnew -2.3336e+04 6.5133e+03 -3.5829 0.0003405 ***
property_conditionother -2.0485e+04 9.4800e+02 -21.6090 < 2.2e-16 ***
energy_efficient1 1.4336e+04 8.4221e+02 17.0216 < 2.2e-16 ***
exterior_typemetal -9.4351e+01 2.3687e+03 -0.0398 0.9682277
exterior_typeother 1.2027e+04 1.0753e+03 11.1843 < 2.2e-16 ***
exterior_typevinyl 5.5264e+03 1.1123e+03 4.9682 6.802e-07 ***
exterior_typewood 3.7714e+03 1.7809e+03 2.1177 0.0342126 *
exterior_featurescourtyard 4.0526e+04 1.4388e+04 2.8167 0.0048552 **
exterior_featuresfence -2.2187e+04 5.4551e+03 -4.0673 4.770e-05 ***
exterior_featuresnone -1.6005e+04 5.4667e+03 -2.9277 0.0034174 **
exterior_featuresporch -2.3004e+04 5.5210e+03 -4.1666 3.103e-05 ***
exterior_featurestennis_court 7.5932e+03 1.0821e+04 0.7017 0.4828551
fireplace1 1.1940e+04 8.3389e+02 14.3183 < 2.2e-16 ***
foundation_typeslab 1.3321e+04 1.2877e+03 10.3450 < 2.2e-16 ***
foundation_typeunspecified 7.8067e+03 1.4283e+03 5.4656 4.658e-08 ***
beds_total1 -2.9076e+04 2.6956e+04 -1.0786 0.2807572
beds_total2 -3.4438e+04 2.6858e+04 -1.2822 0.1997713
beds_total3 -3.4970e+04 2.6893e+04 -1.3003 0.1935003
beds_total4 -3.1785e+04 2.6925e+04 -1.1805 0.2378043
beds_total5 -4.9896e+04 2.7337e+04 -1.8252 0.0679782 .
bath_full1 -3.3866e+04 2.3351e+04 -1.4503 0.1469909
bath_full2 -1.1397e+04 2.3337e+04 -0.4884 0.6252799
bath_full3 1.4332e+04 2.3430e+04 0.6117 0.5407548
bath_full4 1.7551e+04 2.9478e+04 0.5954 0.5515762
bath_full6 -1.5768e+04 2.4025e+04 -0.6563 0.5116069
bath_half1 1.2603e+04 1.1311e+03 11.1419 < 2.2e-16 ***
bath_half2 3.7982e+04 7.7802e+03 4.8819 1.057e-06 ***
bath_half3 5.7772e+04 1.2170e+04 4.7472 2.074e-06 ***
bath_half4 8.2835e+04 3.2808e+03 25.2484 < 2.2e-16 ***
bath_half5 -5.7385e+04 2.7280e+04 -2.1036 0.0354271 *
age -2.0364e+03 8.3985e+01 -24.2475 < 2.2e-16 ***
sold_date -6.4800e-02 4.7932e-01 -0.1352 0.8924613
sewer_typeseptic -5.7769e+03 1.4590e+03 -3.9596 7.529e-05 ***
sewer_typeunspecified -4.6494e+03 7.5422e+02 -6.1646 7.177e-10 ***
property_stylenot_mobile 6.7806e+04 1.7712e+03 38.2830 < 2.2e-16 ***
subdivision1 3.5519e+03 9.1933e+02 3.8636 0.0001120 ***
water_typewell 1.5226e+03 4.0416e+03 0.3767 0.7063762
waterfront1 2.0260e+04 1.5043e+03 13.4680 < 2.2e-16 ***
age_2 1.8678e+01 1.1788e+00 15.8454 < 2.2e-16 ***
area_living_2 8.9998e-03 1.7761e-03 5.0672 4.067e-07 ***
data_factor$infections_3mma 1.0360e+01 7.4316e-01 13.9409 < 2.2e-16 ***
bottom25_dom 1.4593e+04 1.0153e+03 14.3736 < 2.2e-16 ***
data_factor$infections_3mma:bottom25_dom -2.1908e+00 9.2971e-01 -2.3564 0.0184597 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# top 25% is too tight!! means aren't different
# this means that the premium for being in the bottom percentile of dom decreased. This make's sense because this was no longer a result of increased quality but increased demand.
# Conditional Mean
library(plyr)
city_limits_mean_data <- ddply(data_factor, "city_limits", summarise, city_limits_mean = mean(sold_price, na.rm = TRUE))
# Distribution: Just City
ggplot(data = subset(data_factor, data_factor$city_limits ==1), aes(x = sold_price)) +
geom_density(alpha = 0.5, position = "identity", fill = "#ff6c67") +
ggtitle("city_limits Distributions") +
geom_vline(aes(xintercept = mean(city_limits)), linetype="dashed", size= 0.4, alpha = 0.5)
Warning in mean.default(city_limits) :
argument is not numeric or logical: returning NA
Warning: Removed 23635 rows containing missing values (geom_vline).
# Distribution: Infection
ggplot(data_factor, aes(x = sold_price, fill = city_limits)) +
geom_density(alpha = 0.5, position = "identity") +
ggtitle("city_limits Distributions") +
geom_vline(data = city_limits_mean_data, aes(xintercept = city_limits_mean_data[2,2]), linetype="dashed", size= 0.5, color = "#00c2c6", alpha = 0.8) +
geom_vline(data = city_limits_mean_data, aes(xintercept = city_limits_mean_data[1,2]), linetype="dashed", size= 0.5, alpha = 0.8, color = "#ff6c67")
#city_limits on Infections
ggplot(data_factor, aes(x = infections_period, y = city_limits, fill = infections_period)) +
geom_violin(alpha = 0.5) +
geom_boxplot(width=0.1) +
scale_fill_viridis(discrete = TRUE, alpha=0.6, option="D") +
#coord_flip() +
theme_ipsum() +
theme(
legend.position="none",
plot.title = element_text(size=11)) +
ggtitle("Comparison of city_limits") +
xlab("Infections Present (1 = yes)") +
scale_fill_manual(values=c("#ff6c67", "#00c2c6"))
Scale for 'fill' is already present. Adding another scale for 'fill', which will replace the existing scale.
coeftest(lm_corona_city, vcov = vcovHC(lm_corona_city, method = "White2", type = "HC0"))
t test of coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.7861e+05 3.3976e+04 5.2570 1.477e-07 ***
property_typeDUP -5.2256e+04 1.5467e+04 -3.3785 0.0007300 ***
property_typeOTH 2.5209e+04 1.5054e+04 1.6746 0.0940318 .
property_typePAT 1.6422e+04 5.5954e+03 2.9350 0.0033385 **
property_typeSGL 2.2707e+04 2.7116e+03 8.3742 < 2.2e-16 ***
property_typeTNH -3.4785e+03 3.3351e+03 -1.0430 0.2969503
ac_typenone -4.5713e+04 1.9689e+03 -23.2178 < 2.2e-16 ***
ac_typenot_central -1.3706e+04 1.5987e+03 -8.5732 < 2.2e-16 ***
patio1 8.1712e+03 7.7788e+02 10.5044 < 2.2e-16 ***
school_general1 1.1846e+04 1.0460e+03 11.3259 < 2.2e-16 ***
photo_count 9.1824e+02 4.8848e+01 18.7978 < 2.2e-16 ***
pool1 1.3109e+04 1.3993e+03 9.3684 < 2.2e-16 ***
roof_typeother 3.6223e+03 1.4471e+03 2.5032 0.0123145 *
roof_typeshingle 2.1298e+04 1.6497e+03 12.9106 < 2.2e-16 ***
roof_typeslate 1.0056e+04 9.8591e+03 1.0200 0.3077618
gas_typenatural -8.9629e+04 3.6449e+03 -24.5899 < 2.2e-16 ***
gas_typenone -1.3151e+05 2.4644e+03 -53.3656 < 2.2e-16 ***
gas_typepropane -9.9907e+04 1.8268e+04 -5.4690 4.571e-08 ***
gas_typeunknown -1.3692e+05 2.3453e+03 -58.3818 < 2.2e-16 ***
out_building1 -6.1045e+03 8.2702e+02 -7.3814 1.616e-13 ***
area_living 3.2060e+01 6.1705e+00 5.1957 2.056e-07 ***
land_acres 2.0637e+03 9.4585e+02 2.1819 0.0291294 *
appliances1 2.4475e+04 1.1334e+03 21.5939 < 2.2e-16 ***
garage1 1.2014e+04 7.7206e+02 15.5615 < 2.2e-16 ***
property_conditionnew -2.1188e+04 6.2676e+03 -3.3805 0.0007246 ***
property_conditionother -2.1335e+04 9.5483e+02 -22.3443 < 2.2e-16 ***
energy_efficient1 1.3986e+04 8.4013e+02 16.6469 < 2.2e-16 ***
exterior_typemetal -7.3384e+01 2.3631e+03 -0.0311 0.9752273
exterior_typeother 1.1645e+04 1.0751e+03 10.8307 < 2.2e-16 ***
exterior_typevinyl 5.0111e+03 1.1136e+03 4.5001 6.823e-06 ***
exterior_typewood 3.7778e+03 1.7816e+03 2.1205 0.0339778 *
exterior_featurescourtyard 3.3821e+04 1.4091e+04 2.4002 0.0163944 *
exterior_featuresfence -3.1962e+04 5.3284e+03 -5.9984 2.021e-09 ***
exterior_featuresnone -2.4953e+04 5.3355e+03 -4.6769 2.928e-06 ***
exterior_featuresporch -3.2028e+04 5.3922e+03 -5.9396 2.895e-09 ***
exterior_featurestennis_court -5.6576e+02 1.0551e+04 -0.0536 0.9572380
fireplace1 1.1828e+04 8.3361e+02 14.1887 < 2.2e-16 ***
foundation_typeslab 1.4938e+04 1.2903e+03 11.5773 < 2.2e-16 ***
foundation_typeunspecified 8.3762e+03 1.4287e+03 5.8630 4.604e-09 ***
beds_total1 -3.0336e+04 2.5401e+04 -1.1943 0.2323774
beds_total2 -3.8930e+04 2.5313e+04 -1.5379 0.1240784
beds_total3 -4.5128e+04 2.5374e+04 -1.7785 0.0753342 .
beds_total4 -4.2724e+04 2.5412e+04 -1.6812 0.0927301 .
beds_total5 -6.0622e+04 2.5853e+04 -2.3449 0.0190400 *
bath_full1 -3.2997e+04 2.5077e+04 -1.3158 0.1882552
bath_full2 -8.1502e+03 2.5069e+04 -0.3251 0.7450976
bath_full3 1.8659e+04 2.5159e+04 0.7416 0.4583086
bath_full4 2.1358e+04 3.1105e+04 0.6866 0.4923183
bath_full6 1.9232e+04 2.5880e+04 0.7431 0.4574071
bath_half1 1.4021e+04 1.1345e+03 12.3586 < 2.2e-16 ***
bath_half2 3.8677e+04 7.9272e+03 4.8790 1.073e-06 ***
bath_half3 5.8459e+04 1.0835e+04 5.3952 6.909e-08 ***
bath_half4 7.1968e+04 3.2187e+03 22.3594 < 2.2e-16 ***
bath_half5 -6.1887e+04 2.7837e+04 -2.2232 0.0262144 *
age -2.0199e+03 8.4330e+01 -23.9525 < 2.2e-16 ***
dom -6.2165e+01 5.7948e+00 -10.7278 < 2.2e-16 ***
sold_date 3.8776e-01 4.7523e-01 0.8159 0.4145389
sewer_typeseptic -5.7389e+03 1.4748e+03 -3.8912 1.000e-04 ***
sewer_typeunspecified -4.6601e+03 7.5909e+02 -6.1391 8.424e-10 ***
property_stylenot_mobile 6.8636e+04 1.7654e+03 38.8784 < 2.2e-16 ***
subdivision1 3.6139e+03 9.1778e+02 3.9376 8.252e-05 ***
water_typewell 5.8505e+03 4.1916e+03 1.3958 0.1627978
waterfront1 2.0355e+04 1.5069e+03 13.5081 < 2.2e-16 ***
age_2 1.8234e+01 1.1843e+00 15.3960 < 2.2e-16 ***
area_living_2 9.0448e-03 1.7690e-03 5.1129 3.197e-07 ***
data_factor$infections_3mma 5.1147e+00 1.6642e+00 3.0733 0.0021194 **
data_factor$city_limits1 7.2944e+03 2.2063e+03 3.3062 0.0009470 ***
data_factor$infections_3mma:data_factor$city_limits1 4.9912e+00 1.6744e+00 2.9809 0.0028764 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
data_index <- read_excel("/Users/sawyerbenson/Documents/Master Thesis/Thesis_Github/Models/Data/New Data/Index_hardkey.xlsx")
attach(data_index)
The following objects are masked from data_index (pos = 6):
Date, lma_2m, lma_2m_index, lma_3m, lma_3m_index, lma_4m, lma_4m_index, lma_5m, lma_5m_index,
log_wappsf, ma_2m, ma_3m, ma_4m, ma_5m, wappsf
data_index_fred <- read_excel("/Users/sawyerbenson/Documents/Master Thesis/Thesis_Github/Models/Data/New Data/Index_FRED.xls")
attach(data_index_fred)
The following object is masked from data_index_gdp:
date
The following objects are masked from data_index_fred (pos = 6):
date, index_Q1_1980
data_index_gdp <- read_excel("/Users/sawyerbenson/Documents/Master Thesis/Thesis_Github/Models/Data/New Data/la_GDP.xls")
attach(data_index_gdp)
The following object is masked from data_index_fred (pos = 3):
date
The following objects are masked from data_index_gdp (pos = 6):
date, real_gdp, real_gdp_Index, real_gdp_re_specific, real_gdp_re_specific_index
The following object is masked from data_index_fred (pos = 7):
date
# Index graphing
ggplot(data_index, aes(x = Date)) +
geom_line(mapping = aes(y = lma_2m_index), color = "darkred") +
geom_line(mapping = aes(y = lma_3m_index), color = "darkgreen") +
geom_line(mapping = aes(y = lma_4m_index), color = "darkblue") +
geom_line(mapping = aes(y = lma_5m_index), color = "grey45") +
geom_vline(xintercept = as.numeric(as.Date("2020-03-23")), linetype=4, color = "green") +
#scale_x_date(limits = as.Date(c("2020-01-01", "2021-12-31"))) +
scale_y_continuous(limits = c(min(lma_2m_index),max(lma_2m_index))) +
xlab(" ") +
ylab("Weighted Average Price per Sqft.") +
labs(title = "Louisiana Housing Index",
caption = "")
# FRED quarterly data
ggplot(data_index_fred, aes(x = date)) +
geom_line(aes(y = index_Q1_1980), color = "darkred") +
theme_minimal() +
geom_vline(xintercept = as.Date("2020-01-01"), linetype=4, color = "green") +
#scale_x_date(limits = as.Date(c("2020-01-01", "2021-12-31"))) +
scale_y_continuous(limits = c(min(index_Q1_1980),max(index_Q1_1980))) +
xlab(" ") +
ylab("Index Value") +
labs(title = "Louisiana Housing Index: FRED St. Louis",
caption = "")
# La Real GDP data quarterly data
data_index_gdp <- subset(data_index_gdp, data_index_gdp$date >= as.Date("2010-10-01"))
ggplot(data_index_gdp, aes(x = date)) +
geom_line(aes(y = real_gdp_Index), color = "darkred", linetype = "dashed") +
geom_line(aes(y = real_gdp_re_specific_index), color = "darkblue") +
theme_minimal() +
geom_vline(xintercept = as.Date("2020-01-01"), linetype=4, color = "green") +
#scale_x_date(limits = as.Date(c("2020-01-01", "2021-12-31"))) +
#scale_y_continuous(limits = c(min(real_gdp_Index),max(real_gdp_Index))) +
xlab(" ") +
ylab("Index Value") +
labs(title = "Louisiana Housing Index: FRED St. Louis",
caption = "")
cor.test(real_gdp_Index, real_gdp_re_specific_index)
Pearson's product-moment correlation
data: real_gdp_Index and real_gdp_re_specific_index
t = -2.0521, df = 65, p-value = 0.04419
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
-0.459638677 -0.006861981
sample estimates:
cor
-0.246664
# packages
require(ggplot2)
install.packages("ggmap")
require(maps)
install.packages(Geoc)
#Basic Map
LA <- map_data("state", region="louisiana")
ggplot(LA, aes(x=long, y=lat))+geom_polygon()
# data
salesCalls <- data.frame(State=rep("louisiana",5),
City=c("Baton Rouge","New Orleans", "Shreveport", "Lafayette", "Mandeville"),
Calls=c(10,5,8,13,2))
salesCalls <- cbind(geocode(as.character(salesCalls$City)), salesCalls)
?cbind
ggplot(LA, aes(x=long, y=lat)) +
geom_polygon() +
coord_map() +
geom_point(data=salesCalls, aes(x=lon, y=lat, size=Calls), color="orange")
library(boot) # K-fold
library(leaps) # Subset
library(glmnet) #glmnet() is the main function in the glmnet package (must pass in an x matrix as well as a y vector)
# Set x-y definitions for glmnet package
x <- model.matrix(sold_price ~ . ,data = data_factor_core_clean)[, -1]
y <- data_factor_core_clean$sold_price[1:24653] # Manually restricted due rows not matching with x 'x' for an unknown reason
# General grid
grid <- exp(seq(10, -65, length = 101)) #grid of values from exp(10) [null model] to exp(-15) [least squares]
#Lasso
set.seed(1)
cv.out <- cv.glmnet(x, y, alpha = 1, lambda = grid, nfolds = 10) #lasso
plot(cv.out)
# Base decision
bestlam <- cv.out$lambda.min; bestlam; log(bestlam)
out <- cv.out$glmnet.fit
lasso.coef <- predict(out, type = "coefficients", s = bestlam); lasso.coef; lasso.coef[lasso.coef != 0]
sum(abs(lasso.coef[1:31])) #l1 norm
# +1se decision
bestlam2 <- cv.out$lambda.1se; bestlam2; log(bestlam2)
lasso.coef2 <- predict(out, type = "coefficients", s = bestlam2); lasso.coef2; lasso.coef2[lasso.coef2 != 0]
sum(abs(lasso.coef2[2:31])) #l1 norm
end of document