30-Year Fixed-Rate Mortgage Analysis

Load and Prepare Data

Load necessary libraries

{library(ggplot2) library(readxl)}

Load the dataset

Display the first few rows of the data

{ head(mortgage_data)}

Convert the Year column to Date format

{ mortgage_data$Year <- as.Date(mortgage_data$Year, format = "%Y-%m-%d")}

Create the time series plot

{ 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()}

Develop the linear trend equation

{ model <- lm(Interest_Rate ~ Period, data = mortgage_data) summary(model)}

Result of the linear trend equation:

Interest Rate = 6.69541 − 0.12890 × Period

Coefficients from the model

{ intercept <- 6.69541 # Intercept from the model slope <- -0.12890 # Slope from the model}

Forecast for period 25

{ forecast_period_25 <- intercept + slope * 25 forecast_period_25}