spm1d Performance#
This page reports false positive rate (FPR) and related results for spm1d procedures that were derived from numerical simulations. These FPR results form the basis for the spm1d 0.5 defaults (e.g., cov_model='unstructured') and for various warnings that spm1d produces (see Errors and warnings).
The scripts that were used to generate the results below require hundreds of hours to run, so they are not provided as part of this documentation. For users interested in replicating these results, you may wish to use spm1d.util._val ℹ️, which offers a high-level interface for running FPR validation simulations:
ℹ️ spm1d.util._val
The spm1d.util._val subpackage is designed for internal simulation purposes and is not directly supported. Feel free to use this module but please do not request support for it. A more user-friendly validation package may be developed for a future spm1d release.
import numpy as np
import spm1d
fn = lambda y: spm1d.stats.ttest( y, 0 )
rng = lambda: np.random.randn( 8 )
validator = spm1d.util._val.val( fn, rng, niter=1000, progress_bar=True )
print( validator.results )
The code above yields results like this, where p is the FPR:
SimulationResults
n = 1000
x = (1000,) array
xc = 0.05000
p = 0.05700
tol = 0.02068
isvalid = True
All results below are FPRs for null data (a true effect of zero) at α = 0.05. The Monte Carlo standard error for α = 0.05 is about 0.007, 0.005 and 0.0022 for 1000, 2000 and 10,000 datasets, respectively. Related background is available here:
Baseline: IID Gaussian data#
The first question is whether the procedures hold at α = 0.05 under ideal circumstances of independent, identically distributed (IID) Gaussian data. Every spm1d.stats procedure was tested using null data that had these properties:
IID Gaussian data (N(0, 1) for 0D, and smooth Gaussian random fields with Q = 101 and FWHM = 20 for 1D)
equal variances and no factor or covariate effect
independent vector components (I = 3) for multivariate procedures
balanced designs with 20 observations per group or cell (20 subjects per group in repeated-measures designs). J therefore ranges from 20 (
ttest) to 240 (anova3onerm)
Inference was conducted with 10,000 datasets per procedure. Figures depict FPRs for every procedure with one dot per effect for multi-effect designs. The gray band is the 95% Monte Carlo interval for a true rate of 0.05 (0.046–0.054).
spm1d defaults#
Calling each spm1d procedure with its default arguments yielded the FPR results below.
Most FPR values are close to 0.05 and nearly all lie inside the 95% Monte Carlo interval.
The only procedure below the interval in both 0D and 1D is anova1rm, demonstrating conservatism due to its within-subject covariance estimates.
Imposing an IID assumption#
The same datasets were re-analyzed with cov_model='iid' passed to every procedure that accepts the cov_model keyword argument. Other procedures (ttest, ttest_paired, regress, cca, hotellings and hotellings_paired) are excluded below.
Generally tighter convergence to the expected FPR 0.05 is observed.
Heteroscedasticity and nonsphericity#
The figure below shows FPRs for random data that violate the assumption of equal variances (heteroscedasticity) or the assumption of sphericity (nonsphericity). Red dots are results for cov_model='iid', which assumes equal variances and sphericity. Cyan dots are results for cov_model='unstructured', which corrects for unequal variances and nonsphericity. The numbers after each procedure name are the group sizes, or the number of conditions × the number of subjects for anova1rm.
When its assumptions are violated cov_model='iid' can yield FPRs far greater than 0.05, especially for 1D data and for unequal group sizes. Corrections through cov_model='unstructured' yield FPRs much closer to 0.05. In spm1d 0.5 the multi-factor repeated-measures procedures (e.g., anova3onerm) accept only cov_model='iid' (see Multi-factor repeated-measures designs).