Class TestDataAudit

java.lang.Object
edu.cmu.tetrad.test.TestDataAudit

public class TestDataAudit extends Object
Tests the pre-search data audit. Each test plants one pathology in simulated data and asserts that the corresponding finding fires; the clean-data test asserts that no warnings fire on well-behaved Gaussian data. All simulations use fixed seeds.
Version:
$Id: $Id
Author:
josephramsey
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new test.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    A column with no non-missing values at all should fire CONSTANT_COLUMN with numNonMissing = 0.
    void
    Clean Gaussian data should produce zero WARNING findings.
    void
    A near-copy pair should fire HIGH_CORRELATION and NEAR_DETERMINISM_LINEAR but not EXACT_LINEAR_DEPENDENCE.
    void
    An exactly constant continuous column, a continuous column constant on its two non-missing entries, and a single-category discrete column should each fire CONSTANT_COLUMN (and not NEAR_CONSTANT); a varying Gaussian column should fire neither.
    void
    A constant column must not mask downstream findings among the remaining variables: with a constant X1 present, a near-linear-dependence among X2, X3, X4 should still fire NEAR_DETERMINISM_LINEAR, the continuous-name accessors should exclude X1, and the correlation matrix should cover only the non-constant variables.
    void
    An exact linear copy should fire EXACT_LINEAR_DEPENDENCE.
    void
    The JSON rendering should contain the expected top-level keys and have balanced braces.
    void
    n = 30 with p = 10 should fire LOW_SAMPLE_RATIO.
    void
    A 13-level discrete variable should fire DISCRETE_MANY_LEVELS, and a continuous variable taking three values should fire CONTINUOUS_FEW_VALUES.
    void
    MCAR-injected missingness should produce exactly one MISSING_DATA finding, a non-null delegated MissingDataAudit, and a Little's MCAR p-value among the finding's values.
    void
    A negligible-variance (but varying) continuous column and a 99.5-percent-modal (but two-category) discrete column should each fire NEAR_CONSTANT, and neither should fire CONSTANT_COLUMN.
    void
    A class variable with well-separated class means nearly determining a continuous variable should fire NEAR_DETERMINISM_DISCRETE_CONTINUOUS.
    void
    An AR(1) series with substantial lag-1 autocorrelation should fire SERIAL_DEPENDENCE with the AR(1) effective-sample-size clause in the message and without the periodicSuspect flag.
    void
    A periodic series with near-zero lag-1 autocorrelation but a dominant autocorrelation at a deeper lag (here a period-4 cycle, whose lag-2 autocorrelation is near -1 while lag-1 is near 0) should fire SERIAL_DEPENDENCE with the periodic-dependence clause in place of the AR(1) effective-sample-size clause, and should carry periodicSuspect = 1 in its values.
    void
    A lognormal column should fire NON_GAUSSIAN at severity INFO; a Gaussian column should not fire.
    void
    A discrete variable with a 3-case category should fire SMALL_MARGINAL_CELL.
    void
    Two 5-level discrete variables at n = 100 should fire SMALL_PAIRWISE_CELLS.

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TestDataAudit

      public TestDataAudit()
      Constructs a new test.
  • Method Details

    • testCleanGaussianNoWarnings

      public void testCleanGaussianNoWarnings()
      Clean Gaussian data should produce zero WARNING findings.
    • testCollinearPair

      public void testCollinearPair()
      A near-copy pair should fire HIGH_CORRELATION and NEAR_DETERMINISM_LINEAR but not EXACT_LINEAR_DEPENDENCE.
    • testExactLinearDependence

      public void testExactLinearDependence()
      An exact linear copy should fire EXACT_LINEAR_DEPENDENCE.
    • testSkewedColumn

      public void testSkewedColumn()
      A lognormal column should fire NON_GAUSSIAN at severity INFO; a Gaussian column should not fire.
    • testSmallMarginalCell

      public void testSmallMarginalCell()
      A discrete variable with a 3-case category should fire SMALL_MARGINAL_CELL.
    • testSmallPairwiseCells

      public void testSmallPairwiseCells()
      Two 5-level discrete variables at n = 100 should fire SMALL_PAIRWISE_CELLS.
    • testNearDeterminismDiscreteContinuous

      public void testNearDeterminismDiscreteContinuous()
      A class variable with well-separated class means nearly determining a continuous variable should fire NEAR_DETERMINISM_DISCRETE_CONTINUOUS.
    • testNearConstant

      public void testNearConstant()
      A negligible-variance (but varying) continuous column and a 99.5-percent-modal (but two-category) discrete column should each fire NEAR_CONSTANT, and neither should fire CONSTANT_COLUMN.
    • testConstantColumn

      public void testConstantColumn()
      An exactly constant continuous column, a continuous column constant on its two non-missing entries, and a single-category discrete column should each fire CONSTANT_COLUMN (and not NEAR_CONSTANT); a varying Gaussian column should fire neither.
    • testAllMissingColumn

      public void testAllMissingColumn()
      A column with no non-missing values at all should fire CONSTANT_COLUMN with numNonMissing = 0.
    • testConstantColumnDoesNotMaskDownstreamChecks

      public void testConstantColumnDoesNotMaskDownstreamChecks()
      A constant column must not mask downstream findings among the remaining variables: with a constant X1 present, a near-linear-dependence among X2, X3, X4 should still fire NEAR_DETERMINISM_LINEAR, the continuous-name accessors should exclude X1, and the correlation matrix should cover only the non-constant variables. (Before constant columns were excluded, X1's undefined correlations aborted the whole correlation battery.)
    • testManyLevelsAndFewValues

      public void testManyLevelsAndFewValues()
      A 13-level discrete variable should fire DISCRETE_MANY_LEVELS, and a continuous variable taking three values should fire CONTINUOUS_FEW_VALUES.
    • testLowSampleRatio

      public void testLowSampleRatio()
      n = 30 with p = 10 should fire LOW_SAMPLE_RATIO.
    • testMissingData

      public void testMissingData()
      MCAR-injected missingness should produce exactly one MISSING_DATA finding, a non-null delegated MissingDataAudit, and a Little's MCAR p-value among the finding's values.
    • testJsonWellFormed

      public void testJsonWellFormed()
      The JSON rendering should contain the expected top-level keys and have balanced braces.
    • testSerialDependenceAr1Message

      public void testSerialDependenceAr1Message()
      An AR(1) series with substantial lag-1 autocorrelation should fire SERIAL_DEPENDENCE with the AR(1) effective-sample-size clause in the message and without the periodicSuspect flag.
    • testSerialDependencePeriodicSuspectMessage

      public void testSerialDependencePeriodicSuspectMessage()
      A periodic series with near-zero lag-1 autocorrelation but a dominant autocorrelation at a deeper lag (here a period-4 cycle, whose lag-2 autocorrelation is near -1 while lag-1 is near 0) should fire SERIAL_DEPENDENCE with the periodic-dependence clause in place of the AR(1) effective-sample-size clause, and should carry periodicSuspect = 1 in its values. This is the thinned task-fMRI case: AR decay removed by thinning, but a stimulus-locked cycle remaining at the task period.