0
$\begingroup$

I am trying to make some computations using Vasicek short rate model. Especially I a trying to compare exact expectation(obtained with the formula) and the expectation from Monte Carlo simulation.

  • For Exact computation I use:

$E[r_t] = r_0 * exp(-a*t) + (\theta/a)*(1-exp(-a*t))$

 public override double GetExpectation(double r0, double t)
        {
            double expectation = r0 * Math.Exp(-_a * t) + (_theta / _a) * (1 - Math.Exp(-_a * t));
            return expectation;
        }
  • For Monte Carlo simulations I use the following method:

    • I compute r from a time t to a time t+dt using: public override double ComputeNextValue(double r0, double dt) { RandomVariableGenerator rvg = RandomVariableGenerator.GetInstance();

      double randomGaussian = rvg.GetNextRandomGaussian();
      double r_t_dt = (_theta - _a*r0)*dt + _sigma * Math.Sqrt(dt) * randomGaussian;
      
      return r_t_dt;
      

      }

    • then a compute a path from 0 to t with dt as time steps using:

public override double ComputeValue(double r0, double t, double dt) { double x = r0;

    for(double slot = dt; slot <= t; slot += dt)
    {
        x = ComputeNextValue(x, dt);
    }
    return x;
}
  • Then I compute the Monte Carlo Expectation using:

    public override double ComputeMonteCarloExpectation(double r0, double t, double dt, int nreps) { double sum = 0.0; double value; for (int i = 0; i < nreps; i++) { value = ComputeValue(r0, t, dt); sum += value; } return sum / nreps; }

I use the following parameters:

            double sigma = 0.03;
            double r0 = 0.03;
            double theta = 0.1;
            double a = 0.3;

            int nreps = 1000;
            double t = 1;

For dt = 0.1:
Exact expectation: 0,108618473059879;
Monte Carlo Expectation: 0,0101464832161612

For dt = 1:
Exact expectation: 0,108618473059879;
Monte Carlo Expectation: 0,092058844704742

using dt = 1 leads to a result close to exact value while using dt = 0.1 seems to lead to a result having a 0.1 factor difference with exact one.

I think I am doing something wrong but I can't figure it out. Do you have an idea?

$\endgroup$
1
$\begingroup$

I got help from LutzL and figured out that I forgot to add the r0 term

ComputeNextValue(double r0, double dt) 
{ 
RandomVariableGenerator rvg = RandomVariableGenerator.GetInstance();

double randomGaussian = rvg.GetNextRandomGaussian();
double r_t_dt = r0 + (_theta - _a*r0)*dt + _sigma * Math.Sqrt(dt) * randomGaussian;

return r_t_dt;
}

It solved the problem and the values are now closer

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.