# Moderated t-test

Version 1.0.0 (9.15 KB) by
Moderated t-test based on empirical Bayes techniques to improve statistical power
Updated 16 Aug 2023

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.
Example Use:
% Perform the test
[h,p,ci,stats] = moderated_ttest2(x, y)
h = 0
p = 0.9867
ci = 2x1
-1.9438
1.9771
stats = struct with fields:
tstat: 0.0167
df: 238
sd: 7.7084
mean: 0.0167
sd_prior: 7.7084
df_prior: 0
When performing a single test, moderated t-test is equivalent to the standard t-test.
Perform tests for each row:
% Compare results of first exam with 3rd and second with 4th
[h,p,ci,stats] = moderated_ttest2(X, Y, 'Dim', 2);
% Convert to table and display the first 3 results
T = struct2table(struct('Passed', h, 'PValue', p, 'CI', ci, ...
'TStat', stats.tstat, 'DF', stats.df, 'SD', stats.sd));
disp(T(1:3, :));
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

### Cite As

Serhan Yilmaz (2024). Moderated t-test (https://www.mathworks.com/matlabcentral/fileexchange/133922-moderated-t-test), MATLAB Central File Exchange. Retrieved .

##### MATLAB Release Compatibility
Created with R2022b
Compatible with any release
##### Platform Compatibility
Windows macOS Linux