hp <- read.csv("homeprice.csv")
all_var <- hp[ , c("list", "full", "half", "bedrooms", "rooms", "neighborhood")]
plot(hp$sale, hp$list)

plot(hp$sale, hp$full)

plot(hp$sale, hp$half)

plot(hp$sale, hp$bedrooms)

plot(hp$sale, hp$rooms)

plot(hp$sale, hp$neighborhood)
library(ggplot2)

myplot1 <- ggplot(data = hp, aes(x = sale)) +
geom_point(aes(y = list), color = "red") +
geom_point(aes(y = full), color = "blue") +
geom_point(aes(y = half), color = "yellow")
myplot1

myplot2 <- ggplot(data = hp, aes(x = sale)) +
geom_point(aes(y = bedrooms), color = "orange") +
geom_point(aes(y = rooms), col = "purple") +
geom_point(aes(y = neighborhood), col = "green")
myplot2

myplot3 <- ggplot(data = hp, aes(x = list)) +
geom_point(aes(y = bedrooms), color = "orange") +
geom_point(aes(y = rooms), col = "purple") +
geom_point(aes(y = neighborhood), col = "green")
myplot3

model <- lm(sale ~ bedrooms + rooms + neighborhood, data = hp)
summary(model)
##
## Call:
## lm(formula = sale ~ bedrooms + rooms + neighborhood, data = hp)
##
## Residuals:
## Min 1Q Median 3Q Max
## -91.166 -35.314 -2.229 33.494 93.133
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -157.35 43.35 -3.630 0.00127 **
## bedrooms 17.40 20.85 0.835 0.41181
## rooms 16.75 11.73 1.427 0.16589
## neighborhood 88.03 9.71 9.066 2.23e-09 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 46.38 on 25 degrees of freedom
## Multiple R-squared: 0.8605, Adjusted R-squared: 0.8437
## F-statistic: 51.4 on 3 and 25 DF, p-value: 7.783e-11
anova(model)
## Analysis of Variance Table
##
## Response: sale
## Df Sum Sq Mean Sq F value Pr(>F)
## bedrooms 1 91233 91233 42.409 8.045e-07 ***
## rooms 1 63670 63670 29.596 1.198e-05 ***
## neighborhood 1 176818 176818 82.192 2.232e-09 ***
## Residuals 25 53782 2151
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
list_model <- lm(list ~ bedrooms + rooms + neighborhood, data = hp)
summary(list_model)
##
## Call:
## lm(formula = list ~ bedrooms + rooms + neighborhood, data = hp)
##
## Residuals:
## Min 1Q Median 3Q Max
## -104.761 -29.449 1.635 31.158 73.909
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -168.136 43.598 -3.856 0.000716 ***
## bedrooms 15.899 20.971 0.758 0.455452
## rooms 18.019 11.800 1.527 0.139299
## neighborhood 90.688 9.766 9.286 1.4e-09 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 46.65 on 25 degrees of freedom
## Multiple R-squared: 0.866, Adjusted R-squared: 0.8499
## F-statistic: 53.87 on 3 and 25 DF, p-value: 4.706e-11
anova(list_model)
## Analysis of Variance Table
##
## Response: list
## Df Sum Sq Mean Sq F value Pr(>F)
## bedrooms 1 94709 94709 43.523 6.526e-07 ***
## rooms 1 69301 69301 31.847 7.129e-06 ***
## neighborhood 1 187651 187651 86.233 1.399e-09 ***
## Residuals 25 54402 2176
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Are there differences from the sale price? very little, the actual
sale chart is shifted lower than the listed price
Could you use this information to recommend which
characteristic
of a house a real estate agent should concentrate on? Yes,
rooms>neighborhood>bedrooms
Finally, what is the effect of neighborhood on the difference
between sale price and list price? very little
Do richer neighborhoods mean it is more likely to have a house go
over the asking price? Np, theres most likely less competition