Class GeneralizedSemIm

java.lang.Object
edu.cmu.tetrad.sem.GeneralizedSemIm
All Implemented Interfaces:
Simulator, Im, TetradSerializable, Serializable

public class GeneralizedSemIm extends Object implements Im, Simulator
Represents a generalized SEM instantiated model. The parameteric form of this model allows arbitrary equations for variables. This instantiated model gives values for all of the parameters of the parameterized model.
Author:
josephramsey
See Also:
  • Constructor Details

    • GeneralizedSemIm

      public GeneralizedSemIm(GeneralizedSemPm pm)
      Constructs a new GeneralizedSemIm from the given GeneralizedSemPm by picking values for each of the freeParameters from their initial distributions.
      Parameters:
      pm - the GeneralizedSemPm. Includes all of the equations and distributions of the model.
    • GeneralizedSemIm

      public GeneralizedSemIm(GeneralizedSemPm pm, SemIm semIm)
  • Method Details

    • serializableInstance

      public static GeneralizedSemIm serializableInstance()
      Generates a simple exemplar of this class to test serialization.
    • getGeneralizedSemPm

      public GeneralizedSemPm getGeneralizedSemPm()
      Returns:
      a copy of the stored GeneralizedSemPm.
    • setParameterValue

      public void setParameterValue(String parameter, double value)
      Parameters:
      parameter - The parameter whose values is to be set.
      value - The double value that param is to be set to.
    • getParameterValue

      public double getParameterValue(String parameter)
      Parameters:
      parameter - The parameter whose value is to be retrieved.
      Returns:
      The retrieved value.
    • getNodeSubstitutedString

      public String getNodeSubstitutedString(Node node)
      Returns:
      the user's String formula with numbers substituted for freeParameters, where substitutions exist.
    • getNodeSubstitutedString

      public String getNodeSubstitutedString(Node node, Map<String,Double> substitutedValues)
      Parameters:
      node - The node whose expression is being evaluated.
      substitutedValues - A mapping from Strings parameter names to Double values; these values will be substituted for the stored values where applicable.
      Returns:
      the expression string with values substituted for freeParameters.
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      a String representation of the IM, in this case a lsit of freeParameters and their values.
    • simulateData

      public DataSet simulateData(int sampleSize, boolean latentDataSaved)
      Description copied from interface: Simulator
      Simulates data from the model associated with this object.
      Specified by:
      simulateData in interface Simulator
      Parameters:
      sampleSize - the number of rows to simulate.
      latentDataSaved - if true, latent variables are saved in the data set.
      Returns:
      the simulated data set.
    • simulateDataRecursive

      public DataSet simulateDataRecursive(int sampleSize, boolean latentDataSaved)
      This simulates data by picking random values for the exogenous terms and percolating this information down through the SEM, assuming it is acyclic. Fast for large simulations but hangs for cyclic models.
      Parameters:
      sampleSize - > 0.
      Returns:
      the simulated data set.
    • simulateDataMinimizeSurface

      public DataSet simulateDataMinimizeSurface(int sampleSize, boolean latentDataSaved)
    • simulateDataAvoidInfinity

      public DataSet simulateDataAvoidInfinity(int sampleSize, boolean latentDataSaved)
    • simulateDataFisher

      public DataSet simulateDataFisher(int sampleSize)
      Simulates data using the model of R. A. Fisher, for a linear model. Shocks are applied every so many steps. A data point is recorded before each shock is administered. If convergence happens before that number of steps has been reached, a data point is recorded and a new shock immediately applied. The model may be cyclic. If cyclic, all eigenvalues for the coefficient matrix must be less than 1, though this is not checked. Uses an interval between shocks of 50 and a convergence threshold of 1e-5. Uncorrelated Gaussian shocks are used.
      Parameters:
      sampleSize - The number of samples to be drawn. Must be a positive integer.
    • simulateDataFisher

      public DataSet simulateDataFisher(int sampleSize, int intervalBetweenShocks, double epsilon)
      Simulates data using the model of R. A. Fisher, for a linear model. Shocks are applied every so many steps. A data point is recorded before each shock is administered. If convergence happens before that number of steps has been reached, a data point is recorded and a new shock immediately applied. The model may be cyclic. If cyclic, all eigenvalues for the coefficient matrix must be less than 1, though this is not checked.
      Parameters:
      sampleSize - The number of samples to be drawn.
      intervalBetweenShocks - External shock is applied every this many steps. Must be positive integer.
      epsilon - The convergence criterion; |xi.t - xi.t-1| < epsilon.
    • simulateOneRecord

      public Vector simulateOneRecord(Vector e)
    • simulateDataNSteps

      public DataSet simulateDataNSteps(int sampleSize, boolean latentDataSaved)
    • getSemPm

      public GeneralizedSemPm getSemPm()
    • setSubstitutions

      public void setSubstitutions(Map<String,Double> parameterValues)
    • setGuaranteeIid

      public void setGuaranteeIid(boolean guaranteeIid)