Package edu.cmu.tetrad.sem
Class GeneralizedSemIm
java.lang.Object
edu.cmu.tetrad.sem.GeneralizedSemIm
- All Implemented Interfaces:
Simulator
,Im
,TetradSerializable
,Serializable
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 Summary
ConstructorsConstructorDescriptionConstructs a new GeneralizedSemIm from the given GeneralizedSemPm by picking values for each of the freeParameters from their initial distributions.GeneralizedSemIm
(GeneralizedSemPm pm, SemIm semIm) -
Method Summary
Modifier and TypeMethodDescriptiongetNodeSubstitutedString
(Node node) getNodeSubstitutedString
(Node node, Map<String, Double> substitutedValues) double
getParameterValue
(String parameter) getSemPm()
static GeneralizedSemIm
Generates a simple exemplar of this class to test serialization.void
setGuaranteeIid
(boolean guaranteeIid) void
setParameterValue
(String parameter, double value) void
setSubstitutions
(Map<String, Double> parameterValues) simulateData
(int sampleSize, boolean latentDataSaved) Simulates data from the model associated with this object.simulateDataAvoidInfinity
(int sampleSize, boolean latentDataSaved) simulateDataFisher
(int sampleSize) Simulates data using the model of R.simulateDataFisher
(int sampleSize, int intervalBetweenShocks, double epsilon) Simulates data using the model of R.simulateDataMinimizeSurface
(int sampleSize, boolean latentDataSaved) simulateDataNSteps
(int sampleSize, boolean latentDataSaved) 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.toString()
-
Constructor Details
-
GeneralizedSemIm
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
-
-
Method Details
-
serializableInstance
Generates a simple exemplar of this class to test serialization. -
getGeneralizedSemPm
- Returns:
- a copy of the stored GeneralizedSemPm.
-
setParameterValue
- Parameters:
parameter
- The parameter whose values is to be set.value
- The double value thatparam
is to be set to.
-
getParameterValue
- Parameters:
parameter
- The parameter whose value is to be retrieved.- Returns:
- The retrieved value.
-
getNodeSubstitutedString
- Returns:
- the user's String formula with numbers substituted for freeParameters, where substitutions exist.
-
getNodeSubstitutedString
- 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
-
simulateData
Description copied from interface:Simulator
Simulates data from the model associated with this object.- Specified by:
simulateData
in interfaceSimulator
- 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
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
-
simulateDataAvoidInfinity
-
simulateDataFisher
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
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
-
simulateDataNSteps
-
getSemPm
-
setSubstitutions
-
setGuaranteeIid
public void setGuaranteeIid(boolean guaranteeIid)
-