Class RandomMim

java.lang.Object
edu.cmu.tetrad.graph.RandomMim

public final class RandomMim extends Object
Flexible MIM (Multiple Indicator Model) generator.

A "group" is a structural node in the meta-DAG. Each group has rank many latent factors, and childrenPerGroup many measured indicators. For a meta-edge G_i -> G_j, directed edges are added from each latent in G_i to each latent in G_j according to the chosen RandomMim.LatentLinkMode.

Impurities:

  • numLatentMeasuredImpureParents: extra latent -> measured cross-loadings
  • numMeasuredMeasuredImpureParents: measured -> measured directed edges
  • numMeasuredMeasuredImpureAssociations: measured <-> measured bidirected error correlations
  • Method Details

    • constructRandomMim

      public static Graph constructRandomMim(List<RandomMim.LatentGroupSpec> specs, Integer metaEdgeCount, int numLatentMeasuredImpureParents, int numMeasuredMeasuredImpureParents, int numMeasuredMeasuredImpureAssociations, RandomMim.LatentLinkMode latentLinkMode)
      Constructs a random meta-graph as a Multiple Indicator Model (MIM) with specified structural constraints. This method generates latent groups based on the provided specifications, builds a meta-DAG among the groups, and materializes the graph with impurities such as cross-loadings, directed impurities, and bidirectional associations over measured nodes.
      Parameters:
      specs - the list of specifications describing latent groups, including group ranks and children per group; must not be null or empty.
      metaEdgeCount - the number of edges in the meta-DAG over latent groups; if null, a random proportion (~20%) of possible forward edges is chosen instead.
      numLatentMeasuredImpureParents - the number of additional latent-to-measured cross-loadings to introduce.
      numMeasuredMeasuredImpureParents - the number of directed edges to introduce among measured nodes as impurities.
      numMeasuredMeasuredImpureAssociations - the number of bidirectional associations to introduce among measured nodes.
      latentLinkMode - the mode of linking latents between groups in the meta-DAG.
      Returns:
      the constructed graph representing the random MIM with all specified constraints and impurities.
      Throws:
      IllegalArgumentException - if the specifications are null, empty, or malformed, if the number of meta-edges is out of valid range, or if the latentLinkMode is unrecognized.
    • parseLatentGroupSpecs

      public static List<RandomMim.LatentGroupSpec> parseLatentGroupSpecs(String value)
      Parses a specification string defining latent group configurations into a list of LatentGroupSpec objects. Each configuration must follow the pattern: countGroups:childrenPerGroup(rank). Multiple configurations should be separated by commas (e.g., 5:3(2), 4:6(1)).
      Parameters:
      value - the specification string; must not be null or empty.
      Returns:
      a list of parsed LatentGroupSpec objects.
      Throws:
      IllegalArgumentException - if the input is null, empty, or any token is malformed.