Errors and warnings

Contents

Errors and warnings#

This page lists and briefly describes spm1d errors and warnings.


Errors#

SPM1DError

This is the base error class. It is raised directly for malformed input and for inconsistent input arguments. For example spm1d.stats.anova1(y, A) where y and A have 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.

SPM1DZeroVarianceError

This 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)).

SPM1DInfiniteSmoothnessError

This 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.

SPM1DSingleObservationError

This error is raised when just a single observation is submitted to an spm1d.stats procedure. 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. Here J is the number of observations, Q is the number of domain points and I is the number of vector components. In all cases J must be larger than 1. When J is 1 there is no variance and no statistical analysis can be conducted.

SPM1DTypeError

This error is raised when an argument has an incorrect type. For example, t.inference(0.05) is correct but t.inference('0.05') raises an error because the first argument alpha must be numeric. This error is a subclass of both SPM1DError and Python’s builtin TypeError.

SPM1DKeywordError

This 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 because foo is not an accepted keyword argument. Note that the keywords that spm1d’s inference method accepts depend on method. For example t.inference(0.05, method='perm', nperm=5000) is fine but t.inference(0.05, method='rft', nperm=5000) raises an error because the rft method does not accept the nperm option. Similarly spm1d.stats.manova1( y, A ).inference( 0.05 ).posthoc( correction='bonf' ) raises an error because multivariate post hoc analyses do not accept the correction keyword argument.

SPM1DPostHocError

This 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 if posthoc() is called on a result whose null hypothesis was not rejected (i.e., when h0reject is False) because post hoc analyses are permitted only after a significant main test.

SPM1DNotImplementedError

This 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 for glm. Where an alternative route exists the message includes it. This error is a subclass of both SPM1DError and Python’s builtin NotImplementedError.

SPM1DAttributeError

This 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 both SPM1DError and Python’s builtin AttributeError. hasattr and getattr with a default therefore keep working.

SPM1DKeyError

This 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 effect C. The message includes the labels that the list holds. This error is a subclass of both SPM1DError and Python’s builtin KeyError.

SPM1DFileError

This error is raised by spm1d.io.load when 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.

SPM1DInternalError

This 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 SPM1DError and Python’s builtin RuntimeError.

SPM1DRngError

This error is raised if an invalid argument is provided to an spm1d.rng data generator. Invalid arguments include factors with zero levels and correlation values outside their admissible range.


Warnings#

SPM1DDeprecationWarning

This 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_var and two_tailed have become cov_model and dirn in v0.5. This warning is shown once for each command that triggers it. See Migrating from 0.4 to 0.5.

SPM1DUserWarning

This 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_point when the inference method is method='rft'. These p-values are accurate only when p is small (<0.2; see Reporting p-values).

SPM1DDimensionWarning

This 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.

SPM1DUncorrWarning

This 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 ).

SPM1DNonSphericityWarning

This 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.

SPM1DDeveloperWarning

This 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.stats call raises it.