Article Menu |
Calibrating the Ornstein-Uhlenbeck modelby M.A. (Thijs) van den Berg We describe two methods for calibrating the model parameters of an Ornstein-Uhlenbeck process to a given dataset.
[edit] IntroductionThe stochastic differential equation (SDE) for the Ornstein-Uhlenbeck process is given by with
[edit] An example simulationThe table and figure below show a simulated scenario for the Ornstein-Uhlenbeck process with time step
We used the following simulation equation for generating paths that are sampled with fixed time steps of The random numbers used in this example are shown in the last column of the table 1.
[edit] Calibration using least squares regressionThe relationship between consecutive observations
rewriting these equations gives [edit] Calculating the least squares regressionMost software tools (Excel, Matlab, R, Octave, Maple, ...) have built in functionality for least square regression. If its not available, a least square regression can easily be done by calculating the the quantities below from which we get the following parameters of the least square fit [edit] ExampleApplying the regression to the data in table 1 we get
These results allow us to recover the model parameters:
[edit] Calibration using Maximum Likelihood estimates[edit] Conditional probability density functionThe conditional probability density function is easily derived by combining the simulation equation above with the probability density function of the normal distribution function: The equation of the conditional probability density of an observation To simplify the notation of this equation we have introduced [edit] Log-likelihood functionThe log-likelihood function of a set of observation [edit] Maximum likelihood conditionsThe maximum of this log-likelihood surface can be found at the location where all the partial derivatives are zero. This leads to the following set of constraints. , , [edit] Solution of the conditionsThe problem with these conditions is that they solutions depend on each other. However, both
First we change notation of the which gives us:
removing denominators collecting terms moving all [edit] Final results: The maximum likelihood equationsmean mean reversion rate variance with [edit] ExampleCalculating the sums based on table 1 we get
These results allow us to recover the model parameters:
[edit] Matlab Code[edit] Least Squares Calibration
function [mu,sigma,lambda] = OU_Calibrate_LS(S,delta) n = length(S)-1; Sx = sum( S(1:end-1) ); Sy = sum( S(2:end) ); Sxx = sum( S(1:end-1).^2 ); Sxy = sum( S(1:end-1).*S(2:end) ); Syy = sum( S(2:end).^2 ); a = ( n*Sxy - Sx*Sy ) / ( n*Sxx -Sx^2 ); b = ( Sy - a*Sx ) / n; sd = sqrt( (n*Syy - Sy^2 - a*(n*Sxy - Sx*Sy) )/n/(n-2) ); lambda = -log(a)/delta; mu = b/(1-a); sigma = sd * sqrt( -2*log(a)/delta/(1-a^2) ); end [edit] Maximum Likelyhood Calibration
function [mu,sigma,lambda] = OU_Calibrate_ML(S,delta) n = length(S)-1; Sx = sum( S(1:end-1) ); Sy = sum( S(2:end) ); Sxx = sum( S(1:end-1).^2 ); Sxy = sum( S(1:end-1).*S(2:end) ); Syy = sum( S(2:end).^2 ); mu = (Sy*Sxx - Sx*Sxy) / ( n*(Sxx - Sxy) - (Sx^2 - Sx*Sy) ); lambda = -log( (Sxy - mu*Sx - mu*Sy + n*mu^2) / (Sxx -2*mu*Sx + n*mu^2) ) / delta; a = exp(-lambda*delta); sigmah2 = (Syy - 2*a*Sxy + a^2*Sxx - 2*mu*(1-a)*(Sy - a*Sx) + n*mu^2*(1-a)^2)/n; sigma = sqrt(sigmah2*2*lambda/(1-a^2)); end [edit] Example Usage
S = [ 3.0000 1.7600 1.2693 1.1960 0.9468 0.9532 0.6252 ... 0.8604 1.0984 1.4310 1.3019 1.4005 1.2686 0.7147 ... 0.9237 0.7297 0.7105 0.8683 0.7406 0.7314 0.6232 ]; delta = 0.25; [mu1, sigma1, lambda1] = OU_Calibrate_LS(S,delta) [mu2, sigma2, lambda2] = OU_Calibrate_ML(S,delta) gives
mu1 = 0.90748788828331 sigma1 = 0.58307607458526 lambda1 = 3.12873217812387 mu2 = 0.90748788828331 sigma2 = 0.55315453345189 lambda2 = 3.12873217812386
|
, mean reversion rate
, long term mean
and a noise term of
.
We will use this data to explain the model calibration steps.

is linear with a iid normal random term


given a previous observation
time step between them) is given by
can be derived from the conditional density function

