Book Image

Mastering R for Quantitative Finance

Book Image

Mastering R for Quantitative Finance

Overview of this book

Table of Contents (20 chapters)
Mastering R for Quantitative Finance
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

The Vasicek model


The Vasicek model (Vasicek, 1977) is a continuous, affine, one-factor stochastic interest rate model. In this model, the instantaneous interest rate dynamics are given by the following stochastic differential equation:

Here, α, β, and σ are positive constants, rt is the interest rate, t is time, and Wt denotes the standard Wiener process. In mathematics, this process is called the Ornstein-Uhlenbeck process.

As you may observe, the interest rate in the Vasicek model follows a mean-reverting process with a long-term average β; when rt < β, the drift term becomes positive, so the interest rate is expected to increase and vice versa. The speed of adjustment to the long-run mean is measured by α. The volatility term is constant in this model.

Interest rate models are implemented in R, but to understand more deeply what is behind the formulas, let's write a function that directly implements the stochastic differential equation of the Vasicek model:

vasicek <- function(alpha...