Class IndTestGin

java.lang.Object
edu.cmu.tetrad.search.test.IndTestGin
All Implemented Interfaces:
IndependenceTest

public class IndTestGin extends Object implements IndependenceTest
GIN (Generalized Independent Noise) conditional independence test. Reduces CI X ⟂ Y | S to unconditional independence of regression residuals:
  • rX := X - E[X | S \ {X}]
  • rY := Y - E[Y | S \ {Y}]

Then tests rX ⟂ rY using an unconditional backend (dCor by default).

Assumes continuous data. For mixed data, provide a different Regressor (e.g., RF).

  • Constructor Details

    • IndTestGin

      public IndTestGin(DataSet data)
      Constructs an instance of IndTestGin with the specified dataset. Initializes default values for regressor and backend components.
      Parameters:
      data - the dataset to be used for independence testing
    • IndTestGin

      public IndTestGin(DataSet data, IndTestGin.Regressor regressor, IndTestGin.UncondIndTest backend)
      Constructs an instance of IndTestGin with the specified dataset, regressor, and backend components. This constructor allows customization of the regressor and backend used in the independence tests.
      Parameters:
      data - the dataset to be used for independence testing
      regressor - the regressor implementation to be used for regression analysis
      backend - the unconditional independence test to be used as the backend
  • Method Details

    • getDescription

      public String getDescription()
      Provides a string description of the current configuration of the independence test, including details about the regressor and backend used, and additional information related to permutations if applicable.
      Returns:
      a descriptive string summarizing the configuration of the independence test
    • setNumPermutations

      public void setNumPermutations(int n)
      Sets the number of permutations to be used for the independence test. If n is negative, it will be set to 0.
      Parameters:
      n - the number of permutations to set
    • setRegressor

      public void setRegressor(IndTestGin.Regressor r)
      Sets the regressor to be used for the independence test. If r is null, it will throw a NullPointerException.
      Parameters:
      r - the regressor to set
    • setBackend

      public void setBackend(IndTestGin.UncondIndTest b)
      Sets the backend to be used for the independence test. If b is null, it will throw a NullPointerException.
      Parameters:
      b - the backend to set
    • getData

      public DataSet getData()
      Returns the current regressor being used for the independence test.
      Specified by:
      getData in interface IndependenceTest
      Returns:
      the current regressor
    • isVerbose

      public boolean isVerbose()
      Returns the current backend being used for the independence test.
      Specified by:
      isVerbose in interface IndependenceTest
      Returns:
      the current backend
    • setVerbose

      public void setVerbose(boolean verbose)
      Sets the verbosity of the independence test.
      Specified by:
      setVerbose in interface IndependenceTest
      Parameters:
      verbose - True, if so.
    • getVariables

      public List<Node> getVariables()
      Returns the variables involved in the independence test.
      Specified by:
      getVariables in interface IndependenceTest
      Returns:
      the variables involved in the independence test
    • getAlpha

      public double getAlpha()
      Returns the significance level for the independence test.
      Specified by:
      getAlpha in interface IndependenceTest
      Returns:
      the significance level
    • setAlpha

      public void setAlpha(double alpha)
      Sets the significance level for the independence test.
      Specified by:
      setAlpha in interface IndependenceTest
      Parameters:
      alpha - the significance level to set
    • checkIndependence

      public IndependenceResult checkIndependence(Node x, Node y, Set<Node> cond)
      Checks the independence of two given nodes, conditioned on a set of other nodes. It computes residuals for the nodes and uses the backend independence test to determine the independence status along with the p-value.
      Specified by:
      checkIndependence in interface IndependenceTest
      Parameters:
      x - the first node for the independence test
      y - the second node for the independence test
      cond - the set of conditioning nodes
      Returns:
      the result of the independence test containing details such as whether the nodes are independent, the p-value, and additional test information
    • getPValue

      public double getPValue()
      Returns the p-value from the most recent independence test.
      Returns:
      the p-value of the last independence test