Test FTCOR using exponentially distributed data

$ Author: Chanel Malherbe $ $Date: 11/1/2006$

Contents

Detailed description

This script file tests FTCOR by calculating the correlation of two synchronous series extracted from a simulated time series generated with different correlation coefficients.

Variable Declarations

clear                               %clear workspace
total = waitbar(0,'Total Progess'); %measure overall progress
j = 1;                              %initialize variables
N = 8*60*60/4;                      %set sample size of series
nrsim = 100;                        %set number of monte carlo simulations
expmean = 266;                      %set exponential mean

Preallocation of arrays

ftac = zeros(nrsim,10);
pc = zeros(nrsim,10);
errftac = zeros(nrsim,10);
errpc = zeros(nrsim,10);
kurtftac = zeros(10);
kurtpc = zeros(10);
meanftac = zeros(10);
meanpc = zeros(10);
stdftac = zeros(10);
stdpc = zeros(10);
skewftac = zeros(10);
skewpc = zeros(10);
rmseftac = zeros(10);
rmsepc = zeros(10);

Calculate correlation

%run simulation for different correlation values, k
for k = 0.1:0.1:1
    %run simulation
  	for i = 1:nrsim
        waitbar((i + (j-1)*nrsim)/(nrsim * 10),total);
        clear simdata;
        clear data;
        %generate 2 series with correlation k
        simdata = gencordata(N,k);
        extract = extractData([simdata(1:N,1),simdata(1:N,2),simdata(1:N,3)],expmean);
        eSize = length(extract);
        ftac(i,j) = ftcor([extract(1:eSize,1),extract(1:eSize,2)],[extract(1:eSize,1),extract(1:eSize,3)],1,N);
        temp = corr([simdata(1:N,2),simdata(1:N,3)]);
        pc(i,j) = temp(2,1);
        %calculate relative errors
        if (k > 0)
            errftac(i,j) = (ftac(i,j) - k)/k;
            errpc(i,j) = (pc(i,j) - k)/k;
        end
	 end
    j = j+1;
end
close(total);

%calculate evaluation statistics
i = 1;
%repeat for different values of k
for k = 0.1:0.1:1
    %calculate statistics for fourier method
    %calculate kurtosis
    kurtftac(i) = kurtosis(errftac(1:nrsim,i));
    kurtpc(i) = kurtosis(errpc(1:nrsim,i));
    %calculate bias
    meanftac(i) = mean(errftac(1:nrsim,i));
    meanpc(i) = mean(errpc(1:nrsim,i));
    %calculate standard deviation
    stdftac(i) = std(errftac(1:nrsim,i));
    stdpc(i) = std(errpc(1:nrsim,i));
    %calculate skewness
    skewftac(i) = skewness(errftac(1:nrsim,i));
    skewpc(i) = skewness(errpc(1:nrsim,i));
    %calculate root mean square error
    rmseftac(i) = 0;
    rmsepc(i) = 0;
    for j = 1:nrsim
        rmseftac(i) = rmseftac(i) + (k - ftac(j,i))^2;
        rmsepc(i) = rmsepc(i) + (k - pc(j,i))^2;
    end
    rmseftac(i) = rmseftac(i)/nrsim;
    rmsepc(i) = rmsepc(i)/nrsim;
    i = i+1;
end
Warning: Divide by zero.
Warning: Divide by zero.

Results: Average correlation

%This table and graph shows the average correlation obtained from both methods.  The
%first column shows the value of k, the second the correlation obtained
%from the Fourier method and the second the correlation obtained from the
%Pearson method
plot((1:10),(0.1:0.1:1),'r',(1:10),mean(ftac),'g',(1:10),mean(pc),'b');
legend('Induced correlation','Fourier','Pearson','Location','SouthEast')
[(0.1:0.1:1)',mean(ftac)',mean(pc)']
ans =

    0.1000    0.0846    0.1466
    0.2000    0.2083    0.2731
    0.3000    0.2810    0.2499
    0.4000    0.3931    0.3724
    0.5000    0.4788    0.3585
    0.6000    0.5857    0.5084
    0.7000    0.6849    0.6752
    0.8000    0.7845    0.7329
    0.9000    0.9023    0.8616
    1.0000    1.0000    1.0000

Results: Statistics on Fourier estimator

%This table shows the statistics of the relative errors for the Fourier
%estimator
[(0.1:0.1:1)',kurtftac',skewftac',stdftac',meanftac']
ans =

  Columns 1 through 8 

    0.1000    2.8719    3.0863    2.6852    3.5195    2.5896    4.0177    4.7053
    0.2000         0         0         0         0         0         0         0
    0.3000         0         0         0         0         0         0         0
    0.4000         0         0         0         0         0         0         0
    0.5000         0         0         0         0         0         0         0
    0.6000         0         0         0         0         0         0         0
    0.7000         0         0         0         0         0         0         0
    0.8000         0         0         0         0         0         0         0
    0.9000         0         0         0         0         0         0         0
    1.0000         0         0         0         0         0         0         0

  Columns 9 through 16 

    5.8608    5.0975       NaN   -0.2332   -0.2024   -0.2508   -0.7711   -0.3006
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0

  Columns 17 through 24 

   -0.9340   -1.0597   -1.2081   -1.4407       NaN    2.7764    1.2749    0.8186
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0

  Columns 25 through 32 

    0.5458    0.3615    0.2716    0.2069    0.1340    0.0629         0   -0.1539
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0

  Columns 33 through 40 

    0.0417   -0.0634   -0.0173   -0.0425   -0.0238   -0.0216   -0.0194    0.0025
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0

  Column 41 

         0
         0
         0
         0
         0
         0
         0
         0
         0
         0

Results: Statics on Pearson estimator

%This table shows the statistics of the relative errors for the Pearson
%estimator
[(0.1:0.1:1)',kurtpc',skewpc',stdpc',meanpc']
ans =

  Columns 1 through 8 

    0.1000    2.0116    1.9038    2.1676    2.6131    2.3796    3.2071    4.7086
    0.2000         0         0         0         0         0         0         0
    0.3000         0         0         0         0         0         0         0
    0.4000         0         0         0         0         0         0         0
    0.5000         0         0         0         0         0         0         0
    0.6000         0         0         0         0         0         0         0
    0.7000         0         0         0         0         0         0         0
    0.8000         0         0         0         0         0         0         0
    0.9000         0         0         0         0         0         0         0
    1.0000         0         0         0         0         0         0         0

  Columns 9 through 16 

    6.8348    6.2968    3.1254   -0.2459   -0.3048   -0.4024   -0.7654   -0.6601
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0

  Columns 17 through 24 

   -1.0390   -1.4229   -1.8671   -1.8389    0.0858    4.8785    2.3088    1.5694
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0

  Columns 25 through 32 

    1.1748    0.8499    0.6725    0.4258    0.3318    0.1727    0.0000    0.4655
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0

  Columns 33 through 40 

    0.3657   -0.1670   -0.0690   -0.2830   -0.1527   -0.0354   -0.0838   -0.0427
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0

  Column 41 

    0.0000
         0
         0
         0
         0
         0
         0
         0
         0
         0