Home > atmlab > circular > circ_vtest.m

circ_vtest

PURPOSE ^

SYNOPSIS ^

function [pval v] = circ_vtest(alpha, dir, w, d)

DESCRIPTION ^

 [pval, v] = circ_vtest(alpha, dir, w, d)
   Computes V test for non-uniformity of circular data with a specified 
   mean direction dir.
   H0: the population is uniformly distributed around the circle
   HA: the population is not distributed uniformly around the circle but
   has a mean of dir.

   Note: Not rejecting H0 may mean that the population is uniformly
   distributed around the circle OR that it has a mode but that this mode
   is not centered at dir.

   The V test has more power than the Rayleigh test and is preferred if
   there is reason to believe in a specific mean direction. 

   Input:
     alpha    sample of angles in radians
     dir   suspected mean direction
     [w        number of incidences in case of binned angle data]
     [d    spacing of bin centers for binned data, if supplied 
           correction factor is used to correct for bias in 
           estimation of r, in radians (!)]

   Output:
     pval  p-value of V test
     v     value of the V statistic

 PHB 7/6/2008

 References:
   Biostatistical Analysis, J. H. Zar

 Circular Statistics Toolbox for Matlab

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

circ_vtest.m

SOURCE CODE ^

0001 function [pval v] = circ_vtest(alpha, dir, w, d)
0002 %
0003 % [pval, v] = circ_vtest(alpha, dir, w, d)
0004 %   Computes V test for non-uniformity of circular data with a specified
0005 %   mean direction dir.
0006 %   H0: the population is uniformly distributed around the circle
0007 %   HA: the population is not distributed uniformly around the circle but
0008 %   has a mean of dir.
0009 %
0010 %   Note: Not rejecting H0 may mean that the population is uniformly
0011 %   distributed around the circle OR that it has a mode but that this mode
0012 %   is not centered at dir.
0013 %
0014 %   The V test has more power than the Rayleigh test and is preferred if
0015 %   there is reason to believe in a specific mean direction.
0016 %
0017 %   Input:
0018 %     alpha    sample of angles in radians
0019 %     dir   suspected mean direction
0020 %     [w        number of incidences in case of binned angle data]
0021 %     [d    spacing of bin centers for binned data, if supplied
0022 %           correction factor is used to correct for bias in
0023 %           estimation of r, in radians (!)]
0024 %
0025 %   Output:
0026 %     pval  p-value of V test
0027 %     v     value of the V statistic
0028 %
0029 % PHB 7/6/2008
0030 %
0031 % References:
0032 %   Biostatistical Analysis, J. H. Zar
0033 %
0034 % Circular Statistics Toolbox for Matlab
0035 
0036 % By Philipp Berens, 2009
0037 % berens@tuebingen.mpg.de - www.kyb.mpg.de/~berens/circStat.html
0038 
0039 
0040 if size(alpha,2) > size(alpha,1)
0041     alpha = alpha';
0042 end
0043 
0044 if nargin<3
0045   % if no specific weighting has been specified
0046   % assume no binning has taken place
0047     w = ones(size(alpha));
0048 else
0049   if size(w,2) > size(w,1)
0050     w = w';
0051   end 
0052   if length(alpha)~=length(w)
0053     error('Input dimensions do not match.')
0054   end
0055 end
0056 
0057 if nargin<4
0058   % per default do not apply correct for binned data
0059   d = 0;
0060 end
0061 
0062 % compute some ingredients
0063 r = circ_r(alpha,w,d);
0064 mu = circ_mean(alpha,w);
0065 n = sum(w);
0066 
0067 % compute Rayleigh's R (equ. 27.1)
0068 R = n * r;
0069 
0070 % compute the V statistic (equ. 27.5)
0071 v = R * cos(mu-dir);
0072 
0073 % compute u (equ. 27.6)
0074 u = v * sqrt(2/n);
0075 
0076 % compute p-value from one tailed normal approximation
0077 pval = 1 - normcdf(u);

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