Home > code > core > simulation > sim_pcsv.m

sim_pcsv

PURPOSE ^

SIM_PCSV Simulates a PCSV model for the given time points in t.

SYNOPSIS ^

function [y, lambda] = sim_pcsv(y_0, mu, A, lambda_0, kappa, theta, sigma, rho, t)

DESCRIPTION ^

SIM_PCSV Simulates a PCSV model for the given time points in t.

  [y, lambda] = sim_pcsv(y_0, mu, A, lambda_0, kappa, theta, sigma, rho, t)
    Performs an Euler simulation of the PCSV model specified by the given
    parameters for the time points in t.
    Assuming that n is the dimension of the problem, p the number of
    eigenvalues/eigenvectors, the parameters expected are

    INPUT      y_0: n-dimensional vector with initial log prices
                mu: n-dimensional mean vector
                 A: n x p matrix of eigenvectors
          lambda_0: p-dimensional vector of initial eigenvalues
             kappa: p-dimensional vector representing "mean reversion speed"
             theta: p-dimensional vector of "mean reversion means"
             sigma: p-dimensional vector of "mean reversion volatilities"
               rho: p-dimensional vector representing noise correlations
                 t: T-dimensional vector of the time points for which
                    a price is to be simulated

    OUTPUT       y: T x n matrix of the simulated log prices
            lambda: T x p matrix of the simulated eigenvalues

 See also SIM_WASC_2D.

 created by Benedikt Rudolph
 DATE: 12-Aug-2012

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [y, lambda] = sim_pcsv(y_0, mu, A, lambda_0, kappa ...
0002                                , theta, sigma, rho, t)
0003 %SIM_PCSV Simulates a PCSV model for the given time points in t.
0004 %
0005 %  [y, lambda] = sim_pcsv(y_0, mu, A, lambda_0, kappa, theta, sigma, rho, t)
0006 %    Performs an Euler simulation of the PCSV model specified by the given
0007 %    parameters for the time points in t.
0008 %    Assuming that n is the dimension of the problem, p the number of
0009 %    eigenvalues/eigenvectors, the parameters expected are
0010 %
0011 %    INPUT      y_0: n-dimensional vector with initial log prices
0012 %                mu: n-dimensional mean vector
0013 %                 A: n x p matrix of eigenvectors
0014 %          lambda_0: p-dimensional vector of initial eigenvalues
0015 %             kappa: p-dimensional vector representing "mean reversion speed"
0016 %             theta: p-dimensional vector of "mean reversion means"
0017 %             sigma: p-dimensional vector of "mean reversion volatilities"
0018 %               rho: p-dimensional vector representing noise correlations
0019 %                 t: T-dimensional vector of the time points for which
0020 %                    a price is to be simulated
0021 %
0022 %    OUTPUT       y: T x n matrix of the simulated log prices
0023 %            lambda: T x p matrix of the simulated eigenvalues
0024 %
0025 % See also SIM_WASC_2D.
0026 %
0027 % created by Benedikt Rudolph
0028 % DATE: 12-Aug-2012
0029   
0030   n = size(A,1); % dimension of the problem
0031   p = size(A,2); % number of driving eigenvectors / noises
0032   T = length(t); % number of time grid points
0033   dt = reshape(diff(t),T-1,1); % time increments
0034   
0035   mu = reshape(mu, 1, n);
0036   kappa = reshape(kappa, 1, p);
0037   theta = reshape(theta, 1, p);
0038   sigma = reshape(sigma, 1, p);
0039   rho = reshape(rho, 1, p);
0040   
0041   y = zeros(T, n); % pre-allocation
0042   y(1,:) = y_0;
0043   
0044   lambda = zeros(T, p); % pre-allocation
0045   lambda(1,:) = lambda_0;
0046   
0047   dB = normrnd(0, 1, T-1, p); % noise driving the eigenvalues
0048   dW = normrnd(0, 1, T-1, p); % noise driving the log returns
0049   % correlate noises by rho
0050   dW = repmat(rho,T-1,1).*dB + repmat(sqrt(1-rho.^2),T-1,1).*dW;
0051   
0052   for k=2:T
0053     y(k,:) = y(k-1,:) + (mu - 0.5 * lambda(k-1,:) * A'.^2).*dt(k-1) ...
0054                   + ( sqrt(lambda(k-1,:)) .* dW(k-1,:) * A' ) *sqrt(dt(k-1));
0055     lambda(k,:) = lambda(k-1,:) + kappa.*(theta-lambda(k-1,:))*dt(k-1) ...
0056                         + sigma.*sqrt(lambda(k-1,:)).*dB(k-1,:)*sqrt(dt(k-1));
0057     lambda(k,:) = abs( lambda(k,:) );
0058   end
0059 end

Generated on Mon 29-Apr-2013 19:29:13 by m2html © 2005