Home > code > core > cf > cf_pcsv_v.m

cf_pcsv_v

PURPOSE ^

CF_PCSV_V Calculates characteristic function values for a PCSV model.

SYNOPSIS ^

function phi = cf_pcsv_v(mu, A, lambda_0, kappa, theta, sigma, rho, omega, y_t, tau)

DESCRIPTION ^

CF_PCSV_V Calculates characteristic function values for a PCSV model.

  phi = cf_pcsv_v(mu, A, lambda_0, kappa, theta, sigma, rho, omega, y_t, tau)
    Calculates the conditional characteristic function of continuous returns
    of an n-dimensional PCSV model in a vectorized way.
    Assuming that n is the dimension of the problem, p the number of
    eigenvalues/eigenvectors, the parameters expected are

    INPUT       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
             omega: n x N matrix representing the evaluation grid
               y_t: T x n matrix representing the time grid
               tau: real valued time difference

    OUTPUT     phi: a (T-1) x N matrix representing the cf value
                    for time (row) and grid point (column).

 See also CF_WASC_V, CF_GBM_V.

 created by Benedikt Rudolph
 DATE: 16-Aug-2012

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function phi = cf_pcsv_v(mu, A, lambda_0, kappa, theta, sigma ...
0002                               , rho, omega, y_t, tau)
0003 %CF_PCSV_V Calculates characteristic function values for a PCSV model.
0004 %
0005 %  phi = cf_pcsv_v(mu, A, lambda_0, kappa, theta, sigma, rho, omega, y_t, tau)
0006 %    Calculates the conditional characteristic function of continuous returns
0007 %    of an n-dimensional PCSV model in a vectorized way.
0008 %    Assuming that n is the dimension of the problem, p the number of
0009 %    eigenvalues/eigenvectors, the parameters expected are
0010 %
0011 %    INPUT       mu: n-dimensional mean vector
0012 %                 A: n x p matrix of eigenvectors
0013 %          lambda_0: p-dimensional vector of initial eigenvalues
0014 %             kappa: p-dimensional vector representing "mean reversion speed"
0015 %             theta: p-dimensional vector of "mean reversion means"
0016 %             sigma: p-dimensional vector of "mean reversion volatilities"
0017 %               rho: p-dimensional vector representing noise correlations
0018 %             omega: n x N matrix representing the evaluation grid
0019 %               y_t: T x n matrix representing the time grid
0020 %               tau: real valued time difference
0021 %
0022 %    OUTPUT     phi: a (T-1) x N matrix representing the cf value
0023 %                    for time (row) and grid point (column).
0024 %
0025 % See also CF_WASC_V, CF_GBM_V.
0026 %
0027 % created by Benedikt Rudolph
0028 % DATE: 16-Aug-2012
0029   
0030   % n: number of assets
0031   % p: number of eigenvectors
0032   [n, p] = size(A);
0033   
0034   N = size(omega, 2); % number of (n-dimensional) evaluation grid points
0035   T = size(y_t,1)-1; % number of time grid points
0036   t = cumsum(repmat(tau,T,1))-tau;
0037   
0038   c = omega'*A; % N x p
0039   b = -0.5*omega'*(A.^2); % N x p
0040   r = omega'*mu/p; % N x 1
0041   r = repmat(r, 1, p); % N x p
0042   
0043   ph = 1; % suppose we do not need it
0044   
0045   % reshape parameters to required form
0046   lambda_0 = reshape(lambda_0, 1, p);
0047   kappa = reshape(kappa, 1, p);
0048   theta = reshape(theta, 1, p);
0049   sigma = reshape(sigma, 1, p);
0050   rho = reshape(rho, 1, p);
0051   
0052   lambda_0 = repmat(lambda_0, N, 1); % N x p
0053   kappa = repmat(kappa, N, 1); % N x p
0054   theta = repmat(theta, N, 1); % N x p
0055   sigma = repmat(sigma, N, 1); % N x p
0056   rho = repmat(rho, N, 1); % N x p
0057   
0058   
0059   d = sqrt((kappa-rho.*c.*sigma.*ph*1i).^2-sigma.^2.*(2*b.*ph*1i-c.^2.*ph.^2));
0060   g = (kappa - rho.*c.*sigma.*ph*1i + d) ./ (kappa - rho.*c.*sigma.*ph*1i - d);
0061   
0062   C = r*tau.*ph*1i + kappa.*theta./(sigma.^2) .* ...
0063       ((kappa-rho.*c.*sigma.*ph*1i+d)*tau - 2*log((1-g.*exp(d*tau))./(1-g)));
0064   D = (kappa - rho.*c.*sigma.*ph*1i + d) ./ (c.^2.*sigma.^2) .* ...
0065       (1 - exp(d*tau)) ./ (1-g.*exp(d*tau));
0066   
0067   Delta = -1i*D;
0068   
0069   phi = zeros(T,N);
0070   
0071   parfor k=1:length(t)
0072     tau = t(k);
0073  
0074     A = -2*kappa.*theta./(sigma.^2) ...
0075         .* log(1-1i*Delta.*c.^2.*sigma.^2./(2*kappa).*(1-exp(-kappa*tau))); 
0076     B = 1i*Delta.*exp(-kappa*tau) ...
0077         ./ (1 - c.^2.*sigma.^2*1i.*Delta./(2*kappa) .* (1-exp(-kappa*tau))); 
0078 
0079     phi(k,:) = prod(exp(C + A + B.*c.^2.*lambda_0).', 1);
0080   end
0081   
0082   % omega==0 yields NaN
0083   idx = find(sum(omega==0)==n); % omega(:,idx)==zeros(n,1)
0084   if idx
0085     phi(:,idx) = 1; % Phi(0) == 1 for all cf
0086   end
0087 end

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