0todd0000 / spm1d

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

Effect size #76

Closed gabrielmoisan closed 6 years ago

gabrielmoisan commented 6 years ago

Hi, Thank you for your previous answers. They were very helpful and the manuscript is almost ready for submission. But before, we would like to report Cohen's D of Hedges' g effect sizes. We performed one way ANOVA with SPM. Do you have any open-source codes for Python to:

  1. Export effect sizes in text files or Excel for each percentage of the task? or
  2. Export the data in a graph such as in this example (https://github.com/0todd0000/spm1d/issues/54). Thank you so much for your time. It really helps a lot! Gabriel Moisan Université du Québec à Trois-Rivières, Canada
0todd0000 commented 6 years ago

Hi Gabriel,

Cohen's d can be calculated simply as the difference between means, divided by the standard deviation like this:

import numpy as np

Q  = 101 #number of continuum nodes
JA = 8   #sample size, Group A
JB = 8   #sample size, Group B
yA = np.random.randn(JA, Q)  #random sample, GroupA
yB = np.random.randn(JB, Q)  #random sample, GroupB

mA = yA.mean(axis=0) #mean, Group A
mB = yB.mean(axis=0) #mean, Group B
sA = yA.std(axis=0, ddof=1)  #st.dev., Group A
sB = yB.std(axis=0, ddof=1)  #st.dev., Group B

s  = np.sqrt(   ( (JA-1)*sA**2 + (JB-1)*sB**2 ) / (JA+JB)   )  #pooled st.dev.

d  = ( mA - mB ) / s #Cohen's d

To export results from Python in text format see np.savetxt

The figure can be reproduced using matplotlib.pyplot.subplot and standard spm1d plotting commands

Todd

gabrielmoisan commented 6 years ago

Todd, Thank you for your time. I really appreciate it! Gabriel

romainmartinez commented 5 years ago

Hello Todd, I think it would be useful to report Cohen's effect size by default in the output of the spm1d inference functions.

0todd0000 commented 5 years ago

Thank you for your suggestion. This could indeed be done, but I worry that it could be misleading. One-dimensional randomness amplifies values like Pearson's coefficient, ICC and Cohen's coefficients, so the typical interpretations of these values (e.g. r=0.9 represents relatively strong positive correlation) do not hold for 1D data.