0todd0000 / spm1d

One-Dimensional Statistical Parametric Mapping in Python
GNU General Public License v3.0
61 stars 21 forks source link

Which normality test is used? #235

Closed McBanana33 closed 1 year ago

McBanana33 commented 1 year ago

Hello Mr. Pataky,

which normality test do you use in this code (it's your example from file: ex1d_anova1.m)?

" clear; clc

%(0) Load data: dataset = spm1d.data.uv1d.anova1.SpeedGRFcategorical(); % dataset = spm1d.data.uv1d.anova1.Weather(); [y,A] = deal(dataset.Y, dataset.A);

%(1) Conduct normality test: alpha = 0.05; spm = spm1d.stats.normality.anova1(y, A); spmi = spm.inference(0.05); disp(spmi)

%(2) Plot: close all figure('position', [0 0 1200 300]) subplot(131); plot(y', 'k'); hold on; title('Data') subplot(132); plot(spm.residuals', 'k'); title('Residuals') subplot(133); spmi.plot(); title('Normality test')"

On your website I've seen that you support the D’Agostino-Pearson K2 test as well as the Shapiro-Wilk. Which one is it in this example? Thank you!

0todd0000 commented 1 year ago

It appears from your code that you are using the MATLAB version of spm1d, in which case only the K2 test is supported. This is shown in the source code, for example this file for the anova1 normality test.

In the Python version of spm1d, by default the K2 test is used as shown in the normality sub-package's __init__.py file. In Python you can alternatively run a SW test by adding sw between normality and the test name like this:

spm = spm1d.stats.normality.sw.anova1(y, A)
McBanana33 commented 1 year ago

Great, thanks for the response!