Probabilities#
Inference methods#
- rft(STAT, z, df, fwhm, resels, alpha=0.05, circular=False, withBonf=True, dirn=0, zc=None)[source]#
Random field theory (RFT) inference on a 1D test statistic field.
- Parameters:
STAT — test statistic:
'T','F','T2'or'X2'z — (Q,) test statistic field (optionally masked)
df — degrees of freedom as a two-element tuple
fwhm — residual smoothness in nodes (for cluster extents only)
resels — search region resel counts from
spm1d.geom.resel_counts()alpha — Type I error rate (default 0.05)
circular — True for circular domains
withBonf — if True (default), cap RFT probabilities at Bonferroni values
dirn — inference direction: 0 (two-tailed), +1 or -1 (one-tailed)
zc — critical height replacing the
alpha-derived value
- Returns:
InferenceResults1D object
- Example:
RFT inference on the t field of a one-sample t test using the smoothness and resel counts the test estimated.
>>> import spm1d >>> import jikudata as jd >>> y = jd.SimulatedPataky2015b().y # (10,101) array >>> t = spm1d.stats.ttest( y, 0 ) >>> results = spm1d.prob.rft( 'T', t.z, t.df, t.fwhm, t.resels, alpha=0.05, dirn=1 ) >>> print( round( results.zc, 3 ), results.h0reject, round( results.p_set, 3 ) ) 3.218 True 0.045
The example datasets require the jiku-data package:
pip install "spm1d[data]".
- fdr(STAT, z, df, alpha=0.05, dirn=0, circular=False, approach='bh')[source]#
False discovery rate (FDR) inference on a 1D test statistic field.
Corrected point-level p values follow statsmodels.stats.multitest.fdrcorrection. Modified from fdr1d (0todd0000/fdr1d).
- Parameters:
STAT — test statistic:
'T','F','T2'or'X2'z — (Q,) test statistic field (optionally masked)
df — degrees of freedom as a two-element tuple
alpha — false discovery rate (default 0.05)
dirn — inference direction: 0 (two-tailed), +1 or -1 (one-tailed)
circular — True for circular domains
approach —
'bh'(Benjamini-Hochberg, default) or'by'(Benjamini-Yekutieli)
- Returns:
InferenceResults1D object
- Example:
FDR inference on the t field of a one-sample t test. No node passes the criterion. The critical height is therefore infinite.
>>> import spm1d >>> import jikudata as jd >>> y = jd.SimulatedPataky2015b().y # (10,101) array >>> t = spm1d.stats.ttest( y, 0 ) >>> results = spm1d.prob.fdr( 'T', t.z, t.df, alpha=0.05, dirn=1 ) >>> print( results.zc, results.h0reject, round( results.p_point.min(), 3 ) ) inf False 0.073
The example datasets require the jiku-data package:
pip install "spm1d[data]".
- bonf(STAT, z, df, alpha=0.05, dirn=0, circular=False)[source]#
Bonferroni inference on a 1D test statistic field.
- Parameters:
STAT — test statistic:
'T','F','T2'or'X2'z — (Q,) test statistic field (optionally masked)
df — degrees of freedom as a two-element tuple
alpha — Type I error rate (default 0.05)
dirn — inference direction: 0 (two-tailed), +1 or -1 (one-tailed)
circular — True for circular domains
- Returns:
InferenceResults1D object
- Example:
Bonferroni inference on the t field of a one-sample t test.
>>> import spm1d >>> import jikudata as jd >>> y = jd.SimulatedPataky2015b().y # (10,101) array >>> t = spm1d.stats.ttest( y, 0 ) >>> results = spm1d.prob.bonf( 'T', t.z, t.df, alpha=0.05, dirn=1 ) >>> print( round( results.zc, 3 ), results.h0reject ) 4.788 False
The example datasets require the jiku-data package:
pip install "spm1d[data]".
- uncorr(STAT, z, df, alpha=0.05, dirn=0, circular=False)[source]#
Uncorrected inference on a 1D test statistic field.
No correction for multiple comparisons (for comparison with corrected methods only).
- Parameters:
STAT — test statistic:
'T','F','T2'or'X2'z — (Q,) test statistic field (optionally masked)
df — degrees of freedom as a two-element tuple
alpha — Type I error rate (default 0.05)
dirn — inference direction: 0 (two-tailed), +1 or -1 (one-tailed)
circular — True for circular domains
- Returns:
InferenceResults1D object
- Example:
Uncorrected inference on the t field of a one-sample t test.
>>> import spm1d >>> import jikudata as jd >>> y = jd.SimulatedPataky2015b().y # (10,101) array >>> t = spm1d.stats.ttest( y, 0 ) >>> results = spm1d.prob.uncorr( 'T', t.z, t.df, alpha=0.05, dirn=1 ) >>> print( round( results.zc, 3 ), results.h0reject ) 1.833 True
The example datasets require the jiku-data package:
pip install "spm1d[data]".
- param(STAT, z, df, alpha=0.05, dirn=0, zc=None)[source]#
Parametric inference on a 0D test statistic.
- Parameters:
STAT — test statistic:
'T','F','T2'or'X2'z — test statistic value
df — degrees of freedom as a two-element tuple
alpha — Type I error rate (default 0.05)
dirn — inference direction: 0 (two-tailed), +1 or -1 (one-tailed)
zc — critical value replacing the
alpha-derived value
- Returns:
InferenceResults0D object
- Example:
Parametric inference on the t statistic of a paired t test on the “sleep” dataset from R.
>>> import spm1d >>> import jikudata as jd >>> dataset = jd.R_SleepPairedTest() >>> y, A = dataset.y, dataset.x # (20,) arrays of responses and condition labels >>> t = spm1d.stats.ttest_paired( y[ A == 0 ], y[ A == 1 ] ) >>> results = spm1d.prob.param( 'T', t.z, t.df, alpha=0.05, dirn=0 ) >>> print( round( results.zc, 3 ), round( results.p, 3 ) ) 2.262 0.003
The example datasets require the jiku-data package:
pip install "spm1d[data]".
Corrections#
- p_corrected_bonf(p, n)[source]#
Bonferroni-corrected p value min(1, n * p).
- Parameters:
p — probability value computed from one of multiple tests
n — number of tests
- Returns:
Bonferroni-corrected p value
- Example:
>>> p = spm1d.prob.p_corrected_bonf(0.03, 8) # yields p = 0.24
- p_critical_bonf(alpha, n)[source]#
Bonferroni-corrected critical Type I error rate, alpha / n.
- Parameters:
alpha — original Type I error rate (usually 0.05)
n — number of tests
- Returns:
Bonferroni-corrected critical p value
- Example:
>>> p = spm1d.prob.p_critical_bonf(0.05, 20) # yields p = 0.0025
- p_corrected_dirn(p, dirn)[source]#
Corrected p values based on dirn (t-like tests only).
- Parameters:
p — probability value computed from one of multiple tests
dirn — test direction: 0 (two-tailed), 1 or -1 (one-tailed)
- Returns:
Corrected p value(s)
- Example:
>>> p = spm1d.prob.p_corrected_dirn(0.03, 0) # yields p = 0.06