Home > atmlab > circular > circ_corrcl.m

circ_corrcl

PURPOSE ^

SYNOPSIS ^

function [rho pval] = circ_corrcl(alpha, x)

DESCRIPTION ^

 [rho pval ts] = circ_corrcc(alpha, x)
   Correlation coefficient between one circular and one linear random
   variable.

   Input:
     alpha   sample of angles in radians
     x       sample of linear random variable

   Output:
     rho     correlation coefficient
     pval    p-value

 References:
     Biostatistical Analysis, J. H. Zar, p. 651

 PHB 6/7/2008

 Circular Statistics Toolbox for Matlab

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

circ_corrcl.m

SOURCE CODE ^

0001 function [rho pval] = circ_corrcl(alpha, x)
0002 %
0003 % [rho pval ts] = circ_corrcc(alpha, x)
0004 %   Correlation coefficient between one circular and one linear random
0005 %   variable.
0006 %
0007 %   Input:
0008 %     alpha   sample of angles in radians
0009 %     x       sample of linear random variable
0010 %
0011 %   Output:
0012 %     rho     correlation coefficient
0013 %     pval    p-value
0014 %
0015 % References:
0016 %     Biostatistical Analysis, J. H. Zar, p. 651
0017 %
0018 % PHB 6/7/2008
0019 %
0020 % Circular Statistics Toolbox for Matlab
0021 
0022 % By Philipp Berens, 2009
0023 % berens@tuebingen.mpg.de - www.kyb.mpg.de/~berens/circStat.html
0024 
0025 
0026 if size(alpha,2) > size(alpha,1)
0027     alpha = alpha';
0028 end
0029 
0030 if size(x,2) > size(x,1)
0031     x = x';
0032 end
0033 
0034 if length(alpha)~=length(x)
0035   error('Input dimensions do not match.')
0036 end
0037 
0038 n = length(alpha);
0039 
0040 % compute correlation coefficent for sin and cos independently
0041 rxs = corr(x,sin(alpha));
0042 rxc = corr(x,cos(alpha));
0043 rcs = corr(sin(alpha),cos(alpha));
0044 
0045 % compute angular-linear correlation (equ. 27.47)
0046 rho = sqrt((rxc^2 + rxs^2 - 2*rxc*rxs*rcs)/(1-rcs^2));
0047 
0048 % compute pvalue
0049 pval = 1 - chi2cdf(n*rho^2,2);
0050

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005