Is ttest2 with the 'Vartype' set as 'unequal' essentially the same as a Welch's t-test?
40 views (last 30 days)
Show older comments
Hi all,
Just like to confirm that I've understand the documentation for using the ttest2 ( https://www.mathworks.com/help/stats/ttest2.html ) correctly.
Am I right to assume that when I set 'Vartype' as 'unequal' (essentially saying that variance of samples are NOT known to be the same), ttest2 becomes a Welch's t-test?
Hope you could help me confirm this.
Thank you
1 Comment
Answers (1)
Sim
on 30 Jul 2024
Edited: Sim
on 30 Jul 2024
First Comment. As @DJB wrote in his/her comment, we can go to the "More About" Section of Two-sample t-test, and read the following:
In the case where it is not assumed that the two data samples are from populations with equal variances, the test statistic under the null hypothesis has an approximate Student's t distribution with a number of degrees of freedom given by Satterthwaite's approximation. This test is sometimes called Welch’s t-test.
Second Comment. If you open the algorithm from the Command Window
>> open ttest2
At Line 210 we can read (Please @MathWorks Support Team tell me if the following line is allowed to be shown!)
% unequal variances
...
dfe = (s2xbar + s2ybar) .^2 ./ (s2xbar.^2 ./ (nx-1) + s2ybar.^2 ./ (ny-1));
where "dfe" should be the "effective degrees of freedom" given by Satterthwaite's approximation, that we can read in the Welch's t-test article on Wikipedia:
ttest2(data1, data2, 'Vartype', 'unequal')
to perform the Welch's t-test.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!