Home > code > main > wasc_estimation.m

wasc_estimation

PURPOSE ^

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 cd('..');
0002 boot;
0003 cd(cgmm_config.directories.main);
0004 
0005 % Init parameters
0006 n = 2
0007 dt = 1/250;
0008 
0009 % load two-dimensional time series for estimation
0010 s = csvread(cgmm_config.time_series.file,1,0);
0011 y = log(s);
0012 r_real = diff(y);
0013 y_0 = y(1,:);
0014 
0015 % perform heuristic estimation of parameters
0016 [mu_heur, Sigma_0_heur, M_heur, Q_heur, rho_heur, beta_heur] ...
0017       = heuristic_wasc_param_2d(y, dt)
0018 
0019 % encode parameters into flat parameter vector
0020 % call it theta_flat to avoid naming conflicts with the mean reversion
0021 % level parameter theta
0022 [theta_flat_0, decode] = encode_wasc_param(mu_heur, Sigma_0_heur, M_heur ...
0023                                   , Q_heur, rho_heur, beta_heur);
0024 
0025 % prepare characteristic function call with the encoded parameters
0026 cf = @(omega, th, y_t, tau) cf_wasc_v_theta(decode, omega, th, y_t, tau);
0027 
0028 % prepare options for optimization routine
0029 options = optimset('Display', 'iter' ...
0030                   , 'Algorithm', 'interior-point');
0031 % contraint for all parameters of +-25% around heuristic estimate
0032 lb = theta_flat_0 - abs(theta_flat_0)*0.25;
0033 ub = theta_flat_0 + abs(theta_flat_0)*0.25;
0034 lb(6) = -max(abs(theta_flat_0(5:8)))*0.25; % lower left Q; heurist estimate = 0
0035 ub(6) = max(abs(theta_flat_0(5:8)))*0.25; % lower left Q; heurist estimate = 0
0036 % except for correlation (where absolute constraints are more feasible)
0037 lb(end-2:end-1) = max(theta_flat_0(end-2:end-1)-0.6, -1);
0038 ub(end-2:end-1) = min(theta_flat_0(end-2:end-1)+0.6, 1);
0039 % and beta
0040 lb(end) = 7;
0041 ub(end) = 13;
0042 
0043 % perform parameter estimation
0044 tic;
0045 [theta_flat_cgmm, theta_flat_first] = cgmm(y, dt, cf, theta_flat_0 ...
0046                                             , cgmm_config.cgmm.grid_min ...
0047                                             , cgmm_config.cgmm.grid_max ...
0048                                             , cgmm_config.cgmm.grid_res ...
0049                                             , lb, ub, options);
0050 toc;
0051 
0052 % decode parameters
0053 [mu_first, Sigma_0_first, M_first, Q_first, rho_first, beta_first] ...
0054                 = decode_wasc_param(theta_flat_first, decode);
0055 
0056 [mu_cgmm, Sigma_0_cgmm, M_cgmm, Q_cgmm, rho_cgmm, beta_cgmm] ...
0057                 = decode_wasc_param(theta_flat_cgmm, decode);
0058 
0059 % save heuristic estimates, first step estimates and cgmm estimates
0060 save( ...
0061   cgmm_config.estimates.wasc ...
0062   , 'theta_flat_0', 'mu_heur', 'Sigma_0_heur', 'M_heur' ...
0063   , 'Q_heur', 'rho_heur', 'beta_heur' ...
0064   , 'theta_flat_first', 'mu_first', 'Sigma_0_first', 'M_first' ...
0065   , 'Q_first', 'rho_first', 'beta_first' ...
0066   , 'theta_flat_cgmm', 'mu_cgmm', 'Sigma_0_cgmm', 'M_cgmm' ...
0067   , 'Q_cgmm', 'rho_cgmm', 'beta_cgmm' ...
0068 )

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