From: <sch...@us...> - 2010-11-25 23:37:23
|
Revision: 7951 http://octave.svn.sourceforge.net/octave/?rev=7951&view=rev Author: schloegl Date: 2010-11-25 23:37:17 +0000 (Thu, 25 Nov 2010) Log Message: ----------- add correlation and regression analysis, variance analysis, etc. Modified Paths: -------------- trunk/octave-forge/extra/NaN/inst/bland_altman.m Modified: trunk/octave-forge/extra/NaN/inst/bland_altman.m =================================================================== --- trunk/octave-forge/extra/NaN/inst/bland_altman.m 2010-11-25 18:07:59 UTC (rev 7950) +++ trunk/octave-forge/extra/NaN/inst/bland_altman.m 2010-11-25 23:37:17 UTC (rev 7951) @@ -14,9 +14,9 @@ % % % References: -% JM Bland and DG Altman, Measuring agreement in method comparison studies. -% Statistical Methods in Medical Research, 1999; 8; 135. -% doi:10.1177/09622802990080204 +% [1] JM Bland and DG Altman, Measuring agreement in method comparison studies. +% Statistical Methods in Medical Research, 1999; 8; 135. +% doi:10.1177/09622802990080204 % $Id$ % Copyright (C) 2010 by Alois Schloegl <a.s...@ie...> @@ -49,42 +49,56 @@ D = data * [1;-1]; M = data * [1;1]/2; +RES.corrcoef = corrcoef(data(:,1),data(:,2),'spearman'); +[REs.cc,RES.p] = corrcoef(M,D,'spearman'); +if (RES.p<0.05) + warning('A regression model according to section 3.2 [1] should be used'); + %% TODO: implement support for this type of data. + RES.a = [ones(size(data,1),1),D]\M; + RES.b = [ones(size(data,1),1),M]\D; +end; -RES.corrcoef = corrcoef(M,D,'spearman'); - - if isempty(group) G = [1:size(data,1)]'; m = ones(size(data,1),1); d = D; + RES.Bias = mean(d,1); + RES.Var = var(d); elseif ~isempty(group) %% TODO: this is not finished - [G,I,J] = unique (group) + warning('analysis of data with repetitions is experimental!') + [G,I,J] = unique (group); + R = zeros(size(data)); m = repmat(NaN,length(G),1); n = repmat(NaN,length(G),1); d = repmat(NaN,length(G),1); d2 = repmat(NaN,length(G),1); data2 = repmat(NaN,length(G),size(data,2)); SW2 = repmat(NaN,length(G),size(data,2)); - for i = 1:length(G) - ix = find(group==G(k)); + for i = 1:length(G), + ix = find(group==G(i)); n(i) = length(ix); - data2(i,:) = mean(data(ix,:)); - SW2(i,:) = var(data(ix,:)); + [R(ix,:), data2(i,:)] = center(data(ix,:)); d(i) = mean(D(ix,:)); m(i) = mean(M(ix,:)); d2(i) = mean(D(ix,:).^2); - end; - RES.repeatability_coefficient = mean(SW2,2); + end; + RES.group = bland_altman(data2); + RES.repeatability_coefficient = var(R,1); % variance with factor group removed + RES.var_d_ = var(d); + RES.var_m_ = var(m); + return; + D = d; M = m; % RES.sigma2_dw = + + RES.Bias = mean(d,1,[],n); end; -RES.Bias = mean(d,1,[],n); plot(M,D,'o', [min(M),max(M)]', [0,0]','k--', [min(M),max(M)]', [1,1,1; 0,1.96,-1.96]'*[RES.Bias;std(D)]*[1,1], 'k-'); -xlabel('mean') -ylabel('difference') +xlabel('mean'); +ylabel('difference'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |