0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 classdef sosttest < genericStatTest
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061 properties
0062 sosObj
0063 name
0064 s1
0065 s2
0066 s1ColName
0067 s2ColName
0068 s1Col
0069 s2Col
0070 type
0071 runSpecificTest
0072 desiredpvalCondition
0073 desiredpvalConditionHandle
0074 desiredpval
0075 targValue
0076 tail
0077 lastp
0078 label
0079 thresh
0080 end
0081
0082 methods
0083
0084
0085 function obj = sosttest(varargin)
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105 p = inputParser;
0106 p.addParamValue('sosObj', 'null',...
0107 @(sosObj)strcmp(class(sosObj),'sos'));
0108 p.addParamValue('type','null', ...
0109 @(type)sosttest.validTestType(type));
0110 p.addParamValue('sample1','null', ...
0111 @(sample1)strcmp(class(sample1),'sample'));
0112 p.addParamValue('name','noname',@(name)ischar(name));
0113
0114
0115
0116 p.KeepUnmatched = true;
0117 p.parse(varargin{:});
0118
0119
0120
0121
0122
0123
0124 sosObj = p.Results.sosObj;
0125
0126 if(strcmp(p.Results.type,'independent'))
0127 obj.constructIndependentSamplettest(sosObj,varargin{:})
0128 elseif(strcmp(p.Results.type,'paired'))
0129 obj.constructPairedSamplettest(sosObj,varargin{:});
0130 elseif strcmp(p.Results.type,'single')
0131 obj.constructSingleSamplettest(sosObj,varargin{:});
0132 else
0133 error(['Specified <type>: ',p.Results.type, ...
0134 ' is not supported']);
0135 end
0136
0137 obj.lastp = NaN;
0138 obj.sosObj = p.Results.sosObj;
0139
0140
0141
0142 if any(strcmp(p.UsingDefaults,'name'))
0143
0144 numTests = length(obj.sosObj.sosstattests);
0145
0146
0147 obj.name = ['ttest_',num2str(numTests+1)];
0148 else
0149 obj.name = p.Results.name;
0150 end
0151
0152 end
0153
0154
0155
0156 function [userHypothesis, prob, label] = runTest(obj,varargin)
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168 [userHypothesis, prob, label] = obj.runSpecificTest(varargin);
0169
0170 obj.lastp = prob;
0171 end
0172
0173
0174 function [userHypothesis, prob, label] = ...
0175 runIndependentSamplettest(obj,varargin)
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187 varargin = varargin{1};
0188
0189 p = inputParser;
0190
0191 p.addParamValue('reportStyle','short', ...
0192 @(reportStyle)any([strcmp(reportStyle,'short') ...
0193 strcmp(reportStyle,'full') ...
0194 strcmp(reportStyle,'none')]));
0195 p.parse(varargin{:});
0196
0197
0198 reportStyle = p.Results.reportStyle;
0199
0200
0201
0202
0203 if isempty(obj.s1.data) || length(obj.s1.data{obj.s1Col}) ~= obj.s1.n
0204 error('sample 1 has not been filled. Aborting stat test.');
0205 end
0206 if isempty(obj.s2.data) || length(obj.s2.data{obj.s1Col}) ~= obj.s2.n
0207 error('sample 2 has not been filled. Aborting stat test.');
0208 end
0209
0210 [h,prob,ci,stats] = ttest2(obj.s1.data{obj.s1Col},...
0211 obj.s2.data{obj.s2Col},...
0212 0.05,obj.tail,'equal');
0213
0214
0215
0216
0217 if isnan(prob)
0218 m1 = mean(obj.s1.data{obj.s1Col});
0219 m2 = mean(obj.s2.data{obj.s2Col});
0220
0221 if m1==m2
0222 prob = 1;
0223 else
0224 prob = 0;
0225 end
0226
0227 end
0228
0229 userHypothesis = obj.desiredpvalConditionHandle(...
0230 prob,obj.desiredpval);
0231
0232
0233 m1 = mean(obj.s1.data{obj.s1Col});
0234 m2 = mean(obj.s2.data{obj.s2Col});
0235
0236 stderr1 = std(obj.s1.data{obj.s1Col})/ ...
0237 sqrt(length(obj.s1.data{obj.s1Col}));
0238 stderr2 = std(obj.s2.data{obj.s2Col})/ ...
0239 sqrt(length(obj.s2.data{obj.s2Col}));
0240
0241 label = [obj.s1.name, '{',obj.s1ColName, '}-', ...
0242 obj.s2.name, '{',obj.s2ColName, '}'];
0243
0244 if (isnan(userHypothesis))
0245 printHyp = 'N/A';
0246 elseif userHypothesis == 1
0247 printHyp = 'PASS';
0248 elseif userHypothesis == 0
0249 printHyp = 'FAIL';
0250
0251 if abs(m2 - m1) < obj.thresh && isnan(obj.thresh) == 0
0252 userHypothesis = 1;
0253 printHyp ='PTHR';
0254
0255 end
0256
0257 end
0258
0259
0260 if (strcmp(reportStyle,'short'))
0261 verbosePrint([' UserHyp: ', printHyp, '; ', label, ': ', ...
0262 't[',obj.type,'](',num2str(stats.df,3),') = ', ...
0263 num2str(stats.tstat), ', p = ', num2str(prob), ...
0264 ' p-des: ',num2str(obj.desiredpval)], ...
0265 'sosttest_ruIndependentSamplettest');
0266 elseif (strcmp(reportStyle,'full'))
0267 verbosePrint([' UserHyp: ', printHyp , ...
0268 '; ', label, ': ', ...
0269 't[',obj.type,'](',num2str(stats.df,3),') = ', ...
0270 num2str(stats.tstat), ', p = ', num2str(prob), ...
0271 ' p-des: ',num2str(obj.desiredpval), ...
0272 ' m(1) = ', num2str(m1),' (se=',num2str(stderr1,4), ...
0273 '); m(2) = ', num2str(m2),' (se=',num2str(stderr2,4), ...
0274 ')', ...
0275 ' thresh = ', num2str(obj.thresh), ...
0276 ], 'sosttest_ruIndependentSamplettest');
0277 end
0278 end
0279
0280
0281
0282 function [userHypothesis, prob, label] = ...
0283 runPairedSamplettest(obj,varargin)
0284
0285
0286
0287
0288
0289
0290
0291
0292
0293
0294 varargin = varargin{1};
0295
0296 p = inputParser;
0297 p.addParamValue('reportStyle','short', ...
0298 @(reportStyle)any([strcmp(reportStyle,'short') ...
0299 strcmp(reportStyle,'full') ...
0300 strcmp(reportStyle,'none')]));
0301 p.parse(varargin{:});
0302
0303 reportStyle = p.Results.reportStyle;
0304
0305 [h,prob,ci,stats] = ttest(obj.s1.data{obj.s1Col},...
0306 obj.s2.data{obj.s2Col},...
0307 0.05,obj.tail);
0308
0309 if isnan(prob)
0310 m = mean(obj.s1.data{obj.s1Col}-obj.s2.data{obj.s2Col});
0311
0312 if m == 0
0313 prob = 1;
0314 else
0315 prob = 0;
0316 end
0317 end
0318
0319 userHypothesis = obj.desiredpvalConditionHandle(...
0320 prob,obj.desiredpval);
0321
0322
0323 m1 = mean(obj.s1.data{obj.s1Col});
0324 m2 = mean(obj.s2.data{obj.s2Col});
0325
0326 dat1 = obj.s1.data{obj.s1Col};
0327 dat2 = obj.s2.data{obj.s2Col};
0328
0329 meanDiff = mean(dat2-dat1);
0330
0331
0332
0333
0334 stderr = stats.sd/length(obj.s1.data{obj.s1Col});
0335
0336 label = [obj.s1.name, '{',obj.s1ColName, '}-', ...
0337 obj.s2.name, '{',obj.s2ColName, '}'];
0338
0339 if (isnan(userHypothesis))
0340 printHyp = 'N/A';
0341 elseif userHypothesis == 1
0342 printHyp = 'PASS';
0343 elseif userHypothesis == 0
0344 printHyp = 'FAIL';
0345
0346 if abs(meanDiff) < obj.thresh && isnan(obj.thresh) == 0
0347 userHypothesis = 1;
0348 printHyp = 'PTHR';
0349 end
0350
0351 end
0352
0353 if (strcmp(reportStyle,'short'))
0354 verbosePrint([' UserHyp: ', printHyp, ...
0355 '; ', label, ': ', ...
0356 't[',obj.type,'](',num2str(stats.df,3),') = ', ...
0357 num2str(stats.tstat), ', p = ', num2str(prob), ...
0358 ' p-des: ',num2str(obj.desiredpval)], ...
0359 'sosttest_runPairedSamplettest');
0360 elseif (strcmp(reportStyle,'full'))
0361 verbosePrint([' UserHyp: ', printHyp, ...
0362 '; ', label, ': ', ...
0363 't[',obj.type,'](',num2str(stats.df,3),') = ', ...
0364 num2str(stats.tstat), ', p = ', num2str(prob), ...
0365 ' p-des: ',num2str(obj.desiredpval), ...
0366 ' m(1) = ', num2str(m1), '; m(2) = ', num2str(m2), ...
0367 ' (se=',num2str(stderr), ')' ...
0368 ' thresh = ', num2str(obj.thresh), ...
0369 ], 'sosttest_runPairedSamplettest');
0370 end
0371 end
0372
0373
0374
0375 function [userHypothesis, prob, label] = ...
0376 runSingleSamplettest(obj,varargin)
0377
0378
0379
0380
0381
0382
0383
0384
0385
0386
0387 varargin = varargin{1};
0388
0389 p = inputParser;
0390 p.addParamValue('reportStyle','short', ...
0391 @(reportStyle)any([strcmp(reportStyle,'short') ...
0392 strcmp(reportStyle,'full') ...
0393 strcmp(reportStyle,'none')]));
0394 p.parse(varargin{:});
0395
0396 reportStyle = p.Results.reportStyle;
0397
0398 [h,prob,ci,stats] = ttest(obj.s1.data{obj.s1Col},...
0399 obj.targValue,...
0400 0.05,obj.tail);
0401
0402 if isnan(prob)
0403 m = mean(obj.s1.data{obj.s1Col});
0404
0405 if m == 0
0406 prob = 1;
0407 else
0408 prob = 0;
0409 end
0410 end
0411
0412 userHypothesis = obj.desiredpvalConditionHandle(...
0413 prob,obj.desiredpval);
0414
0415
0416
0417 m1 = mean(obj.s1.data{obj.s1Col});
0418 stderr = stats.sd/length(obj.s1.data{obj.s1Col});
0419
0420
0421
0422
0423 label = [obj.s1.name, '{',obj.s1ColName, '}-', ...
0424 num2str(obj.targValue)'];
0425
0426 if (isnan(userHypothesis))
0427 printHyp = 'N/A';
0428 elseif userHypothesis == 1
0429 printHyp = 'PASS';
0430 elseif userHypothesis == 0
0431 printHyp = 'FAIL';
0432
0433 if abs(m1-obj.targValue) < obj.thresh && isnan(obj.thresh) == 0
0434 userHypothesis = 1;
0435 printHyp = 'PTHR';
0436 end
0437 end
0438
0439 if (strcmp(reportStyle,'short'))
0440 verbosePrint([' UserHyp: ', printHyp, ...
0441 '; ', label, ': ', ...
0442 't[',obj.type,'](',num2str(stats.df,3),') = ', ...
0443 num2str(stats.tstat), ', p = ', num2str(prob), ...
0444 ' p-des: ',num2str(obj.desiredpval)], ...
0445 'sosttest_runSingleSamplettest');
0446 elseif (strcmp(reportStyle,'full'))
0447 verbosePrint([' UserHyp: ', printHyp, ...
0448 '; ', label, ': ', ...
0449 't[',obj.type,'](',num2str(stats.df,3),') = ', ...
0450 num2str(stats.tstat), ', p = ', num2str(prob), ...
0451 ' p-des: ',num2str(obj.desiredpval), ...
0452 ' m = ', num2str(m1), ...
0453 ' (se=',num2str(stderr), ...
0454 ')', ...
0455 ' thresh = ', num2str(obj.thresh), ...
0456 ], 'sosttest_runSingleSamplettest');
0457 end
0458 end
0459
0460
0461
0462 function constructIndependentSamplettest(obj,sosObj,varargin)
0463
0464
0465
0466
0467
0468
0469
0470
0471
0472
0473
0474
0475
0476
0477
0478
0479
0480
0481
0482
0483
0484
0485
0486
0487
0488
0489 p = inputParser;
0490
0491 p.addRequired('sosObj', ...
0492 @(sosObj)strcmp(class(sosObj),'sos'));
0493 p.addParamValue('type','null', ...
0494 @(type)sosttest.validTestType(type));
0495 p.addParamValue('sample1','null', ...
0496 @(sample1)strcmp(class(sample1),'sample'));
0497 p.addParamValue('sample2','null', ...
0498 @(sample2)strcmp(class(sample2),'sample'));
0499
0500 p.addParamValue('s1ColName',NaN, ...
0501 @(s1ColName)ischar(s1ColName));
0502 p.addParamValue('s2ColName',NaN, ...
0503 @(s2ColName)ischar(s2ColName));
0504 p.addParamValue('desiredpvalCondition','N/A', ...
0505 @(desiredpvalCondition)any([strcmp(desiredpvalCondition,'<='), ...
0506 strcmp(desiredpvalCondition,'=>'), ...
0507 strcmp(desiredpvalCondition,'N/A')]));
0508 p.addParamValue('desiredpval', 0.05, ...
0509 @(desiredpval)validateattributes(desiredpval, ...
0510 {'numeric'}, ...
0511 {'scalar', 'positive', '>=', 0, '<=', 1}));
0512 p.addParamValue('tail','both', ...
0513 @(tail)any([strcmp(tail,'both'), strcmp(tail,'left'),strcmp(tail,'right')]));
0514 p.addParamValue('name','noname',@(name)ischar(name));
0515 p.addParamValue('thresh',NaN,@(thres)validateattributes(thres, ...
0516 {'numeric'}, {'scalar'}));
0517
0518 p.parse(sosObj,varargin{:});
0519
0520
0521 sample1 = p.Results.sample1;
0522 sample2 = p.Results.sample2;
0523 s1ColName = p.Results.s1ColName;
0524 s2ColName = p.Results.s2ColName;
0525 obj.desiredpvalCondition = p.Results.desiredpvalCondition;
0526 obj.thresh = p.Results.thresh;
0527
0528 if strcmp(obj.desiredpvalCondition,'N/A')
0529 obj.desiredpvalConditionHandle = @sosttest.returnNaN;
0530 elseif strcmp(obj.desiredpvalCondition,'<=')
0531 obj.desiredpvalConditionHandle = @le;
0532 elseif strcmp(obj.desiredpvalCondition,'=>')
0533 obj.desiredpvalConditionHandle = @ge;
0534 end
0535
0536
0537 if strcmp(obj.desiredpvalCondition,'N/A')
0538 obj.desiredpval = NaN;
0539 else
0540 obj.desiredpval = p.Results.desiredpval;
0541 end
0542
0543
0544
0545
0546 present1 = sosObj.containsSample(sample1);
0547 if (present1 == 0 )
0548 error('sos sosObject does not contain sample1');
0549 end
0550
0551 present2 = sosObj.containsSample(sample2);
0552 if (present2 == 0 )
0553 error('sos sosObject does not contain sample2');
0554 end
0555
0556 col1 = sample1.colName2colNum(s1ColName);
0557 if(col1 == -1)
0558 error('<s1ColName> not a column of data in <sample1>');
0559 end
0560
0561 col2 = sample1.colName2colNum(s2ColName);
0562 if(col2 == -1)
0563 error('<s2ColName> not a column of data in <sample2>');
0564 end
0565
0566 if isempty(sample1.data)
0567 error('sample 1 does not contain items - did you fill it yet?');
0568 end
0569
0570 if isempty(sample2.data)
0571 error('sample 2 does not contain items - did you fill it yet?');
0572 end
0573
0574
0575 obj.s1 = sample1;
0576 obj.s2 = sample2;
0577 obj.s1ColName = s1ColName;
0578 obj.s2ColName = s2ColName;
0579 obj.s1Col = col1;
0580 obj.s2Col = col2;
0581 obj.type = p.Results.type;
0582 obj.tail = p.Results.tail;
0583
0584 obj.runSpecificTest = @obj.runIndependentSamplettest;
0585
0586 obj.label = [obj.s1.name, '{',obj.s1ColName, '}-', ...
0587 obj.s2.name, '{',obj.s2ColName, '}', ...
0588 ':t[',obj.type,']'];
0589
0590
0591 end
0592
0593
0594 function constructPairedSamplettest(obj,sosObj,varargin)
0595
0596
0597
0598
0599
0600
0601
0602
0603
0604
0605
0606
0607
0608
0609
0610
0611
0612
0613
0614
0615
0616
0617
0618
0619 p = inputParser;
0620
0621 p.addRequired('sosObj', ...
0622 @(sosObj)strcmp(class(sosObj),'sos'));
0623 p.addParamValue('type','null', ...
0624 @(type)sosttest.validTestType(type));
0625 p.addParamValue('sample1','null', ...
0626 @(sample1)strcmp(class(sample1),'sample'));
0627 p.addParamValue('sample2','null', ...
0628 @(sample2)strcmp(class(sample2),'sample'));
0629
0630 p.addParamValue('s1ColName',NaN, ...
0631 @(s1ColName)ischar(s1ColName));
0632 p.addParamValue('s2ColName',NaN, ...
0633 @(s2ColName)ischar(s2ColName));
0634 p.addParamValue('desiredpvalCondition','N/A', ...
0635 @(desiredpvalCondition)any([strcmp(desiredpvalCondition,'<='), ...
0636 strcmp(desiredpvalCondition,'=>'), ...
0637 strcmp(desiredpvalCondition,'N/A')]));
0638 p.addParamValue('desiredpval', 0.05, ...
0639 @(desiredpval)validateattributes(desiredpval, ...
0640 {'numeric'}, ...
0641 {'scalar', 'positive', '>=', 0, '<=', 1}));
0642 p.addParamValue('tail','both', ...
0643 @(tail)any([strcmp(tail,'both'), strcmp(tail,'left'),strcmp(tail,'right')]));
0644 p.addParamValue('name','noname',@(name)ischar(name));
0645 p.addParamValue('thresh',NaN,@(thres)validateattributes(thres, ...
0646 {'numeric'}, {'scalar'}));
0647
0648
0649 p.parse(sosObj,varargin{:});
0650
0651
0652 sample1 = p.Results.sample1;
0653 sample2 = p.Results.sample2;
0654 s1ColName = p.Results.s1ColName;
0655 s2ColName = p.Results.s2ColName;
0656 obj.desiredpvalCondition = p.Results.desiredpvalCondition;
0657 obj.thresh = p.Results.thresh;
0658
0659 if strcmp(obj.desiredpvalCondition,'N/A')
0660 obj.desiredpvalConditionHandle = @sosttest.returnNaN;
0661 elseif strcmp(obj.desiredpvalCondition,'<=')
0662 obj.desiredpvalConditionHandle = @le;
0663 elseif strcmp(obj.desiredpvalCondition,'=>')
0664 obj.desiredpvalConditionHandle = @ge;
0665 end
0666
0667
0668 if strcmp(obj.desiredpvalCondition,'N/A')
0669 obj.desiredpval = NaN;
0670 else
0671 obj.desiredpval = p.Results.desiredpval;
0672 end
0673
0674
0675
0676
0677 present1 = sosObj.containsSample(sample1);
0678 if (present1 == 0 )
0679 error('sos sosObject does not contain sample1');
0680 end
0681
0682 present2 = sosObj.containsSample(sample2);
0683 if (present2 == 0 )
0684 error('sos sosObject does not contain sample2');
0685 end
0686
0687 col1 = sample1.colName2colNum(s1ColName);
0688 if(col1 == -1)
0689 error('<s1ColName> not a column of data in <sample1>');
0690 end
0691
0692 col2 = sample1.colName2colNum(s2ColName);
0693 if(col2 == -1)
0694 error('<s2ColName> not a column of data in <sample2>');
0695 end
0696
0697
0698
0699
0700 if isempty(sample1.data)
0701 error('sample 1 does not contain items - did you fill it yet?');
0702 end
0703
0704 if isempty(sample2.data)
0705 error('sample 2 does not contain items - did you fill it yet?');
0706 end
0707
0708 if (length(sample1.data{col1}) ~= length(sample2.data{col2}))
0709 error('Sample 1 and Sample 2 must have the same number of observations for a paired comparison');
0710 end
0711
0712
0713
0714 obj.s1 = sample1;
0715 obj.s2 = sample2;
0716 obj.s1ColName = s1ColName;
0717 obj.s2ColName = s2ColName;
0718 obj.s1Col = col1;
0719 obj.s2Col = col2;
0720 obj.type = p.Results.type;
0721 obj.tail = p.Results.tail;
0722
0723 obj.runSpecificTest = @obj.runPairedSamplettest;
0724
0725 obj.label = [obj.s1.name, '{',obj.s1ColName, '}-', ...
0726 obj.s2.name, '{',obj.s2ColName, '}', ...
0727 ':t[',obj.type,']'];
0728
0729
0730 end
0731
0732
0733 function constructSingleSamplettest(obj,sosObj,varargin)
0734
0735
0736
0737
0738
0739
0740
0741
0742
0743
0744
0745
0746
0747
0748
0749
0750
0751
0752
0753
0754
0755
0756
0757
0758 p = inputParser;
0759
0760 p.addRequired('sosObj', ...
0761 @(sosObj)strcmp(class(sosObj),'sos'));
0762 p.addParamValue('type','null', ...
0763 @(type)sosttest.validTestType(type));
0764 p.addParamValue('sample1','null', ...
0765 @(sample1)strcmp(class(sample1),'sample'));
0766
0767 p.addParamValue('s1ColName',NaN, ...
0768 @(s1ColName)ischar(s1ColName));
0769 p.addParamValue('targValue', 0.0, ...
0770 @(targValue)validateattributes(targValue, ...
0771 {'numeric'}, {'scalar'}));
0772 p.addParamValue('desiredpvalCondition','N/A', ...
0773 @(desiredpvalCondition)any([strcmp(desiredpvalCondition,'<='), ...
0774 strcmp(desiredpvalCondition,'=>'), ...
0775 strcmp(desiredpvalCondition,'N/A')]));
0776 p.addParamValue('desiredpval', 0.05, ...
0777 @(desiredpval)validateattributes(desiredpval, ...
0778 {'numeric'}, ...
0779 {'scalar', 'positive', '>=', 0, '<=', 1}));
0780 p.addParamValue('tail','both', ...
0781 @(tail)any([strcmp(tail,'both'), strcmp(tail,'left'),strcmp(tail,'right')]));
0782 p.addParamValue('name','noname',@(name)ischar(name));
0783 p.addParamValue('thresh',NaN,@(thres)validateattributes(thres, ...
0784 {'numeric'}, {'scalar'}));
0785
0786 p.parse(sosObj,varargin{:});
0787
0788
0789 sample1 = p.Results.sample1;
0790 s1ColName = p.Results.s1ColName;
0791 obj.desiredpvalCondition = p.Results.desiredpvalCondition;
0792 obj.targValue = p.Results.targValue;
0793 obj.thresh = p.Results.thresh;
0794
0795 if strcmp(obj.desiredpvalCondition,'N/A')
0796 obj.desiredpvalConditionHandle = @sosttest.returnNaN;
0797 elseif strcmp(obj.desiredpvalCondition,'<=')
0798 obj.desiredpvalConditionHandle = @le;
0799 elseif strcmp(obj.desiredpvalCondition,'=>')
0800 obj.desiredpvalConditionHandle = @ge;
0801 end
0802
0803
0804 if strcmp(obj.desiredpvalCondition,'N/A')
0805 obj.desiredpval = NaN;
0806 else
0807 obj.desiredpval = p.Results.desiredpval;
0808 end
0809
0810
0811
0812
0813 present1 = sosObj.containsSample(sample1);
0814 if (present1 == 0 )
0815 error('sos sosObject does not contain sample1');
0816 end
0817
0818 col1 = sample1.colName2colNum(s1ColName);
0819 if(col1 == -1)
0820 error('<s1ColName> not a column of data in <sample1>');
0821 end
0822
0823
0824 if isempty(sample1.data)
0825 error('sample 1 does not contain items - did you fill it yet?');
0826 end
0827
0828
0829
0830
0831 obj.s1 = sample1;
0832 obj.s1ColName = s1ColName;
0833 obj.s1Col = col1;
0834 obj.type = p.Results.type;
0835 obj.tail = p.Results.tail;
0836
0837 obj.runSpecificTest = @obj.runSingleSamplettest;
0838
0839
0840 obj.label = [obj.s1.name, '{',obj.s1ColName, '}-', ...
0841 num2str(obj.targValue),':t[',obj.type,']'];
0842
0843 end
0844 end
0845
0846
0847 methods (Static)
0848
0849
0850 function userHypothesis = returnNaN(~,~)
0851
0852 userHypothesis = NaN;
0853 end
0854
0855
0856 function flag = validTestType(str)
0857
0858
0859 flag = 0;
0860
0861 if(ischar(str) == false)
0862 error('<Type> must be either "single","paired", or "independent"');
0863 end
0864
0865 if (strcmp(str,'single') || strcmp(str,'paired') || ...
0866 strcmp(str,'independent'))
0867 flag = 1;
0868 else
0869 error('<Type> must be either "single","paired", or "independent"');
0870 end
0871
0872 end
0873 end
0874
0875 end
0876