This packages provides an implementation of the moderated t-test, which utilizes an empirical Bayes method to shrink the sample variances towards a common value and augment the degrees of freedom for the individual variances, resulting in increased statistical power. It includes two functions: 'moderated_ttest' for one-sample or paired t-tests, and 'moderated_ttest2' for two-sample t-tests. For ease of use, these functions closely mirror the input and output structure of MATLAB's ttest and ttest2 functions and can be used interchangeably. The implementation is inspired from R's limma package and applies the techniques outlined in the Smyth (2004) paper.
x = grades(:, 1);
y = grades(:, 2);
[h,p,ci,stats] = moderated_ttest2(x, y)
h = 0
p = 0.9867
ci = 2x1
stats = struct with fields:
When performing a single test, moderated t-test is equivalent to the standard t-test.
Perform tests for each row:
X = grades(:, 1:2);
Y = grades(:, 3:4);
[h,p,ci,stats] = moderated_ttest2(X, Y, 'Dim', 2);
T = struct2table(struct('Passed', h, 'PValue', p, 'CI', ci, ...
'TStat', stats.tstat, 'DF', stats.df, 'SD', stats.sd));
Passed PValue CI TStat DF
______ _________ __________________ ________ ___
false 1 -8.5232 8.5232 0 360
false 0.90822 -9.0232 8.0232 -0.11537 360
false 0.17917 -2.6899 14.357 1.3459 360