Package edu.cmu.tetrad.sem
Class GeneralizedSemPm
java.lang.Object
edu.cmu.tetrad.sem.GeneralizedSemPm
- All Implemented Interfaces:
Pm
,TetradSerializable
,Serializable
Parametric model for Generalized SEM model. This contains all the equations of the model with parameters represented
symbolically (i.e. no values for parameters).
- Author:
- josephramsey
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionGeneralizedSemPm
(Graph graph) Constructs a BayesPm from the given Graph, which must be convertible first into a ProtoSemGraph and then into a SemGraph.GeneralizedSemPm
(SemGraph graph) Constructs a new SemPm from the given SemGraph.GeneralizedSemPm
(GeneralizedSemPm semPm) Copy constructor.GeneralizedSemPm
(SemPm semPm) -
Method Summary
Modifier and TypeMethodDescriptiongetErrorNode
(Node node) Returns the list of exogenous variableNodes.getGraph()
Returns the structural model graph this SEM PM is using.getNodeExpression
(Node node) getNodeExpressionString
(Node node) getNodes()
getParameterExpression
(String parameter) getParameterExpressionString
(String parameter) getParents
(Node node) getReferencedNodes
(Node node) getReferencedParameters
(Node node) getReferencingNodes
(Node node) getReferencingNodes
(String parameter) getStartsWithParameterTemplate
(String startsWith) Returns the list of variable nodes--that is, node that are not error nodes.nextParameterName
(String base) Given base b (a String), returns the first name in the sequence "b1", "b2", "b3", etc., which is not already the name of a node in the workbench.static GeneralizedSemPm
Generates a simple exemplar of this class to test serialization.void
setErrorsTemplate
(String errorsTemplate) void
setNodeExpression
(Node node, String expressionString) void
setParameterEstimationInitializationExpression
(String parameter, String expressionString) void
setParameterEstimationInitializationExpression
(String startsWith, String parameter, String expressionString) Sets the expression which should be evaluated when calculating new values for the given parameter.void
setParameterExpression
(String parameter, String expressionString) Sets the expression which should be evaluated when calculating new values for the given parameter.void
setParameterExpression
(String startsWith, String parameter, String expressionString) Sets the expression which should be evaluated when calculating new values for the given parameter.void
setParametersEstimationInitializationTemplate
(String parametersTemplate) void
setParametersTemplate
(String parametersTemplate) void
setStartsWithParametersEstimationInitializaationTemplate
(String startsWith, String parametersEstimationInitializationTemplate) void
setStartsWithParametersTemplate
(String startsWith, String parametersTemplate) void
setVariablesTemplate
(String variablesTemplate) toString()
Returns a relatively brief String representation of this SEM PM--the equations and distributions of the model.
-
Constructor Details
-
GeneralizedSemPm
Constructs a BayesPm from the given Graph, which must be convertible first into a ProtoSemGraph and then into a SemGraph. -
GeneralizedSemPm
Constructs a new SemPm from the given SemGraph. -
GeneralizedSemPm
-
GeneralizedSemPm
Copy constructor.
-
-
Method Details
-
serializableInstance
Generates a simple exemplar of this class to test serialization. -
getParameterNames
-
getNodeExpression
-
getNodeExpressionString
-
setNodeExpression
- Throws:
ParseException
-
setParameterExpression
Sets the expression which should be evaluated when calculating new values for the given parameter. These values are used to initialize the freeParameters.- Parameters:
parameter
- The parameter whose initial value needs to be computed.expressionString
- The formula for picking initial values.- Throws:
ParseException
- If the formula cannot be parsed or contains variable names.
-
setParameterEstimationInitializationExpression
public void setParameterEstimationInitializationExpression(String parameter, String expressionString) throws ParseException - Throws:
ParseException
-
setParameterExpression
public void setParameterExpression(String startsWith, String parameter, String expressionString) throws ParseException Sets the expression which should be evaluated when calculating new values for the given parameter. These values are used to initialize the freeParameters.- Parameters:
parameter
- The parameter whose initial value needs to be computed.expressionString
- The formula for picking initial values.- Throws:
ParseException
- If the formula cannot be parsed or contains variable names.
-
setParameterEstimationInitializationExpression
public void setParameterEstimationInitializationExpression(String startsWith, String parameter, String expressionString) throws ParseException Sets the expression which should be evaluated when calculating new values for the given parameter. These values are used to initialize the freeParameters.- Parameters:
parameter
- The parameter whose initial value needs to be computed.expressionString
- The formula for picking initial values.- Throws:
ParseException
- If the formula cannot be parsed or contains variable names.
-
getParameters
- Returns:
- the set of freeParameters for the model.
-
getParameterExpression
- Parameters:
parameter
- The parameter whose initial value needs to be evaluated.- Returns:
- an expression that can be used to calculate the initial value.
-
getParameterEstimationInitializationExpression
- Parameters:
parameter
- The parameter whose initial value needs to be evaluated.- Returns:
- an expression that can be used to calculate the initial value.
-
getParameterExpressionString
- Parameters:
parameter
- The parameter whose initial value needs to be computed.- Returns:
- The formula string that was set using
setParameterExpression
, with spacing intact.
-
getParameterEstimationInitializationExpressionString
- Parameters:
parameter
- The parameter whose initial value needs to be computed.- Returns:
- The formula string that was set using
setParameterExpression
, with spacing intact.
-
getGraph
Returns the structural model graph this SEM PM is using. -
getNodes
- Returns:
- all the nodes in the sem, including error nodes.
-
getVariableNodes
Returns the list of variable nodes--that is, node that are not error nodes. -
getMeasuredNodes
- Returns:
- the lsit of measured nodes.
-
getErrorNodes
Returns the list of exogenous variableNodes. -
getErrorNode
- Parameters:
node
- The variable node in question.- Returns:
- the error node for the given node.
-
getNode
- Parameters:
name
- the name of the parameter.- Returns:
- the variable with the given name, if there is one. Otherwise, null.
-
getReferencingNodes
- Parameters:
parameter
- The parameter in question.- Returns:
- the set of nodes that reference a given parameter.
-
getReferencedParameters
- Parameters:
node
- the node doing the referencing.- Returns:
- the freeParameters referenced by the given variable (variable node or error node).
-
getReferencingNodes
- Parameters:
node
- the node doing the referencing.- Returns:
- the set of nodes (variable or error) referenced by the expression for the given node.
-
getReferencedNodes
- Parameters:
node
- the node doing the referencing.- Returns:
- the variables referenced by the expression for the given node (variable node or error node).
-
nextParameterName
Given base b (a String), returns the first name in the sequence "b1", "b2", "b3", etc., which is not already the name of a node in the workbench.- Parameters:
base
- the base string.- Returns:
- the first string in the sequence not already being used.
-
getParents
- Parameters:
node
- the given node, variable or error.- Returns:
- all parents of the given node, with error node(s?) last.
-
toString
Returns a relatively brief String representation of this SEM PM--the equations and distributions of the model. Initial value distributions for freeParameters are not printed. -
getVariablesTemplate
-
setVariablesTemplate
- Throws:
ParseException
-
getErrorsTemplate
-
setErrorsTemplate
- Throws:
ParseException
-
getParametersTemplate
-
setParametersTemplate
- Throws:
ParseException
-
getParametersEstimationInitializationTemplate
-
setParametersEstimationInitializationTemplate
public void setParametersEstimationInitializationTemplate(String parametersTemplate) throws ParseException - Throws:
ParseException
-
setStartsWithParametersTemplate
public void setStartsWithParametersTemplate(String startsWith, String parametersTemplate) throws ParseException - Throws:
ParseException
-
setStartsWithParametersEstimationInitializaationTemplate
public void setStartsWithParametersEstimationInitializaationTemplate(String startsWith, String parametersEstimationInitializationTemplate) throws ParseException - Throws:
ParseException
-
getStartsWithParameterTemplate
-
getStartsWithParameterEstimationInitializatonTemplate
-
startsWithPrefixes
-