When to use nonparametric inference#
General recipe: Use random field theory (RFT) inference as the default and use permutation inference to check the RFT results. If the two methods yield qualitatively similar results, it may generally be concluded that RFT’s normality assumption did not affect the conclusions. If they differ qualitatively, first check the data for potential sources of non-normality (e.g., outliers) and fix any data problems that exist. Permutation inference is not automatically the safer choice because several numerical problems may compromise its accuracy, for example: small samples and unequal group variances. For these situations parametric (RFT) inference usually performs better (see Permutation inference).
Justification: RFT assumes that the data are normally distributed but permutation inference does not. When the data are strongly non-normal the two methods can yield different critical thresholds. However, this difference often affects only borderline significant effects. When the true effect is large, both methods are expected to detect it regardless of whether the data are normally distributed. See Continuum-level inference for more details.
The example below uses smooth, random 1D data (generated using rft1d) for two groups of twelve observations with a true effect in the middle of the domain.
Refer to Normality tests for more details.
import numpy as np
from matplotlib import pyplot as plt
import rft1d
import spm1d
plt.rc( 'font', size=18 ) # minimum font size for all figure text
np.random.seed( 3 ) # reproducible random data
Q = 101 # number of domain points
q = np.arange( Q )
effect = 1.6 * np.exp( -0.5 * ((q - 55) / 12)**2 ) # true effect: a smooth bump in the middle of the domain
y0 = rft1d.randn1d( 12, Q, 20 ) # group 0: 12 smooth Gaussian observations (FWHM = 20)
y1 = rft1d.randn1d( 12, Q, 20 ) + effect # group 1: 12 smooth Gaussian observations plus the effect
The function below conducts a two-sample t test and plots the test statistic together with the RFT and permutation thresholds.
def plot_thresholds( y0, y1 ):
t = spm1d.stats.ttest2( y1, y0 )
ti = t.inference( 0.05 ) # RFT inference
np.random.seed( 0 ) # reproducible permutations
tp = t.inference( 0.05, method='perm', nperm=5000 ) # permutation inference
plt.figure( figsize=(6.4, 4.5), tight_layout=True )
ax = plt.gca()
ax.plot( t.z, color='k', lw=3 )
ax.axhline( 0, color='0.6', ls=':' )
for zc, color, label in [(ti.zc, '#08343f', 'RFT'), (tp.zc, '#2eb0ce', 'Permutation')]:
ax.axhline( zc, color=color, lw=2.5, ls='--', label=label )
ax.axhline( -zc, color=color, lw=2.5, ls='--' )
ax.legend( fontsize=20, ncol=2, loc='lower center', bbox_to_anchor=(0.5, 1) ) # critical thresholds; above the axes
ax.set_ylabel( 't-value', fontsize=20 )
The figure below depicts the results for the original (Gaussian) data.


The figure below depicts the results for the exponentiated (skewed) data.


The RFT and permutation thresholds are similar for Gaussian data but differ for the skewed data. In this case it would be best to report both results and to separately describe the distribution for completeness.
This example demonstrates that the choice of method can affect the results but does not by itself show which threshold is correct. The important point is that both methods are generally valid, but we can never know which is correct because we never know the true effect for experimental data.
See also: Continuum-level inference.