Finding and Testing Parameters of the Vasicek Model. (2024)

The Vasicek Model is perhaps the simplest stochastic differential equation which is generally used to model short term interest rates or FX forward rates, however in theory it can be applied to any mean reverting asset such as commodities or FX spot.

\[dS_t = \lambda(\mu-S_t)dt+\sigma dW_t\]

where \(S_t\) represents the asset price at time t and \(W_t\) is standard Brownian Motion.

The SDE takes three parameters:

\(\mu\) describes the mean level, which all trajectory paths should evolve around in long term behaviour.

\(\lambda\) is the speed of mean reversion

\(\sigma\) is the standard deviation, modelling volatility.

In this post, I look at EUR/USD mid-price data from 08/11/2015 to 01/12/2015 (excluding weekends) and force a solution via maximum liklehood estimation for the three parameters.

Continuous Solution

The continuous case solution to the Vasicek differential equation is obtained by observing:

\[d(e^{\lambda t} S_t) = e^{\lambda t}dS_t + \lambda e^{\lambda t}S_t dt\]\[= e^{\lambda t}[\lambda(\mu - S_t)]dt + \sigma e^{\lambda t} dW_t + \lambda e^{\lambda t}S_t dt\]\[\lambda e^{\lambda t} dt + \sigma e^{\lambda t} dW_t\]

In integral form:

\[\Rightarrow e^{\lambda t} S_t = S_0 + \lambda\int^{t}_{0}e^{\lambda u}du + \sigma\int^{t}_{0}e^{\lambda u}dW_u\]

Evaluating the deterministic integral yields:

\[e^{\lambda t} S_t = S_0 + (e^{\lambda t} -1) + \sigma\int^{t}_{0}e^{\lambda u}dW_u\]

Dividing both sides by \(e^{\lambda t}\) and rewriting \(\lambda (s-t)\) as \(-\lambda (t-s)\) we get:

\[S_t = S_0 e^{-\lambda t} + (1-e^{-\lambda t}) + \sigma\int^{t}_{0}e^{-\lambda(t-s)}dW_s\]

Discrete Time Analog

In this post, I am using 30 minute intervals over approximately 1 month, so we can simplify greatly. In discrete time, \(S_{t+1} = \alpha S_t + \beta + \Upsilon(\mu_1 , \sigma_1^2)\)

ie: a Linear dependence with an normally distributed random term.

To find the parameters, we observe the conditional probability distribution:

\[f(S_{t+1} | S_{t})\]

This is distributed normally as: \(N(S_{t}e^{-\lambda}-\mu(1-e^{-\lambda}),\sigma^2 \frac{1-e^{-2\lambda}}{2\lambda})\)

Let \(\sigma_1^2 = \sigma^2 (\frac{1-e^{-2\lambda}}{2\lambda})\) for brevity.

This can be simulated in code and we can generate sample paths as shown:

 def vasicek_path(mu, sigma, _lambda, starting, n_ticks): # runs a simulated trajectory path with n ticks # with given parameters and starting value path = [starting] for i in range(0,n_ticks-1): s = np.random.normal(0, 1, 1)[0] a = (path[i]*math.exp(-_lambda)) + mu*(1-math.exp(-_lambda)) + (sigma * math.sqrt( (1-math.exp(-2*_lambda)) / (2*_lambda) ) ) *s path.append(a) return pathdef plotter(): for n in range(4): plt.plot(range(50), vasicek_path(1.,1.5,0.25,1,50), alpha = 0.6, color = 'red') plt.plot(range(50), vasicek_path(1.,1.,1,1,50), alpha = 0.6, color = 'blue') plt.title('Simulated Vasicek Trajectories') plt.ylabel('S(i)') plt.xlabel('i') plt.show()plotter()

Finding and Testing Parameters of the Vasicek Model. (1)Red: \(\mu = 1, \lambda = 1.5, \sigma = 0.25\)

Blue: \(\mu = 1, \lambda = 1, \sigma = 1\)

The higher volatility of \(S_{red}\) is clearly visible with 50 sampling points.

Liklehood Estimation to find Parameters

The Liklehood Estimator is given by:

