CF_PCSV_PARTIAL Calculates characteristic function values for a PCSV partial 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: "mean reversion speed" theta: "mean reversion means" sigma: "mean reversion volatilities" rho: noise correlation 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_PCSV_V, CF_GBM_V. created by Benedikt Rudolph DATE: 31-Jan-2013
0001 function phi = cf_pcsv_partial(mu, A, lambda_0, kappa, theta, sigma ... 0002 , rho, omega, y_t, tau) 0003 %CF_PCSV_PARTIAL Calculates characteristic function values for a PCSV partial 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: "mean reversion speed" 0015 % theta: "mean reversion means" 0016 % sigma: "mean reversion volatilities" 0017 % rho: noise correlation 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_PCSV_V, CF_GBM_V. 0026 % 0027 % created by Benedikt Rudolph 0028 % DATE: 31-Jan-2013 0029 0030 % n: number of assets 0031 % p: number of eigenvectors, only the 1st is stochastic 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 lambda_0 to required form 0046 lambda_0 = reshape(lambda_0, 1, p); 0047 0048 lambda_0 = repmat(lambda_0, N, 1); % N x p 0049 kappa = repmat(kappa, N, 1); % N x 1 0050 theta = repmat(theta, N, 1); % N x 1 0051 sigma = repmat(sigma, N, 1); % N x 1 0052 rho = repmat(rho, N, 1); % N x 1 0053 0054 % eigenvalues 2 to p 0055 0056 phi_lognormal = prod( (exp(... 0057 (r(:,2:p) + b(:,2:p).*lambda_0(:,2:p))*tau*ph ... 0058 - 0.5 * (c(:,2:p).^2.*lambda_0(:,2:p))*tau*ph^2 ... 0059 )).', 1); 0060 0061 % first eigenvalue 0062 0063 c = c(:,1); 0064 b = b(:,1); 0065 r = r(:,1); 0066 0067 d = sqrt((kappa-rho.*c.*sigma.*ph*1i).^2-sigma.^2.*(2*b.*ph*1i-c.^2.*ph.^2)); 0068 g = (kappa - rho.*c.*sigma.*ph*1i + d) ./ (kappa - rho.*c.*sigma.*ph*1i - d); 0069 0070 C = r*tau.*ph*1i + kappa.*theta./(sigma.^2) .* ... 0071 ((kappa-rho.*c.*sigma.*ph*1i+d)*tau - 2*log((1-g.*exp(d*tau))./(1-g))); 0072 D = (kappa - rho.*c.*sigma.*ph*1i + d) ./ (c.^2.*sigma.^2) .* ... 0073 (1 - exp(d*tau)) ./ (1-g.*exp(d*tau)); 0074 0075 Delta = -1i*D; 0076 0077 phi = zeros(T,N); 0078 0079 parfor k=1:length(t) 0080 tau = t(k); 0081 0082 A = -2*kappa.*theta./(sigma.^2) ... 0083 .* log(1-1i*Delta.*c.^2.*sigma.^2./(2*kappa).*(1-exp(-kappa*tau))); 0084 B = 1i*Delta.*exp(-kappa*tau) ... 0085 ./ (1 - c.^2.*sigma.^2*1i.*Delta./(2*kappa) .* (1-exp(-kappa*tau))); 0086 0087 phi(k,:) = phi_lognormal .* exp(C + A + B.*c.^2.*lambda_0(:,1)).'; 0088 end 0089 0090 % omega==0 yields NaN 0091 idx = find(sum(omega==0)==n); % omega(:,idx)==zeros(n,1) 0092 if idx 0093 phi(:,idx) = 1; % Phi(0) == 1 for all cf 0094 end 0095 end