SIM_PCSV_PARTIAL Simulates a PCSV partial model for the given time points in t. [y, lambda] = sim_pcsv_partial(y_0, mu, A, lambda_0, kappa, theta, sigma, rho, t) Performs an Euler simulation of the PCSV partial 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/constant eigenvalues kappa: scalar "mean reversion speed" theta: scalar "mean reversion mean" sigma: scalar "mean reversion volatility" rho: scalar noise correlation 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-dimensional vector of the simulated eigenvalues See also SIM_WASC_2D, SIM_PCSV. created by Benedikt Rudolph DATE: 04-Feb-2013
0001 function [y, lambda] = sim_pcsv_partial(y_0, mu, A, lambda_0, kappa ... 0002 , theta, sigma, rho, t) 0003 %SIM_PCSV_PARTIAL Simulates a PCSV partial model for the given time points in t. 0004 % 0005 % [y, lambda] = sim_pcsv_partial(y_0, mu, A, lambda_0, kappa, theta, sigma, rho, t) 0006 % Performs an Euler simulation of the PCSV partial model specified by the 0007 % given 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/constant eigenvalues 0015 % kappa: scalar "mean reversion speed" 0016 % theta: scalar "mean reversion mean" 0017 % sigma: scalar "mean reversion volatility" 0018 % rho: scalar noise correlation 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-dimensional vector of the simulated eigenvalues 0024 % 0025 % See also SIM_WASC_2D, SIM_PCSV. 0026 % 0027 % created by Benedikt Rudolph 0028 % DATE: 04-Feb-2013 0029 0030 n = size(A,1); % dimension of the problem 0031 p = size(A,2); % number of driving eigenvectors / noises, just one stochastic 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 0037 y = zeros(T, n); % pre-allocation 0038 y(1,:) = y_0; 0039 0040 lambda = zeros(T, 1); % pre-allocation 0041 lambda(1) = lambda_0(1); 0042 0043 dB = normrnd(0, 1, T-1, 1); % noise driving the eigenvalue 0044 dW = normrnd(0, 1, T-1, p); % noise driving the log returns 0045 % correlate noises by rho 0046 dW(:,1) = repmat(rho,T-1,1).*dB + repmat(sqrt(1-rho.^2),T-1,1).*dW(:,1); 0047 0048 for k=2:T 0049 l_k = [lambda(k-1), lambda_0(2:end)]; 0050 y(k,:) = y(k-1,:) + (mu - 0.5 * l_k * A'.^2).*dt(k-1) ... 0051 + ( sqrt(l_k) .* dW(k-1,:) * A' ) *sqrt(dt(k-1)); 0052 lambda(k) = lambda(k-1) + kappa.*(theta-lambda(k-1))*dt(k-1) ... 0053 + sigma.*sqrt(lambda(k-1)).*dB(k-1)*sqrt(dt(k-1)); 0054 lambda(k,:) = abs( lambda(k,:) ); 0055 end 0056 end