Class TestNonlinearityTests

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

public class TestNonlinearityTests extends Object
Regression tests for NonlinearityTests, pinning two fixes verified by the calibration harness:
  • Internal centering: the tests fit without an intercept column, so before the fix any linear relationship with a nonzero intercept (the typical case for raw real data) was misspecified under the null and all of RESET, the conditional-moment test, and the additive-hinge test rejected "linearity" with probability near 1. The tests now center y and X internally, on copies.
  • Honored seeds: rffCosSin previously ignored its seed and drew random features from the global RandomUtil stream, so the training and test matrices in cvLinearVsNonlinear were embedded with different features; predictions were noise, the nonlinear model always lost the cross-validated comparison, and the test had zero power everywhere. Seeds are now honored with local generators throughout, which also makes the CV tests deterministic given their inputs.
Known limitation, deliberately not asserted here: heteroskedastic but linear-in-mean data inflates the type I error of the three F/LM tests above nominal (roughly 10-35 percent at alpha = 0.05 in the harness); see the class Javadoc of NonlinearityTests.
Author:
josephramsey
  • Constructor Details

    • TestNonlinearityTests

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

    • testLinearWithInterceptNotFlagged

      public void testLinearWithInterceptNotFlagged()
      A linear relationship with a large intercept, passed raw (uncentered), must not be flagged nonlinear. Before the centering fix, RESET, conditional-moment, and additive-hinge all rejected here with probability near 1. The alpha of 0.01 with a fixed seed keeps this test stable against the nominal false-rejection rate.
    • testQuadraticFlaggedByAllFour

      public void testQuadraticFlaggedByAllFour()
      A strong quadratic must be flagged by all four tests. The CV assertion is the regression test for the rffCosSin seed fix: before it, cvLinearVsNonlinear had zero power on this scenario.
    • testCvTestsDeterministic

      public void testCvTestsDeterministic()
      The CV tests must be deterministic given their inputs (local seeded generators), independent of the global RandomUtil stream's state. Perturbs the global stream between calls and requires identical statistics.
    • testAdditivityCheckFlagsPureInteraction

      public void testAdditivityCheckFlagsPureInteraction()
      cvAdditiveVsRff must have power on its one job: a pure interaction, which no additive model can represent. Before the redesign (nested models on a shared additive base, a single GCV-tuned ridge selected on the full model, and pooled per-observation signed-rank inference), the full RFF model had more features than training rows at near-interpolation regularization, lost the CV comparison even here, and the test rejected in only about 5-12 percent of replications; after it, rejection is essentially certain at this n and effect size.
    • testAdditivityCheckNotFooledBySmoothAdditive

      public void testAdditivityCheckNotFooledBySmoothAdditive()
      cvAdditiveVsRff must NOT flag additive-but-smooth truths. This pins the per-variable RFF enrichment of the additive design: with a hinge-only additive base, the joint RFF block absorbed the hinge basis's approximation bias on smooth additive functions and this scenario was falsely flagged non-additive about 45 percent of the time. The alpha of 0.01 with a fixed seed keeps this test stable against the nominal false-rejection rate.
    • testCallerArraysNotModified

      public void testCallerArraysNotModified()
      Internal centering must operate on copies: caller arrays are not modified.