Once we have estimated the coefficients, we can interpret them to understand the relationship between house size and price.
\(\beta_1\) (the slope) tells us how much the price increases for each additional square foot of house size. For example, if \(\beta_1 = 100\), it means that for each additional square foot, the house price increases by $100.
\(\beta_0\) (the intercept) gives us the predicted price of a house when the size is zero. Practically, this might not make sense (as houses can’t have zero size), but it helps in aligning our linear model.
Using these coefficients, we can predict house prices for any given size using the formula:
\[ \text{Predicted Price} = \beta_0 + \beta_1 \times \text{House Size} \]
##Slide with R Output
The summary of our linear model provides important information, including the coefficients, their significance, and the overall fit of the model. Below is the R code used to fit the model and its output:
# Fitting a linear model
model <- lm(house_price ~ house_size, data = data)
# Displaying summary of the model
summary(model)
Call:
lm(formula = house_price ~ house_size, data = data)
Residuals:
Min 1Q Median 3Q Max
-112787 -27894 -3284 27465 109306
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 38106.191 18792.058 2.028 0.0482 *
house_size 104.773 5.706 18.362 <2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 47020 on 48 degrees of freedom
Multiple R-squared: 0.8754, Adjusted R-squared: 0.8728
F-statistic: 337.2 on 1 and 48 DF, p-value: < 2.2e-16