⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test1r.m

📁 一个非常实用的统计工具箱
💻 M
字号:
function [pval, r] = test1r(x, method)%TEST1R   Test for median equals 0 using rank test%         %         [pval, ranksum] = test1r(x)%         %         This is called the Wilcoxon signed rank test. It is two %	  sided. If you want a one sided alternative then devide %	  pval by 2. The probability is exact and might take time%	  to compute unless a second argument 'n' is given, in %	  case a normal approximation is used for the distribution%	  of the ranksum.%%	  Ties are presently not properly handled.%       Anders Holtsberg, 18-11-93, 14-Aug-1998, 16-Dec-1998%       Copyright (c) Anders Holtsberg      x = x(:);if nargin < 2  method = 'exact';endI = find(x==0);if ~isempty(I)   fprintf('\nWarning: zeros in data.\n');   fprintf('Method used is to remove all zeros.\n');      x(I) = [];endn = length(x);s = x > 0;[x I] = sort(abs(x));J = find(s(I));r = ranktrf(abs(x));r = sum(r(J));r = min(r,n*(n+1)/2-r);if method(1) == 'e'   F = zeros(1,ceil((n*(n+1)/2+1)/2));   F(1) = 1;   for i=1:n      B = [0.5 zeros(1,i-1) 0.5];      F = filter(B,1,F);   end   pval = min(2*sum(F(1:ceil(r)+1)),1);else   % See B W Lindgren page 509, with continuity correction   m = n*(n+1)/4;   v = n*(n+1)*(2*n+1)/24;   pval = min(1, 2*pnorm((r+0.5-m)/sqrt(v)));end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -