Introduction to continuous-time single-factor interest rate models.
Overview of the Vasicek model and its equation.
Overview of the CIR model and its equation.
Interest Rate Path Simulations
Continuous-time single-factor interest rate models are mathematical frameworks used to describe the dynamics of interest rates over time.
These models assume that the short-term interest rate follows a stochastic process and trying to capture various behavior of the interest rate movements.
These models capture the key characteristics of interest rate dynamics, such as mean reversion, volatility, and the term structure of interest rates.
Continuous-time models allow for more precise modeling and pricing of fixed-income securities compared to discrete-time models.
Single-factor interest rate models serve as building blocks for more complex models and are fundamental to risk analysis, bond pricing, yield curve construction, and interest rate derivatives pricing.
The most widely used single-factor interest rate models include the Vasicek model, CIR (Cox-Ingersoll-Ross) model, Hull-White model, and Black-Karasinski model.
The Vasicek model assumes a constant mean reversion speed and normally distributed interest rate shocks.
The CIR model introduces a non-negative interest rate process to address the limitation of negative interest rates in the Vasicek model.
The Hull-White model is a single-factor interest rate model that incorporates time-varying mean reversion speed to capture interest rate dynamics.
The Black-Karasinski model is a single-factor interest rate model that allows for time-varying volatility to capture interest rate dynamics and term structure.
Vasicek, O. (1977). An equilibrium characterization of the term structure. Journal of financial economics, 5(2), 177-188. https://www.sciencedirect.com/science/article/pii/0304405X77900162
Cox, J. C., Ingersoll Jr, J. E., & Ross, S. A. (2005). A theory of the term structure of interest rates. In Theory of valuation (pp. 129-164). https://www.worldscientific.com/doi/abs/10.1142/9789812701022_0005
Hull, J., & White, A. (1990). Pricing interest-rate-derivative securities. The review of financial studies, 3(4), 573-592. https://academic.oup.com/rfs/article-abstract/3/4/573/1585938
Black, F., & Karasinski, P. (1991). Bond and option pricing when short rates are lognormal. Financial Analysts Journal, 47(4), 52-59. https://www.tandfonline.com/doi/pdf/10.2469/faj.v47.n4.52
# Install and load required packages
# install.packages("quantmod")
library(quantmod)
## Loading required package: xts
## Warning: package 'xts' was built under R version 4.0.2
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
## Loading required package: TTR
## Warning: package 'TTR' was built under R version 4.0.2
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
library(ggplot2)
# Set the start and end dates for the data
start_date <- as.Date("2012-01-01")
end_date <- as.Date("2022-01-01")
# Set the ticker symbol for the Treasury rates
ticker1 <- "^IRX"
ticker2 <- "^FVX"
ticker3 <- "^TNX"
ticker4 <- "^TYX"
# Fetch the data from Yahoo Finance
getSymbols(Symbols = ticker1, src = "yahoo", from = start_date, to = end_date)
## Warning: ^IRX contains missing values. Some functions will not work if objects
## contain missing values in the middle of the series. Consider using na.omit(),
## na.approx(), na.fill(), etc to remove or replace them.
## [1] "IRX"
getSymbols(Symbols = ticker2, src = "yahoo", from = start_date, to = end_date)
## Warning: ^FVX contains missing values. Some functions will not work if objects
## contain missing values in the middle of the series. Consider using na.omit(),
## na.approx(), na.fill(), etc to remove or replace them.
## [1] "FVX"
getSymbols(Symbols = ticker3, src = "yahoo", from = start_date, to = end_date)
## Warning: ^TNX contains missing values. Some functions will not work if objects
## contain missing values in the middle of the series. Consider using na.omit(),
## na.approx(), na.fill(), etc to remove or replace them.
## [1] "TNX"
getSymbols(Symbols = ticker4, src = "yahoo", from = start_date, to = end_date)
## Warning: ^TYX contains missing values. Some functions will not work if objects
## contain missing values in the middle of the series. Consider using na.omit(),
## na.approx(), na.fill(), etc to remove or replace them.
## [1] "TYX"
# Extract the adjusted closing prices
dat1 <- IRX[,6]
dat2 <- FVX[,6]
dat3 <- TNX[,6]
dat4 <- TYX[,6]
par(mfrow = c(2,2))
plot(dat1, main = "13-week Rates")
plot(dat2, main = "5-Year Rates")
plot(dat3, main = "10-Year Rates")
plot(dat4, main = "30-Year Rates")
Brownian motion, named after mathematician Robert Brown, is a stochastic process used to model random movements over time.
It is characterized by continuous and unpredictable fluctuations, making it suitable for modeling various natural phenomena.
Brownian motion exhibits properties of independence, stationarity, and Gaussian increments, allowing for mathematical analysis and modeling.
It serves as a fundamental concept in fields such as finance, physics, and biology, capturing random behavior and uncertainty.
Equation/Definition:
Brownian motion, denoted as W(t), is a continuous-time stochastic process characterized by the following properties:
W(0) = 0 (starts at zero)
The increments W(t2) - W(t1), for any t2 > t1, are normally distributed with mean zero and variance t2 - t1.
The increments are independent, meaning that the behavior of W(t) is not influenced by previous increments.
Properties of Brownian Motion:
Continuity: Brownian motion is a continuous process, meaning that it has no jumps or discontinuities.
Gaussian Increments: The increments of Brownian motion over a time interval follow a Gaussian (normal) distribution.
Independent Increments: The increments of Brownian motion are independent of each other, implying that future behavior does not depend on past increments.
Time Scaling: Brownian motion exhibits a property called time scaling, where increasing the time scale by a factor ‘c’ results in scaling the values of W(t) by √c.
# Load required libraries
library(ggplot2)
# Function to simulate a Brownian motion path
brownian_motion_path <- function(steps) {
dt <- 1 # Time increment
# Generate random increments
dW <- rnorm(steps, mean = 0, sd = sqrt(dt))
# Calculate the cumulative sum to obtain the path
path <- cumsum(dW)
return(path)
}
# Function to simulate Brownian motion with drift
brownian_motion_with_drift <- function(steps, drift) {
dt <- 1 # Time increment
# Generate random increments
dW <- rnorm(steps, mean = 0, sd = sqrt(dt))
# Calculate the drift component
drift_component <- drift * seq(1, steps)
# Calculate the cumulative sum to obtain the path with drift
path <- cumsum(dW + drift_component)
return(path)
}
# Set Seed
set.seed(100)
# Set number of steps and drift
steps <- 200
drift <- 0.005
# Simulate a Brownian motion path
path <- brownian_motion_path(steps)
# Simulate Brownian motion with drift
path_with_drift <- brownian_motion_with_drift(steps, drift)
# Create time vector
time <- 1:steps
# Plot the simulated paths
plot_data <- data.frame(Time = time, Path = path, PathWithDrift = path_with_drift)
ggplot(plot_data) +
geom_line(aes(x = Time, y = Path, color = "Brownian Motion"), linetype = "solid", size = 1) +
geom_line(aes(x = Time, y = PathWithDrift, color = "Brownian Motion with Drift"), linetype = "solid", size = 1) +
xlab("Time") +
ylab("Value") +
ggtitle("Simulated Brownian Motion Path\nwith and without Drift") +
scale_color_manual(values = c("Brownian Motion" = "blue", "Brownian Motion with Drift" = "red")) +
theme_bw() +
labs(color = "Path Type")
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## Warning: Please use `linewidth` instead.
Usual interest rate model consists of two parts: dt component and the dZ component:
dr = a(r,t,T)dt + q(r,t,T)dW
dr is the change of interest rate over the short period of time (hence, the short-term interest model)
The dt component represents the deterministic part of the interest rate model, capturing the systematic changes over small time intervals.
a(r,t,T) is a constant or a function of the model’s parameters, time, and possibly other variables, and determines the overall trend or mean reversion behavior.
The dW (or I might be using dZ sometimes) component represents the stochastic or random part of the interest rate model, capturing the unpredictable fluctuations or shocks in interest rates. It is modeled using a stochastic process, such as a Wiener process or Brownian motion, to account for the inherent randomness in interest rate movements.
q(r,t,T) is a constant or a function that capture the behavior of the random part of the interest rate.
For example, there’s a model called “Ho-Lee Model”. The simplest version is following:
dr = a dt + b dZ; a and b are positive constants.
Pros: Very simple model
Cons: Cannot capture the true behavior of the interest rate. Interest rate can be trending up without mean reversion Interest rate can be negative.
Rendelman-Bartter Model assumes that the interest rate process follows a Geometric Brownian Motion (GBM) process i.e. the interest rate itself follows a lognormal distribution.
dr = (ar) dt + (br) dZ; a and b are positive constants.
Pros: Very simple model
Cons: Cannot capture the true behavior of the interest rate. Interest rate can be trending up without mean reversion. Though the interest rate cannot be negative but it can go arbitrarily large.
GBM is more common as a stock price process, not interest rate.
The Vasicek model is a popular single-factor interest rate model used to describe the dynamics of interest rates.
The Vasicek model is widely used in fixed-income securities pricing, risk management, and interest rate derivative valuation.
The model’s simplicity allows for analytical solutions and efficient parameter estimation.
Extensions of the Vasicek model incorporate credit risk or multiple factors for more complex interest rate modeling.
The interest rate follows the following stochastic process:
dr = a(b - r)dt + q dZ; a is a speed of mean reversion, b is a long-term interest rate and
It assumes mean reversion, with the interest rate tending to move towards a long-term mean over time.
The model incorporates a speed of mean reversion parameter that controls the rate at which the interest rate reverts.
It assumes normally distributed interest rate shocks, capturing the random fluctuations in interest rates.
# Clear Working Environment
rm(list = ls())
# Load required libraries
library(ggplot2)
# Function for Vasicek interest rate Monte Carlo simulation
vasicek_simulation <- function(theta, alpha, sigma, steps) {
dt <- 1 # Time increment
r <- numeric(steps) # Vector to store simulated interest rates
r[1] <- theta # Initial interest rate
for (i in 2:steps) {
# Generate random shock term
dW <- rnorm(1, mean = 0, sd = sqrt(dt))
# Calculate next interest rate using Vasicek model equation
r[i] <- r[i - 1] + alpha * (theta - r[i - 1]) * dt + sigma * dW
}
return(r)
}
# Set model parameters
theta <- 0.04 # Long-term mean or equilibrium interest rate
alpha <- 0.05 # Speed of mean reversion
sigma <- 0.01 # Volatility
# Set number of simulation steps
steps <- 1000
# Perform Vasicek Monte Carlo simulation
simulated_rates <- vasicek_simulation(theta, alpha, sigma, steps)
# Create time vector
time <- 1:steps
# Plot simulated interest rates
plot_data <- data.frame(Time = time, Rate = simulated_rates)
ggplot(plot_data, aes(x = Time, y = Rate)) +
geom_line(color = ifelse(simulated_rates < 0, "red", "blue")) +
geom_hline(yintercept = 0, linetype = "dashed") +
geom_hline(yintercept = 0.05, linetype = "dashed") +
xlab("Time") +
ylab("Interest Rate") +
ggtitle("Vasicek Interest Rate Monte Carlo Simulation") +
theme_bw()
Cox-Ingersoll-Ross Model or the CIR model is a popular single-factor interest rate model used to describe the dynamics of interest rates.
It incorporates mean reversion and captures the tendency of interest rates to gravitate towards a long-term mean.
The model allows for time-varying volatility, which accounts for the changing level of fluctuations in interest rates.
The CIR model is widely used in fixed-income securities pricing, risk management, and interest rate derivative valuation.
Cox-Ingersoll-Ross (CIR) model has the following equation for the interest rate dynamic:
dr(t) = α(θ - r(t))dt + σ√(r(t))dZ(t)
where:
r(t) represents the short-term interest rate at time t.
α is the speed of mean reversion parameter, determining the rate at which the interest rate reverts towards the long-term mean θ.
θ is the long-term mean or equilibrium interest rate.
σ is the volatility parameter, representing the level of fluctuations in interest rates.
dt is the time increment.
dZ(t) is a standard Wiener process or Brownian motion, representing the random shock term.
# Load required libraries
library(ggplot2)
# Function for CIR interest rate Monte Carlo simulation with standard normal shocks
cir_simulation <- function(theta, alpha, sigma, steps) {
dt <- 1 # Time increment
r <- numeric(steps) # Vector to store simulated interest rates
r[1] <- theta # Initial interest rate
for (i in 2:steps) {
# Generate standard normal shock term
dW <- rnorm(1, mean = 0, sd = 1)
# Calculate next interest rate using CIR model equation
gamma <- sqrt(alpha^2 + 2 * sigma^2)
psi <- (gamma + alpha) * dt
z <- dW^2
r[i] <- r[i - 1] + (alpha * (theta - r[i - 1]) * dt) + (sigma * sqrt(r[i - 1]) * sqrt(dt) * sqrt(z) / sqrt(psi))
}
return(r)
}
# Set model parameters
theta <- 0.01 # Long-term mean or equilibrium interest rate
alpha <- 0.05 # Speed of mean reversion
sigma <- 0.1 # Volatility
# Set number of simulation steps
steps <- 1000
# Perform CIR Monte Carlo simulation with standard normal shocks
simulated_rates <- cir_simulation(theta, alpha, sigma, steps)
# Create time vector
time <- 1:steps
# Plot simulated interest rates
plot_data <- data.frame(Time = time, Rate = simulated_rates)
ggplot(plot_data, aes(x = Time, y = Rate)) +
geom_line() +
xlab("Time") +
ylab("Interest Rate") +
ggtitle("CIR Interest Rate Monte Carlo Simulation")
Introduction to continuous-time single-factor interest rate models.
Overview of the Vasicek model and its equation.
Overview of the CIR model and its equation.
More examples
Interest Rate Path Simulations
Model parameter estimation: OLS, Method of Moments, Maximum Likelihood Estimation
How can we apply interest rate SDE to find:
Price a bond
Construct a yield curve
Forecast and simulate future interest rates and portfolios