{library(ggplot2) library(readxl)}
{ head(mortgage_data)}
{ mortgage_data$Year <- as.Date(mortgage_data$Year, format = "%Y-%m-%d")}
{ ggplot(mortgage_data, aes(x = Year, y = Interest_Rate)) + geom_line(color = "blue") + labs(title = "30-Year Fixed-Rate Mortgage Interest Rates", x = "Year", y = "Interest Rate (%)") + theme_minimal()}
{ model <- lm(Interest_Rate ~ Period, data = mortgage_data) summary(model)}
{ intercept <- 6.69541 # Intercept from the model slope <- -0.12890 # Slope from the model}
{ forecast_period_25 <- intercept + slope * 25 forecast_period_25}