Errors and warnings#
This page lists and briefly describes spm1d errors and warnings.
Errors#
SPM1DErrorThis is the base error class. It is raised directly for malformed input and for inconsistent input arguments. For example
spm1d.stats.anova1(y, A)whereyandAhave different lengths. Other relevant input errors include contrast errors, keyword argument value errors, etc. The error message includes the problematic argument and the accepted form.SPM1DZeroVarianceErrorThis error is raised if one or more nodes — inside the region of interest (ROI) being tested — have identical values for all observations (i.e., zero variance at one or more nodes). This error is raised only at the inference stage (not when the statistic is computed) so that the user can deliberately ignore zero-variance nodes through roi (e.g.,
t.inference(0.05, roi=a)).SPM1DInfiniteSmoothnessErrorThis error is raised if 1D data are constant across the domain (i.e., flat horizontal lines). In this case smoothness is infinite and the data are actually 0D (i.e., a 0D test conducted at each domain point would yield identical results). spm1d’s 1D probabilities converge to 0D probabilities as smoothness increases, but when smoothness is actually infinite then it cannot be numerically estimated and a 1D test becomes meaningless. Convert these data to 0D (e.g.,
y = y[:, 0]) and re-run the analysis to obtain 0D results.SPM1DSingleObservationErrorThis error is raised when just a single observation is submitted to an
spm1d.statsprocedure. Univariate inputs to these procedures are(J,)arrays for 0D data or(J,Q)arrays for 1D data. Multivariate inputs are(J,I)arrays for 0D data or(J,Q,I)arrays for 1D data. HereJis the number of observations,Qis the number of domain points andIis the number of vector components. In all casesJmust be larger than 1. WhenJis 1 there is no variance and no statistical analysis can be conducted.SPM1DTypeErrorThis error is raised when an argument has an incorrect type. For example,
t.inference(0.05)is correct butt.inference('0.05')raises an error because the first argumentalphamust be numeric. This error is a subclass of bothSPM1DErrorand Python’s builtinTypeError.SPM1DKeywordErrorThis error is raised if a user attempts to use a keyword that a procedure does not accept. For example:
spm1d.stats.ttest(y, foo=1)raises an error becausefoois not an accepted keyword argument. Note that the keywords that spm1d’s inference method accepts depend onmethod. For examplet.inference(0.05, method='perm', nperm=5000)is fine butt.inference(0.05, method='rft', nperm=5000)raises an error because therftmethod does not accept thenpermoption. Similarlyspm1d.stats.manova1( y, A ).inference( 0.05 ).posthoc( correction='bonf' )raises an error because multivariate post hoc analyses do not accept thecorrectionkeyword argument.SPM1DPostHocErrorThis error is raised if post hoc analyses are attempted in an unsupported way. For example,
spm1d.stats.anova1( y, A ).inference( 0.05, method='perm' ).posthoc()raises an error because post hoc analyses follow RFT (1D) or parametric (0D) inference only. This error is also raised ifposthoc()is called on a result whose null hypothesis was not rejected (i.e., whenh0rejectisFalse) because post hoc analyses are permitted only after a significant main test.SPM1DNotImplementedErrorThis error is raised when a procedure or option is not provided in this version. For example,
spm1d.stats.glm( y, X, c ).inference( 0.05, method='perm' )raises an error because permutation inference is not implemented forglm. Where an alternative route exists the message includes it. This error is a subclass of bothSPM1DErrorand Python’s builtinNotImplementedError.SPM1DAttributeErrorThis error is raised when an attribute or method name does not exist on an spm1d object or module. For example,
spm1d.stats.ttest( y ).inferance( 0.05 )raises an error that suggests the closest existing name (Did you mean "inference"?). This error is a subclass of bothSPM1DErrorand Python’s builtinAttributeError.hasattrandgetattrwith a default therefore keep working.SPM1DKeyErrorThis error is raised when a label is not one of the labels an spm1d list holds. For example,
spm1d.stats.anova2( y, A, B )['C']raises an error because the design has no effectC. The message includes the labels that the list holds. This error is a subclass of bothSPM1DErrorand Python’s builtinKeyError.SPM1DFileErrorThis error is raised by
spm1d.io.loadwhen a file does not hold what an spm1d result file holds. Typical causes are a damaged or edited file and a file written by a different version.SPM1DInternalErrorThis error is raised when one of spm1d’s internal consistency checks fails. It indicates a bug in spm1d rather than a problem with the input and should be reported together with the call that raised it. This error is a subclass of both
SPM1DErrorand Python’s builtinRuntimeError.SPM1DRngErrorThis error is raised if an invalid argument is provided to an
spm1d.rngdata generator. Invalid arguments include factors with zero levels and correlation values outside their admissible range.
Warnings#
SPM1DDeprecationWarningThis warning is raised for a v0.4 name or argument that v0.5 still accepts but a later version will remove. For example, the v0.4 keyword arguments
equal_varandtwo_tailedhave becomecov_modelanddirnin v0.5. This warning is shown once for each command that triggers it. See Migrating from 0.4 to 0.5.SPM1DUserWarningThis is the base class of warnings that are not deprecation-related. This class of warnings is raised for cases that are not errors but for which better practice exists. For example, running a one-way ANOVA with only two levels is equivalent to a t test. A warning therefore points the user to the standard t test route. A user warning is also raised when a user attempts to access point-level p-values for
p_pointwhen the inference method ismethod='rft'. These p-values are accurate only when p is small (<0.2; see Reporting p-values).SPM1DDimensionWarningThis warning is raised when a dependent variable input appears to be a single, smooth continuum rather than a sample of independently measured scalars. A sorted sample of scalars can look like a rising continuum. That is why this is a warning and not an error. If the data really are 1D, they should be reshaped to
(J, Q)before submitting to an spm1d procedure.SPM1DUncorrWarningThis warning is raised if
method='uncorr'is selected for 1D inference. Uncorrected probability calculations are not valid for inferences regarding 1D data. These uncorrected probability values are provided as a baseline for comparison with the corrected methods. Their results must not be reported as the outcome of a domain-level test. Reporting uncorrected probabilities represents a serious misuse of spm1d. Unlike the other warnings it is raised on every call. Using uncorrected results without a warning therefore requires a deliberate decision to ignore this warning:warnings.filterwarnings( 'ignore', category=SPM1DUncorrWarning ).SPM1DNonSphericityWarningThis warning is raised if a repeated-measures covariance correction was applied with five or fewer subjects and an estimated epsilon above its lower bound. The corrected degrees of freedom come from the estimated covariance. With so few subjects the estimate is poor. This situation has known limitations that are described in Non-sphericity. Pass
cov_model='iid'to assume sphericity instead or interpret the result in the light of the documented limitations.SPM1DDeveloperWarningThis warning is raised only by the v0.4 comparison tools of the test suite. The package’s own tests use those tools to check results against spm1d 0.4. No
spm1d.statscall raises it.