0todd0000 / spm1d

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

One sample t-test #53

Closed zof1985 closed 8 years ago

zof1985 commented 8 years ago

Hi Todd,

I would like to compare some time-series with a set of thresholds that are subject-dependent but not time-dependent. Since I would like to evaluate which region of the time series are above the thresholds, I wonder if the use of 1D paired t-tests to compare the time-series with the time-series created from the thresholds values (that have variance equal to 0 over time) would be a correct approach.

many thanks, Luca.

0todd0000 commented 8 years ago

Hi Luca,

If you are interested mainly in separate subject effects then maybe a one-sample t test would be sufficient. For example, a set of eight 1D observations in an (8 x 101) array y can be compared to a scalar datum as follows:

>>>  mu = 1.5   #or any other value, in the same units as y
>>>  spm = spm1d.stats.ttest(y, mu)
>>>  spmi = spm.inference(0.05)

Or you can compare the observations y to an arbitrary 1D datum mu as follows:

>>>  import numpy as np
>>>  mu = np.random.randn(101)   #or any field containing 101 values
>>>  spm = spm1d.stats.ttest(y, mu)
>>>  spmi = spm.inference(0.05)

If you're also interested in cross-subject results then it might also be possible to subtract the datum from each subject separately like this:

>>>  mu0 = 1.5
>>>  mu1 = 1.8
>>>  mu2 = 1.3
...

>>>  d0 = y0 - mu0
>>>  d1 = y1 - mu1
>>>  d2 = y2 - mu2
...

and then run a test using the d variables.

Todd

zof1985 commented 8 years ago

Hi Todd,

The last option is what I was looking for.

Many thanks, Luca.