Class KciSmokeTest

java.lang.Object
edu.cmu.tetrad.search.KciSmokeTest

public class KciSmokeTest extends Object
The KciSmokeTest class contains unit tests to evaluate the performance and correctness of the Kci class, specifically focusing on conditional independence tests.

It provides multiple test methods to verify the behavior of the Kci algorithm under different scenarios, such as independent and dependent data relationships, both with and without approximation techniques.

The tests include:

  • gammaApprox_independent_vs_dependent: Verifies the conditional independence test using an approximate gamma distribution method for both independent and dependent cases.
  • nonApprox_independent_vs_dependent: Tests the deterministic behavior and accuracy of the non-approximate (permutation-based) conditional independence test with independent and dependent data.
  • permutation_independent_vs_dependent: Validates the conditional independence test using the permutation-based method under different data relationships.

Utility methods:

  • makeDataVxN: Generates simulated data for tests, with rows representing variables (X, Y, Z) and columns representing samples. The method allows controlling dependency with noise levels.
  • makeKci: Initializes and configures the Kci instance with given data and parameters for testing independence.
  • Constructor Details

    • KciSmokeTest

      public KciSmokeTest()
      Default constructor for the KciSmokeTest class. This constructor initializes an instance of the KciSmokeTest class to perform unit tests on the Kci framework.
  • Method Details

    • gammaApprox_independent_vs_dependent

      public void gammaApprox_independent_vs_dependent()
      Tests the accuracy and behavior of the gamma approximation method for conditional independence testing using the Kci framework. This method evaluates two scenarios: independent and dependent relationships between variables.

      The test is conducted with the following configurations:

      • Independent Test: Variable Y is evaluated as being independent of X given Z.
        • The method ensures that the p-value is within valid bounds and fails to reject the null hypothesis of independence when p > alpha.
      • Dependent Test: Variable Y is evaluated as linearly dependent on X with noise (Y = X + 0.05 * e, strong dependence).
        • The method ensures that the p-value indicates strong significance (p < alpha) for the dependent case.

      Assertions:

      • The p-value for the independent case lies within the acceptable [0, 1] range.
      • The p-value for the independent case does not indicate rejection of the null hypothesis (p > alpha).
      • The p-value for the dependent case is significant (p < alpha), confirming the method's ability to detect dependence.
    • nonApprox_independent_vs_dependent

      public void nonApprox_independent_vs_dependent()
      Tests the accuracy and behavior of the non-approximate conditional independence testing method using the Kci framework. This method evaluates two scenarios: independent and dependent relationships between variables.

      The test utilizes a fixed random seed for reproducibility and performs the following configurations:

      • Independent Test: Evaluates whether variable Y is independent of X given Z.
        • Ensures the p-value lies within the valid range [0,1].
        • Confirms the p-value does not indicate a rejection of independence (p > alpha).
      • Dependent Test: Evaluates a scenario where variable Y is linearly dependent on X (Y = X + 0.05 * e, with strong dependence).
        • Confirms the p-value indicates strong significance (p < alpha), demonstrating the method's sensitivity to dependence.

      Assertions:

      • The p-value for the independent case lies within the range [0,1].
      • The p-value for the independent case does not reject the null hypothesis (p > alpha).
      • The p-value for the dependent case is small (e.g., p < alpha), indicating significance.
    • permutation_independent_vs_dependent

      public void permutation_independent_vs_dependent()
      Tests the behavior and accuracy of the permutation-based conditional independence testing method in the Kci framework. This method evaluates two scenarios: independent and dependent relationships between variables.

      The test utilizes the following configuration:

      • A fixed random seed for reproducibility.
      • The permutation testing method to assess variable relationships.

      The test performs the following scenarios:

      1. Independent Test:
        • Variable Y is evaluated as being independent of X given Z.
        • Ensures that the p-value lies within the valid range [0, 1].
        • Confirms that the p-value fails to reject the null hypothesis of independence when p > alpha (indicating no significant dependence).
      2. Dependent Test:
        • Variable Y is evaluated as linearly dependent on X with noise (Y = X + 0.05 * e, strong dependence).
        • Ensures that the p-value indicates strong significance (p < alpha), reflecting the method's ability to detect dependence robustly.

      Assertions:

      • For the independent case, the p-value lies within [0, 1] and satisfies p > alpha.
      • For the dependent case, the p-value is highly significant, confirming p < alpha.