Make sure to include the unit of the values whenever appropriate.
Hint: The variables are available in the SaratogaHouses data set from the mosaicData package.
library(tidyverse)
data(SaratogaHouses, package="mosaicData")
wages_lm <- lm(price~ bedrooms + waterfront,
data = SaratogaHouses)
summary(wages_lm)
##
## Call:
## lm(formula = price ~ bedrooms + waterfront, data = SaratogaHouses)
##
## Residuals:
## Min 1Q Median 3Q Max
## -270743 -54861 -15794 32876 502206
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 247858 23774 10.426 <2e-16 ***
## bedrooms 49790 2610 19.074 <2e-16 ***
## waterfrontNo -194643 22994 -8.465 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 88440 on 1725 degrees of freedom
## Multiple R-squared: 0.1938, Adjusted R-squared: 0.1928
## F-statistic: 207.3 on 2 and 1725 DF, p-value: < 2.2e-16
Since the p-value is smaller than .05, the coefficient of bedrooms is statistically significant at 5%.
Hint: Discuss both its sign and magnitude.
For every bedroom a house in Saratoga, New York has, the price of the house increases by $49,790.
Hint: Discuss all three aspects of the relevant predictor: 1) statistical significance, 2) sign, and 3) magnitude.
The coefficient of waterfront homes is statistically significant at 5% because the p-value is less than .05.
The negative sign of the coefficient indicates that the waterfront homes are less expensive than the mean price of homes in Saratoga, New York.
The magnitude of the coefficient of waterfront homes is -194643, meaning that waterfront homes are on average $194,643 less expensive than the median home price in Saratoga, New York.
$202,585
Hint: Provide a technical interpretation.
The technical interpretation of the intercept is that a home in Saratoga, New York without a waterfront location or any bedrooms costs $247,858 on average. This technically is not possible and is only a reference point for comparing the coeffficients waterfront and number of bedrooms.
Hint: Discuss in terms of both residual standard error and reported adjusted R squared.
wages_lm <- lm(price~ bedrooms + waterfront + age,
data = SaratogaHouses)
summary(wages_lm)
##
## Call:
## lm(formula = price ~ bedrooms + waterfront + age, data = SaratogaHouses)
##
## Residuals:
## Min 1Q Median 3Q Max
## -214067 -53391 -16214 32639 521759
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 270418.82 23271.97 11.620 <2e-16 ***
## bedrooms 50503.63 2543.58 19.855 <2e-16 ***
## waterfrontNo -200250.85 22403.23 -8.938 <2e-16 ***
## age -689.71 71.01 -9.712 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 86140 on 1724 degrees of freedom
## Multiple R-squared: 0.2356, Adjusted R-squared: 0.2343
## F-statistic: 177.1 on 3 and 1724 DF, p-value: < 2.2e-16
The second model is a better predictor of home price because it has a lower residual standard error and higher asjusted r-squared.
Hint: Use message
, echo
and results
in the chunk options. Refer to the RMarkdown Reference Guide.