Class RandomMim

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

public final class RandomMim extends Object
Flexible MIM generator.

A "group" is a structural node in the meta-DAG. Each group has 'rank' many latent factors, and each group has 'childrenPerGroup' many measured indicators.

For a meta-edge G_i -> G_j, we add directed edges from each latent in G_i to each latent in G_j. (Complete bipartite between factor sets, as requested.)

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, Random rng)
      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 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, either via Cartesian product or corresponding positions.
      rng - the random generator used to make stochastic decisions during graph construction; can be null to use a default Random instance with a seed of 0.
      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 in the input string 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 containing one or more latent group configurations; must not be null or empty, and each configuration must adhere to the specified pattern.
      Returns:
      a list of parsed LatentGroupSpec objects representing the configurations.
      Throws:
      IllegalArgumentException - if the input string is null, empty, or contains invalid configurations, or if any parsed values are less than 1.