Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

bootsigmoid_val.m 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. function [p,D]=bootsigmoid(A,B,varargin)
  2. % [p,D]=bootsigmoid(A,B,varargin)
  3. % Takes two sets of N x 2 binomial data A and B, and fits sigmoids to them
  4. % both. It then uses the mean and covariance of the fits to calculate the
  5. % distance (using the projection of the fits onto fisher's linear
  6. % discriminant) of the fits.
  7. % Then we permute the rows of A and B to generate permuted data sets and
  8. % perform the same fits and estimates of "distance". Finally, the distance
  9. % between A and B fits are compared to the distribution of distances
  10. % generated by permuting A and B.
  11. BOOTS=100000;
  12. utils.overridedefaults(who,varargin);
  13. import stats.*
  14. [dAB, D]=get_dist(A,B);
  15. n_A=size(A,1);
  16. n_B=size(B,1);
  17. permAB=nan(BOOTS,1);
  18. M=[A;B];
  19. parfor bx=1:BOOTS
  20. rperm=randperm(n_A+n_B);
  21. rA=M(rperm(1:n_A),:);
  22. rB=M(rperm((n_A+1):end),:);
  23. permAB(bx)=get_dist(rA,rB);
  24. end
  25. p= stats.get_p(dAB,permAB);
  26. D.permAB=permAB;
  27. D.p=p;
  28. end %sfunction
  29. function [dAB,D]=get_dist(A,B)
  30. n_A=size(A,1);
  31. n_B=size(B,1);
  32. aidx=randperm(n_A);
  33. bidx=randperm(n_B);
  34. Alim=floor(n_A/2);
  35. Blim=floor(n_B/2);
  36. trainAdx=aidx(1:Alim);
  37. trainBdx=bidx(1:Blim);
  38. testAdx=aidx(Alim+1:end);
  39. testBdx=bidx(Blim+1:end);
  40. [nbetaA,~,~,covA,~]=nlinfit(A(trainAdx,1),A(trainAdx,2),@sig4,[0 1 0 10]);
  41. [nbetaB,~,~,covB,~]=nlinfit(B(trainBdx,1),B(trainBdx,2),@sig4,[0 1 0 10]);
  42. vAB=flda(nbetaA,nbetaB,covA,covB,Alim,Blim);
  43. [betaA,~,~,~,~]=nlinfit(A(testAdx,1),A(testAdx,2),@sig4,[0 1 0 10]);
  44. [betaB,~,~,~,~]=nlinfit(B(testBdx,1),B(testBdx,2),@sig4,[0 1 0 10]);
  45. dAB=abs(betaA*vAB-betaB*vAB);
  46. D.trainbetaA=nbetaA;
  47. D.trainbetaB=nbetaB;
  48. D.testbetaA=betaA;
  49. D.testbetaB=betaB;
  50. D.covA=covA;
  51. D.covB=covB;
  52. D.vAB=vAB;
  53. D.dAB=dAB;
  54. end % subfunction