\[L(\mu,\lambda,\sigma_1) = \prod_{t=1}^{n} f(S_t|S_{t-1}) = \left( \frac{1}{\sqrt{2\pi\sigma^2}} \right)^n e^{-\sum^{n}_{t=1}(S_t - S_{t-1}\frac{e^{-\lambda} - \mu(1-e^-\lambda))^2}{2\sigma_1^2})}\]

It suffices to maximise the Log-likehood estimator as the logarithm function is monotonically increasing and continuous.

\[log(L(\mu,\lambda,\sigma_1)) = \frac{-n}{2}log(2\pi\sigma^2) -\sum^{n}_{t=1} \frac{(S_t - S_{t-1}e^{-\lambda} - \mu(1-e^-\lambda))^2}{2\sigma_1^2} - n log(\sigma)\]

Now, we partially differentiate \(log(L)\) with respect to \(\lambda\), \(\sigma_1\) and \(\mu\), setting the derivatives to zero gives us solutions for the estimator values.

For example, in the case of \(\mu\) we set:

\[\frac{dlog(L(\mu,\lambda,\sigma_1))}{d\mu} := 0\]\[\Rightarrow \mu_{est} = \frac{\sum^{n}_{t=1}(S_t-S_{t-1})e^{-\lambda}}{n(1-e^{-\lambda})}\]

The case is similar for \(\lambda\) and \(\sigma_1\)

Plotting

Data was taken from Bloomberg Terminals at King’s College London

Plotting the Backtest Data (30 minute granularity, no weekend data)

dates = []prices = []with open('usdeur30min.csv', 'r') as csvfile: reader = csv.reader(csvfile) for row in reader: date_object = datetime.strptime((row[0]), '%d/%m/%Y %H:%M') dates.append( date_object ) prices.append( float(row[1]) )dates = dates[::-1] # Chronologicallyprices = prices[::-1] # 

Simulating Trajectories with Estimated Parameters

With the initial starting mid-price, 50 simulations are ran with the MLE parameters, along with the real data in red.

s_x = sum(prices[0:-1])s_y = sum(prices[1:])s_xx = sum(i**2 for i in prices[0:-1])s_yy = sum(i**2 for i in prices[1:])s_xy = sum(prices[i]*prices[i+1] for i in range(0,len(prices)-1))mu = (s_y*s_xx - s_x*s_xy)/( len(prices)*(s_xx - s_xy) - (s_x**2 - s_x*s_y) )_lambda = -math.log( (s_xy - mu*s_x - mu*s_y + len(prices)*mu**2) / (s_xx -2*mu*s_x + len(prices)*mu**2) )a = math.exp(-_lambda)sigmah2 = (s_yy - 2*a*s_xy + (a**2)*s_xx - 2*mu*(1-a)*(s_y - a*s_x) + len(prices)*(mu**2)*(1-a)**2)/len(prices)sigma = math.sqrt(sigmah2*2*_lambda/(1-a**2))def forward_test(): prices_path = [prices[0]] for i in range(0,len(dates)-1): s = np.random.normal(0, 1, 1)[0] a = (prices_path[i]*math.exp(-_lambda)) +mu*(1-math.exp(-_lambda)) + (sigma * math.sqrt( (1-math.exp(-2*_lambda)) / (2*_lambda) ) ) *s prices_path.append(a) return prices_pathfor n in range(1,30): plt.plot(dates, forward_test(),linewidth=0.4,alpha = 0.7, color = 'green')plt.plot(dates, prices,linewidth=2.0, color = 'red')plt.title('Mid Price of USD/EUR: 08/11/15 - 01/12/15')plt.ylabel('USDEUR Mid Price')plt.xlabel('Date')plt.show()

Finding and Testing Parameters of the Vasicek Model. (2)

Note: the jumps are due to weekends.

Next Steps

The above results are not particularly surprising. Indeed we expect the final points of simulated trajectory paths to be normally distributed around the real data result. The next steps are to forward test our parameters with new unseen intra-day data. My next post will cover this in more detail once a month has elapsed.

Finding and Testing Parameters of the Vasicek Model. (2024)

FAQs

How do you calculate Vasicek parameters? ›

Estimates the parameters of the Vasicek model. dr = alpha(beta-r)dt + sigma dW, with market price of risk q(r) = q1+q2 r.

What is the formula for the Vasicek model? ›

Using the Vasicek model equation: dR(t) = a(b – R(t))dt + σdW(t), we can simulate the interest rate path as follows: Step 1: Set initial values: R(0) = 0.05 (initial interest rate) Δt = 1/12 (time step, 1 month)

What are the assumptions of the Vasicek model? ›

Based on the information, the Vasicek model assumes that the interest rate revolves around the long term-mean level, “b.” The drift factor, which is defined as a(b-rt), is an important part of the model and describes the expected change in the interest rate at time t.

What is the Vasicek model simulation in Python? ›

Vasicek one factor model for simulating the evolution of a credit instruments such as a government bonds. The Vasicek model assumes that the process evolves as an Ornstein-Uhlenbeck process. Ornstein-Uhlenbeck is a stochastic process where over time, the process tends to drift towards a long-term mean (mean reverting).

What is the formula for estimating parameters? ›

2.3 Parameter Estimation

For both simple regression and ANOVA, we can write the model in matrix form as y=Xβ+ϵ where ϵ∼N(0,σ2In) y = X β + ϵ where ϵ ∼ N ( 0 , σ 2 I n ) which could also be written as y∼N(Xβ,σ2In) y ∼ N ( X β , σ 2 I n ) and we could use the maximum-likelihood principle to find estimators for β and σ2 .

How does Vasicek model work? ›

It outlines an interest rate's evolution as a factor composed of market risk, time, and equilibrium value. The model is often used in the valuation of interest rate futures and in solving for the price of various hard-to-value bonds. The Vasicek Model values the instantaneous interest rate using a specific formula.

How to calibrate Vasicek? ›

The calibration is done by maximizing the likelihood of zero coupon bond log prices, using mean and covariance functions computed analytically, as well as likelihood derivatives with respect to the parameters. The maximization method used is the conjugate gradients.

What is the Vasicek default rate model? ›

The Vasicek model is a one-period (i.e. static) model used to construct default indicators of correlated ex- posures over a given time horizon. Closely related is the Gaussian copula model, a dynamic model used to construct the default times of correlated exposures.

What are the pros and cons of Vasicek model? ›

The Vasicek Model offers flexibility, simplicity, and the incorporation of mean reversion in modeling interest rate dynamics. However, it is important to be aware of its limitations, such as the assumption of constant parameters and the inability to model negative interest rates.

How does Vasicek model explain credit risk? ›

The Vasicek model uses three inputs to calculate the probability of default (PD) of an asset class. One input is the through-the-cycle PD (TTC_PD) specific for that class. Further inputs are a portfolio common factor, such as an economic index over the interval (0,T) given by S.

What are the benefits of the Vasicek model? ›

Calibration: One of the key advantages of the Vasicek Model is its simplicity and ease of calibration. The model only requires a few parameters to be estimated, such as the long-term mean, the speed of mean reversion, and the volatility of interest rates.

What is Vasicek distribution? ›

Definition. The Vasicek Distribution is a special probability distribution that emerges in the context of Threshold Models used in credit portfolio modelling.

What is the Merton Vasicek approach? ›

The Vasicek approach is applied to the firms characterized by the same probability of default. In turn, the Vasicek-Merton approach requires not only the same probability of default, but additionally the same volatility of assets value.

What is the Vasicek model of default rate? ›

The Vasicek model is a one-period (i.e. static) model used to construct default indicators of correlated ex- posures over a given time horizon. Closely related is the Gaussian copula model, a dynamic model used to construct the default times of correlated exposures.

References

Top Articles
Latest Posts
Article information

Author: Lilliana Bartoletti

Last Updated:

Views: 5940

Rating: 4.2 / 5 (53 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Lilliana Bartoletti

Birthday: 1999-11-18

Address: 58866 Tricia Spurs, North Melvinberg, HI 91346-3774

Phone: +50616620367928

Job: Real-Estate Liaison

Hobby: Graffiti, Astronomy, Handball, Magic, Origami, Fashion, Foreign language learning

Introduction: My name is Lilliana Bartoletti, I am a adventurous, pleasant, shiny, beautiful, handsome, zealous, tasty person who loves writing and wants to share my knowledge and understanding with you.