Class PooledIndependenceWrapper

java.lang.Object
edu.cmu.tetrad.algcomparison.utils.PooledIndependenceWrapper
All Implemented Interfaces:
IndependenceWrapper, HasParameters, TetradSerializable, Serializable

public final class PooledIndependenceWrapper extends Object implements IndependenceWrapper
The test-side counterpart of PooledScoreWrapper: builds the inner test on each pooled data set and combines them with IndTestMulti using Fisher's method (default) or Tippett's method on the per-data-set p-values, per Params.POOLED_TEST_METHOD (data sets are assumed independent of one another, e.g. different subjects or regions). This makes constraint-based algorithms multi-data-set in the same way IMaGES makes score-based ones: PC + Fisher Z on a list of data sets is a pooled PC.

The data model passed to getTest(DataModel, Parameters) is ignored; the data sets registered for the calling thread (set by the bootstrap loop for each replicate) or the default list are used. Instances are transient, existing only during a search.

Author:
josephramsey
See Also:
  • Constructor Details

    • PooledIndependenceWrapper

      public PooledIndependenceWrapper(IndependenceWrapper inner, List<DataModel> defaultDataSets)
      Constructs a pooled independence wrapper.
      Parameters:
      inner - the independence wrapper used to build one test per pooled data set.
      defaultDataSets - the data sets pooled when none have been registered for the calling thread via setThreadDataSets(List); a defensive copy is kept. All pooled data sets must have the same variables by name.
      Throws:
      NullPointerException - if inner is null.
      IllegalArgumentException - if defaultDataSets is null or empty.
  • Method Details

    • getTest

      public IndependenceTest getTest(DataModel ignored, Parameters parameters)
      Builds one test per pooled data set and combines them into an IndTestMulti, which pools the per-data-set p-values by the method selected with method(Parameters) (Fisher's method by default, or Tippett's). The data sets used are those registered for the calling thread by setThreadDataSets(List), or the default list given at construction if none are registered.
      Specified by:
      getTest in interface IndependenceWrapper
      Parameters:
      ignored - ignored; the pooled data sets are used instead of this argument.
      parameters - the parameters, passed through to the inner wrapper for every data set and consulted for Params.POOLED_TEST_METHOD.
      Returns:
      the pooled independence test.
    • method

      public static ResolveSepsets.Method method(Parameters parameters)
      Returns the p-value combining method selected by Params.POOLED_TEST_METHOD. The value "tippett" (case-insensitive, surrounding whitespace ignored) selects Tippett's minimum-p method with a Sidak adjustment; any other value, or no value, selects Fisher's method. Both assume the pooled data sets are independent of one another.
      Parameters:
      parameters - the parameters.
      Returns:
      the combining method.
    • setThreadDataSets

      public void setThreadDataSets(List<DataModel> dataSets)
      Registers the data sets to pool for tests subsequently built on the calling thread, overriding the default list. The registration is thread-local, so concurrent searches (e.g., bootstrap replicates run in parallel) can each pool their own resampled data sets through a single shared wrapper. Pass null to clear the registration and revert to the default list.
      Parameters:
      dataSets - the data sets to pool on this thread, or null to clear.
    • getInner

      public IndependenceWrapper getInner()
      Returns the independence wrapper that is built on each pooled data set.
      Returns:
      the inner independence wrapper.
    • getDescription

      public String getDescription()
      Returns a description of the pooled test, formed by prefixing the inner wrapper's description with "Pooled".
      Specified by:
      getDescription in interface IndependenceWrapper
      Returns:
      the description.
    • getDataType

      public DataType getDataType()
      Returns the data type the inner independence wrapper accepts; pooling does not change it.
      Specified by:
      getDataType in interface IndependenceWrapper
      Returns:
      the data type of the inner independence wrapper.
    • getParameters

      public List<String> getParameters()
      Returns the names of the parameters the inner independence wrapper uses. The combining method is read from Params.POOLED_TEST_METHOD, which is not added to this list here; callers that expose it should add it themselves.
      Specified by:
      getParameters in interface HasParameters
      Specified by:
      getParameters in interface IndependenceWrapper
      Returns:
      the parameter names of the inner independence wrapper.