0todd0000 / spm1d

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

z scores instead of t scores #114

Closed limbicode214 closed 4 years ago

limbicode214 commented 4 years ago

Hi Todd

We performing a multiple regression analysis using t = spm1d.stats.glm(Y, X, c)
ti = t.inference(0.05)

How can we display z, instead of t scores ? By simply replacing the "t" with "z" it still shows spm {t} on the y-axis and we are not sure if those are the z-scores within a significant cluster as they are very similar with a sample size > N = 30.

many thanks for your help, michael

0todd0000 commented 4 years ago

Hi! z scores have to be manually calculated. For single samples this is easy:

import numpy as np

y = np.random.randn(8, 101)  

z = (y - mu) / sigma # if population mean & SD are known
z = (y - y.mean(axis=0)) / y.std(axis=0, ddof=1) # if population mean & SD are unknown

In regression designs I believe that z scores can be calculated from correlation coefficients, so you'd first need to calculate the correlation coefficient of interest, then calculate the z score.

limbicode214 commented 4 years ago

Many thanks Todd. I simply calculated the correlation coefficient for each t-value (from spm.z) using the formula R2 = t2 / (t2 + DF)