Change significance value in ttest2
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I want to do two ttest2 tests; one where the significance value is 5% and one where it is 0.0125% for the difference in mean value of the species Versicolor and Virginica (of the data set fisheriris) four different variables.
This was my code for the default significance value:
load fisheriris
%Versicolor
ver1 = meas(51:100,1);
ver2 = meas(51:100,2);
ver3 = meas(51:100,3);
ver4 = meas(51:100,4);
%Virginica
vir1 = meas(101:150,1);
vir2 = meas(101:150,2);
vir3 = meas(101:150,3);
vir4 = meas(101:150,4);
% ttest2
[h1, p1, ci1] = ttest2(ver1, vir1, 'Vartype', 'unequal')
[h2, p2, ci2] = ttest2(ver2, vir2, 'Vartype', 'unequal')
[h3, p3, ci3] = ttest2(ver3, vir3, 'Vartype', 'unequal')
[h4, p4, ci4] = ttest2(ver4, vir4, 'Vartype', 'unequal')
And then for the significance value 0.0125% I wrote:
[h11, p11, ci11] = ttest2(ver1, vir1, 'Vartype', 'unequal', 'alpha', 0.05/4)
[h22, p22, ci22] = ttest2(ver2, vir2, 'Vartype', 'unequal','alpha', 0.05/4)
[h33, p33, ci33] = ttest2(ver3, vir3, 'Vartype', 'unequal','alpha', 0.05/4)
[h44, p44, ci44] = ttest2(ver4, vir4, 'Vartype', 'unequal','alpha', 0.05/4)
Firstly, does this give me the mean difference between the variables? Secondly, the two tests give the same h and p values and only the confidence interval differs, which i don't believe to be correct. I found a question asked here saying that trying ranksum should give the same p value as ttest2 and then the result could be considered correct. So I tried:
[rp1, rh1, rci1] = ranksum(ver1, vir1, 'alpha', 0.05/4)
which gives me a completely different value for p.
Could someone explain where I am going wrong? Thank you!
0 Kommentare
Antworten (1)
Ive J
am 2 Jan. 2021
No, it doesn't say that. I just says Wilcoxon is a distribution independent (non-parametric) test. Non-parametric tests don't make any assumption of underlying distribution. This does not mean that their test statistics and hence, their p-values are the same.
For the first part of your question, of course the p-value would be same irrespective of alpha level you chose. P-value is calculated from the test statistic which remains constant simply becasue your variables on interest are the same! The only difference is confidence interval which relies on the alpha level you choose. When alpha is 0.05, you get a 95% CI, and when is 0.0125 it's (1-0.0125 =) 98.75% CI.
2 Kommentare
Ive J
am 2 Jan. 2021
Bearbeitet: Ive J
am 2 Jan. 2021
In this case you can use ttest2 given that your variables satisfy t-test assumptions (e.g. normal variables or fairly large sample size). Please note that h tells you if you can reject your H0 depending on the alpha level you've chosen. In your example, if p-values are below both 0.05 and 0.05/4, so you can confidently reject the null (that's why h of two tests is same) that two populations have equal means .
Hypothetically speaking (and clearly), if p-value was 0.03, you would only reject the null of first test (alpha = 0.05) and not the latter (alpha = 0.05/4).
But again, note that this has nothing to do with test statistic itself (tstat1 in your other snippet):
tstat = mean(X) / (std(X)/sqrt(numel(X)));
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!