library(tidyverse)
library(scales)
options(scipen=999)
data(SaratogaHouses, package="mosaicData")
houses_lm <- lm(price ~ lotSize + age + landValue +
livingArea + bedrooms + bathrooms +
waterfront,
data = SaratogaHouses)
# View summary of model 1
summary(houses_lm)
##
## Call:
## lm(formula = price ~ lotSize + age + landValue + livingArea +
## bedrooms + bathrooms + waterfront, data = SaratogaHouses)
##
## Residuals:
## Min 1Q Median 3Q Max
## -220208 -35416 -5443 27570 464320
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 139878.80484 16472.92736 8.491 < 0.0000000000000002 ***
## lotSize 7500.79232 2075.13554 3.615 0.000309 ***
## age -136.04011 54.15794 -2.512 0.012099 *
## landValue 0.90931 0.04583 19.841 < 0.0000000000000002 ***
## livingArea 75.17866 4.15811 18.080 < 0.0000000000000002 ***
## bedrooms -5766.75988 2388.43256 -2.414 0.015863 *
## bathrooms 24547.10644 3332.26775 7.366 0.000000000000271 ***
## waterfrontNo -120726.62066 15600.82783 -7.738 0.000000000000017 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 59370 on 1720 degrees of freedom
## Multiple R-squared: 0.6378, Adjusted R-squared: 0.6363
## F-statistic: 432.6 on 7 and 1720 DF, p-value: < 0.00000000000000022
Interpretation
Intercept line, for example, indicates that the coefficient is significant at 0.1% signficance level (low p-values). It means that we are 99.9% confident that the interecept is true. One the other hand, The variable age has only one star. It means that we are only 95% confident that age is meaningful in explaining home prices. If a variable had no star, it would have meant that we are not confident of the reported coefficient at all. In other words, it would be highly unlikely that changes in the variable with no star is meaningful in explaining changes in the home prices.living area is 75.18. It means that an increase of one square foot of living area is associated with a home price increase of $75, holding the other variables constant. When interpreting coeffcients, make sure to check the unit of the variables in the data.living area = 0). Of coure, living area canโt be zero. Often, interpret is meaningless.hightemp, and precip.Hint: The variables are available in the RailTrail data set from the mosaicData package.
data(RailTrail, package="mosaicData")
railtrail_lm <- lm(volume ~hightemp + precip ,
data = RailTrail)
# View summary of model 1
summary(houses_lm)
##
## Call:
## lm(formula = price ~ lotSize + age + landValue + livingArea +
## bedrooms + bathrooms + waterfront, data = SaratogaHouses)
##
## Residuals:
## Min 1Q Median 3Q Max
## -220208 -35416 -5443 27570 464320
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 139878.80484 16472.92736 8.491 < 0.0000000000000002 ***
## lotSize 7500.79232 2075.13554 3.615 0.000309 ***
## age -136.04011 54.15794 -2.512 0.012099 *
## landValue 0.90931 0.04583 19.841 < 0.0000000000000002 ***
## livingArea 75.17866 4.15811 18.080 < 0.0000000000000002 ***
## bedrooms -5766.75988 2388.43256 -2.414 0.015863 *
## bathrooms 24547.10644 3332.26775 7.366 0.000000000000271 ***
## waterfrontNo -120726.62066 15600.82783 -7.738 0.000000000000017 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 59370 on 1720 degrees of freedom
## Multiple R-squared: 0.6378, Adjusted R-squared: 0.6363
## F-statistic: 432.6 on 7 and 1720 DF, p-value: < 0.00000000000000022
hightemp statistically significant at 5%?Yes, It is significant because it P-Value is smaller than 5 percent ## Q3 Interpret the coefficient of hightemp? The number of trail users increase by more than 6 people or degree increase in fairhenheit ## Q4 Is the intercept statistically significant at 5%? No, it is larger than 0.05 therefore it is not significant ## Q5 Interpret the intercept? The intercept is at 0.9 ## Q6 Interpret the reported residual standard error. On average the residual standard error does not account for 97 people ## Q7 Interpret the reported adjusted R squared. The model is explained but only to 42% ## Q8 Hide the messages, but display the code and its results on the webpage. Hint: Use message, echo and results in the chunk options. Refer to the RMarkdown Reference Guide.