Class MissingDataSpec

java.lang.Object
edu.cmu.tetrad.data.missing.MissingDataSpec
All Implemented Interfaces:
TetradSerializable, Serializable

public final class MissingDataSpec extends Object implements TetradSerializable
An immutable specification of how missing data are to be handled: a MissingDataPolicy together with the parameters that policy needs (EM settings for MissingDataPolicy.EM_COVARIANCE, the number of imputations for MissingDataPolicy.MULTIPLE_IMPUTATION, and so on). The whole configuration travels as one object so that constructors, algcomparison wrappers, and py-tetrad can pass it through uniformly.

Instances are created from the static factory methods and refined with the with... methods, e.g.:

    MissingDataSpec spec = MissingDataSpec.emCovariance().withEmRidge(1e-4);
Version:
$Id: $Id
Author:
josephramsey
See Also:
  • Method Details

    • of

      public static MissingDataSpec of(MissingDataPolicy policy)
      A spec with the given policy and default parameters.
      Parameters:
      policy - The policy.
      Returns:
      The spec.
    • fail

      public static MissingDataSpec fail()
      A spec that refuses data containing missing values.
      Returns:
      The spec.
    • listwise

      public static MissingDataSpec listwise()
      A spec for listwise deletion.
      Returns:
      The spec.
    • testwise

      public static MissingDataSpec testwise()
      A spec for test-wise deletion. This reproduces the historical implicit behavior of, e.g., SemBicScore on data with missing values, but explicitly.
      Returns:
      The spec.
    • emCovariance

      public static MissingDataSpec emCovariance()
      A spec for EM covariance estimation with default EM settings.
      Returns:
      The spec.
    • pairwiseCovariance

      public static MissingDataSpec pairwiseCovariance()
      A spec for a pairwise-deletion covariance matrix; see MissingDataPolicy.PAIRWISE_COVARIANCE and PairwiseCovarianceEstimator. Consistent under MCAR, not MAR. Pair it with a pairwise effective sample size mode, since the estimate reports the full row count.
      Returns:
      The spec.
    • multipleImputation

      public static MissingDataSpec multipleImputation(int numImputations)
      A spec for multiple imputation with the given number of imputations.
      Parameters:
      numImputations - The number of imputed datasets, m; at least 1. One is allowed, but a single completed dataset shows nothing of the uncertainty due to the missing values; use 2 or more for any result meant to be relied on.
      Returns:
      The spec.
    • serializableInstance

      public static MissingDataSpec serializableInstance()
      Generates a simple exemplar of this class to test serialization.
      Returns:
      This exemplar.
    • withEmRidge

      public MissingDataSpec withEmRidge(double emRidge)
      Returns a copy of this spec with the given EM ridge.
      Parameters:
      emRidge - The ridge; must be nonnegative.
      Returns:
      The copy.
    • withEmTolerance

      public MissingDataSpec withEmTolerance(double emTolerance)
      Returns a copy of this spec with the given EM convergence tolerance.
      Parameters:
      emTolerance - The tolerance; must be positive.
      Returns:
      The copy.
    • withEmMaxIterations

      public MissingDataSpec withEmMaxIterations(int emMaxIterations)
      Returns a copy of this spec with the given maximum number of EM iterations.
      Parameters:
      emMaxIterations - The maximum; must be at least 1.
      Returns:
      The copy.
    • withNumImputations

      public MissingDataSpec withNumImputations(int numImputations)
      Returns a copy of this spec with the given number of imputations.
      Parameters:
      numImputations - The number of imputed datasets, m; at least 1. One is allowed, but a single completed dataset shows nothing of the uncertainty due to the missing values; use 2 or more for any result meant to be relied on.
      Returns:
      The copy.
    • withSeed

      public MissingDataSpec withSeed(long seed)
      Returns a copy of this spec with the given random seed.
      Parameters:
      seed - The seed; -1 means no fixed seed.
      Returns:
      The copy.
    • withEssMode

      Returns a copy of this spec with the given effective sample size mode.
      Parameters:
      essMode - The mode.
      Returns:
      The copy.
    • getPolicy

      public MissingDataPolicy getPolicy()
      The policy.
      Returns:
      This policy.
    • getEmRidge

      public double getEmRidge()
      The EM ridge.
      Returns:
      This ridge.
    • getEmTolerance

      public double getEmTolerance()
      The EM convergence tolerance.
      Returns:
      This tolerance.
    • getEmMaxIterations

      public int getEmMaxIterations()
      The maximum number of EM iterations.
      Returns:
      This maximum.
    • getNumImputations

      public int getNumImputations()
      The number of imputations, m.
      Returns:
      This number.
    • getSeed

      public long getSeed()
      The random seed, or -1 if none is fixed.
      Returns:
      This seed.
    • getEssMode

      The effective sample size mode.
      Returns:
      This mode.
    • toString

      public String toString()
      A string representation of the spec.
      Overrides:
      toString in class Object
      Returns:
      This string.