## 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, *r _{t}* is the interest rate,

*t*is time, and

*W*denotes the standard Wiener process. In mathematics, this process is called the Ornstein-Uhlenbeck process.

_{t}As you may observe, the interest rate in the Vasicek model follows a mean-reverting process with a long-term average *β*; when *r _{t} < β*, 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...**