Class MissingDataSpec
java.lang.Object
edu.cmu.tetrad.data.missing.MissingDataSpec
- All Implemented Interfaces:
TetradSerializable, Serializable
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumHow the effective sample size used by penalized scores (e.g., the n in BIC) is determined when the analysis runs on a covariance matrix estimated from incomplete data. -
Method Summary
Modifier and TypeMethodDescriptionstatic MissingDataSpecA spec for EM covariance estimation with default EM settings.static MissingDataSpecfail()A spec that refuses data containing missing values.intThe maximum number of EM iterations.doubleThe EM ridge.doubleThe EM convergence tolerance.The effective sample size mode.intThe number of imputations, m.The policy.longgetSeed()The random seed, or -1 if none is fixed.static MissingDataSpeclistwise()A spec for listwise deletion.static MissingDataSpecmultipleImputation(int numImputations) A spec for multiple imputation with the given number of imputations.static MissingDataSpecof(MissingDataPolicy policy) A spec with the given policy and default parameters.static MissingDataSpecA spec for a pairwise-deletion covariance matrix; seeMissingDataPolicy.PAIRWISE_COVARIANCEandPairwiseCovarianceEstimator.static MissingDataSpecGenerates a simple exemplar of this class to test serialization.static MissingDataSpectestwise()A spec for test-wise deletion.toString()A string representation of the spec.withEmMaxIterations(int emMaxIterations) Returns a copy of this spec with the given maximum number of EM iterations.withEmRidge(double emRidge) Returns a copy of this spec with the given EM ridge.withEmTolerance(double emTolerance) Returns a copy of this spec with the given EM convergence tolerance.Returns a copy of this spec with the given effective sample size mode.withNumImputations(int numImputations) Returns a copy of this spec with the given number of imputations.withSeed(long seed) Returns a copy of this spec with the given random seed.
-
Method Details
-
of
A spec with the given policy and default parameters.- Parameters:
policy- The policy.- Returns:
- The spec.
-
fail
A spec that refuses data containing missing values.- Returns:
- The spec.
-
listwise
-
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
A spec for EM covariance estimation with default EM settings.- Returns:
- The spec.
-
pairwiseCovariance
A spec for a pairwise-deletion covariance matrix; seeMissingDataPolicy.PAIRWISE_COVARIANCEandPairwiseCovarianceEstimator. 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
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
Generates a simple exemplar of this class to test serialization.- Returns:
- This exemplar.
-
withEmRidge
Returns a copy of this spec with the given EM ridge.- Parameters:
emRidge- The ridge; must be nonnegative.- Returns:
- The copy.
-
withEmTolerance
Returns a copy of this spec with the given EM convergence tolerance.- Parameters:
emTolerance- The tolerance; must be positive.- Returns:
- The copy.
-
withEmMaxIterations
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
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
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
-
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
-