October 26, 2025

Linear Regression Model

Our regression model is: \(\widehat{y} = b_0 + b_1 \cdot x\) where \(y\) = monthly rent, \(x\) = number of bedrooms

             Estimate Std. Error  t value Pr(>|t|)
(Intercept) 1135.5384   4.893977 232.0277        0
beds         513.8209   2.264135 226.9391        0

Fitted Model: \(\widehat{y} = 1135.54 + 513.82 \cdot x\)

Interpretation: Each additional bedroom increases monthly rent by approx. \(514\) dollars

Rent Trends in the Bay Area Over Time

Top 5 Most Expensive Counties in the Bay Area

Analysis: This plot shows that San Francisco county is the most expensive on average, with the highest median overall.

Size vs Bedrooms vs Price (3D Visualization)

Analysis: This plot shows that the size, number of bedrooms, and price appear to be correlated.

Correlation Coefficient

The linear correlation coefficient measures the strength of the linear relationship between two variables:

\[r = \frac{\sum x_i y_i - \frac{(\sum x_i)(\sum y_i)}{n}}{\sqrt{\left(\sum x_i^2 - \frac{(\sum x_i)^2}{n}\right)\left(\sum y_i^2 - \frac{(\sum y_i)^2}{n}\right)}}\] when \(x\) = number of bedrooms and \(y\) = monthly rent price:

[1] 0.4586301

Interpretation: \(0.4586\) suggests a moderate positive correlation between the number of bedrooms and the monthly price of rent. While the number of bedrooms does influence the rent price, other factors such as location, square footage, and amenities also play a significant role.

Bedroom distribution in Bay Area Rentals

Analysis: This plot shows that listings with 2 bedrooms are most common, followed by those with 1 bedroom.

R Code: Price per Square Foot

sqft_data <- rent_clean %>%
  filter(!is.na(sqft), sqft > 200, sqft < 3000) %>%
  mutate(price_per_sqft = price / sqft)

ggplot(sqft_data, aes(x = sqft, y = price_per_sqft)) +
  geom_point(alpha = 0.2, color = "#8C1D40") +
  geom_smooth(method = "lm", color = "#FFC627", linewidth = 1.2) +
  labs(x = "Square Feet", y = "Price per Square Foot ($)",
       title = "Price Per Square Foot") +
  theme_minimal()

This code creates a plot using ggplot that shows the price per square foot.

Price per Square Foot

Analysis: This plot shows that the higher the square feet, the lower the price per square foot.