Package edu.cmu.tetrad.sem
Class GeneralizedSemPm
java.lang.Object
edu.cmu.tetrad.sem.GeneralizedSemPm
- All Implemented Interfaces:
- Pm,- TetradSerializable,- Serializable
Parametric model for a Generalized SEM model. This contains all the equations of the model with parameters
 represented symbolically (i.e., no values for parameters).
- Version:
- $Id: $Id
- Author:
- josephramsey
- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionGeneralizedSemPm(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) Initializes a new instance of the GeneralizedSemPm class by copying the properties of the provided GeneralizedSemPm object.GeneralizedSemPm(SemPm semPm) Constructs a new GeneralizedSemPm object based on the given SemPm object.
- 
Method SummaryModifier and TypeMethodDescriptiongetErrorNode(Node node) Retrieves the error node associated with the given node.Returns the list of exogenous variableNodes.Returns the error template string.getGraph()Returns the structural model graph this SEM PM is using.Returns a list of measured nodes.Returns the Node with the given name.getNodeExpression(Node node) getNodeExpression.getNodeExpressionString(Node node) getNodeExpressionString.getNodes()Retrieves a list of nodes.Retrieves the initialization expression for a given parameter used in parameter estimation.Returns the initialization expression string for the given parameter.getParameterExpression(String parameter) Retrieves the expression associated with the given parameter.getParameterExpressionString(String parameter) Returns the expression string associated with the given parameter.Retrieves the names of the parameters required for a certain operation.Retrieves the set of parameters.Retrieves the parameter estimation initialization template.Retrieves the template for the parameters.getParents(Node node) Retrieves the list of parent nodes for the given node.getReferencedNodes(Node node) Retrieves a set of referenced nodes for the given node.getReferencedParameters(Node node) Retrieves the set of referenced parameters from a given node.getReferencingNodes(Node node) Retrieves the set of referencing nodes for a given node.getReferencingNodes(String parameter) Returns a set of nodes that reference the given parameter.Retrieves the initialization template for parameter estimation based on the provided starting string.getStartsWithParameterTemplate(String startsWith) getStartsWithParameterTemplate.Returns the list of variable nodes--that is, node that is not error nodes.Retrieves the variable template.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 GeneralizedSemPmGenerates a simple exemplar of this class to test serialization.voidsetErrorsTemplate(String errorsTemplate) Sets the error template for the software.voidsetNodeExpression(Node node, String expressionString) Sets the expression for a given node.voidsetParameterEstimationInitializationExpression(String parameter, String expressionString) Sets the parameter estimation initialization expression for the given parameter.voidsetParameterEstimationInitializationExpression(String startsWith, String parameter, String expressionString) Sets the expression which should be evaluated when calculating new values for the given parameter.voidsetParameterExpression(String parameter, String expressionString) Sets the expression which should be evaluated when calculating new values for the given parameter.voidsetParameterExpression(String startsWith, String parameter, String expressionString) Sets the expression which should be evaluated when calculating new values for the given parameter.voidsetParametersEstimationInitializationTemplate(String parametersTemplate) Sets the template for parameter estimation initialization.voidsetParametersTemplate(String parametersTemplate) Sets the parameter template for the object.voidsetStartsWithParametersEstimationInitializationTemplate(String startsWith, String parametersEstimationInitializationTemplate) Sets the parameter estimation initialization template for a given startsWith string.voidsetStartsWithParametersTemplate(String startsWith, String parametersTemplate) Sets the parameter template for expressions that start with the specified string.voidsetVariablesTemplate(String variablesTemplate) Sets the variable template.startsWithPrefixes.toString()Returns a relatively brief String representation of this SEM PM--the equations and distributions of the model.
- 
Constructor Details- 
GeneralizedSemPmConstructs a BayesPm from the given Graph, which must be convertible first into a ProtoSemGraph and then into a SemGraph.- Parameters:
- graph- a- Graphobject
 
- 
GeneralizedSemPmConstructs a new SemPm from the given SemGraph.- Parameters:
- graph- a- SemGraphobject
 
- 
GeneralizedSemPmConstructs a new GeneralizedSemPm object based on the given SemPm object.- Parameters:
- semPm- the SemPm object used to construct the GeneralizedSemPm
- Throws:
- IllegalStateException- if there is a parse error in constructing the initial model
 
- 
GeneralizedSemPmInitializes a new instance of the GeneralizedSemPm class by copying the properties of the provided GeneralizedSemPm object.- Parameters:
- semPm- The GeneralizedSemPm object to copy.
 
 
- 
- 
Method Details- 
serializableInstanceGenerates a simple exemplar of this class to test serialization.- Returns:
- a GeneralizedSemPmobject
 
- 
getParameterNamesRetrieves the names of the parameters required for a certain operation.- Returns:
- a list containing the names of the parameters
 
- 
getNodeExpressiongetNodeExpression. - Parameters:
- node- a- Nodeobject
- Returns:
- a Expressionobject
 
- 
getNodeExpressionStringgetNodeExpressionString. 
- 
setNodeExpressionSets the expression for a given node.- Parameters:
- node- the node for which to set the expression
- expressionString- the expression string to set
- Throws:
- ParseException- if the expression string cannot be parsed
- NullPointerException- if node is null or expressionString is null
 
- 
setParameterExpressionSets 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.
 
- 
setParameterEstimationInitializationExpressionpublic void setParameterEstimationInitializationExpression(String parameter, String expressionString) throws ParseException Sets the parameter estimation initialization expression for the given parameter.- Parameters:
- parameter- The parameter to set the initialization expression for.
- expressionString- The expression string to be parsed and stored.
- Throws:
- NullPointerException- If either parameter or expressionString is null.
- ParseException- If the expressionString is not valid and cannot be parsed.
- IllegalArgumentException- If the expressionString contains parameters.
 
- 
setParameterExpressionpublic 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:
- startsWith- a- Stringobject
- 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.
 
- 
setParameterEstimationInitializationExpressionpublic 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:
- startsWith- a- Stringobject
- 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.
 
- 
getParametersRetrieves the set of parameters.- Returns:
- a Set of String representing the parameters.
 
- 
getParameterExpressionRetrieves the expression associated with the given parameter.- Parameters:
- parameter- the name of the parameter
- Returns:
- the expression associated with the given parameter, or null if not found
 
- 
getParameterEstimationInitializationExpressionRetrieves the initialization expression for a given parameter used in parameter estimation.- Parameters:
- parameter- the parameter for which to retrieve the initialization expression
- Returns:
- the initialization expression for the specified parameter, or null if not found
 
- 
getParameterExpressionStringReturns the expression string associated with the given parameter.- Parameters:
- parameter- the parameter name
- Returns:
- the expression string associated with the parameter
 
- 
getParameterEstimationInitializationExpressionStringReturns the initialization expression string for the given parameter.- Parameters:
- parameter- the parameter for which the initialization expression string is needed
- Returns:
- the initialization expression string for the given parameter, or null if not found
 
- 
getGraphReturns the structural model graph this SEM PM is using.- Returns:
- a SemGraphobject
 
- 
getNodesRetrieves a list of nodes.- Returns:
- A list of nodes.
 
- 
getVariableNodesReturns the list of variable nodes--that is, node that is not error nodes.- Returns:
- a Listobject
 
- 
getMeasuredNodesReturns a list of measured nodes.- Returns:
- a list of measured nodes.
 
- 
getErrorNodesReturns the list of exogenous variableNodes.- Returns:
- a Listobject
 
- 
getErrorNodeRetrieves the error node associated with the given node.- Parameters:
- node- The node to check for error association.
- Returns:
- The error node associated with the given node, or null if no error node is found.
 
- 
getNodeReturns the Node with the given name.- Parameters:
- name- the name of the Node to retrieve
- Returns:
- the Node with the given name, or null if no Node exists with the specified name
 
- 
getReferencingNodesReturns a set of nodes that reference the given parameter.- Parameters:
- parameter- the parameter to search for referencing nodes
- Returns:
- a set of nodes that reference the given parameter, or an empty set if no nodes are found
 
- 
getReferencedParametersRetrieves the set of referenced parameters from a given node.- Parameters:
- node- The node for which to retrieve referenced parameters.
- Returns:
- The set of referenced parameters found in the given node.
 
- 
getReferencingNodesRetrieves the set of referencing nodes for a given node.- Parameters:
- node- the node for which to retrieve the referencing nodes
- Returns:
- a set of referencing nodes
 
- 
getReferencedNodesRetrieves a set of referenced nodes for the given node.- Parameters:
- node- the node for which to retrieve the referenced nodes
- Returns:
- a set of referenced nodes
 
- 
nextParameterNameGiven 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.
 
- 
getParentsRetrieves the list of parent nodes for the given node.- Parameters:
- node- the specified node
- Returns:
- the list of parent nodes
 
- 
toStringReturns a relatively brief String representation of this SEM PM--the equations and distributions of the model. Initial value distributions for freeParameters are not printed.
- 
getVariablesTemplateRetrieves the variable template.- Returns:
- the variable template
 
- 
setVariablesTemplateSets the variable template.- Parameters:
- variablesTemplate- the template for variables
- Throws:
- ParseException- if the variable template fails to parse
- NullPointerException- if the variable template is null
 
- 
getErrorsTemplateReturns the error template string.- Returns:
- the error template string
 
- 
setErrorsTemplateSets the error template for the software.- Parameters:
- errorsTemplate- the string representation of the error template
- Throws:
- ParseException- if the error template cannot be parsed successfully
- NullPointerException- if the errorsTemplate parameter is null
 
- 
getParametersTemplateRetrieves the template for the parameters.- Returns:
- The template for the parameters.
 
- 
setParametersTemplateSets the parameter template for the object.- Parameters:
- parametersTemplate- the template string representing the parameters
- Throws:
- ParseException- if the given parameters template is not valid
- NullPointerException- if the parameter template is null
- IllegalArgumentException- if the parameter template contains parameters
- See Also:
 
- 
getParametersEstimationInitializationTemplateRetrieves the parameter estimation initialization template.- Returns:
- The parameter estimation initialization template as a String.
 
- 
setParametersEstimationInitializationTemplatepublic void setParametersEstimationInitializationTemplate(String parametersTemplate) throws ParseException Sets the template for parameter estimation initialization.- Parameters:
- parametersTemplate- the template string for parameter estimation initialization
- Throws:
- ParseException- if the provided parameters template is not parseable
- NullPointerException- if the provided parameters template is null
 
- 
setStartsWithParametersTemplatepublic void setStartsWithParametersTemplate(String startsWith, String parametersTemplate) throws ParseException Sets the parameter template for expressions that start with the specified string. If the startsWith parameter is null or empty, the method does nothing. If the parametersTemplate parameter is null, a NullPointerException is thrown. The method parses the parametersTemplate to ensure it is a valid expression. If the startsWith string contains spaces, an IllegalArgumentException is thrown.- Parameters:
- startsWith- The starting string for the expressions.
- parametersTemplate- The template for the parameters of the expressions.
- Throws:
- ParseException- If the parametersTemplate is not a valid expression.
- NullPointerException- If the parametersTemplate is null.
- IllegalArgumentException- If the startsWith string contains spaces.
 
- 
setStartsWithParametersEstimationInitializationTemplatepublic void setStartsWithParametersEstimationInitializationTemplate(String startsWith, String parametersEstimationInitializationTemplate) throws ParseException Sets the parameter estimation initialization template for a given startsWith string.- Parameters:
- startsWith- the string that the template should start with
- parametersEstimationInitializationTemplate- the template for initializing the parameter estimation
- Throws:
- ParseException- if the template is unable to be parsed
- NullPointerException- if the parametersTemplate is null
- IllegalArgumentException- if the startsWith string contains spaces
 
- 
getStartsWithParameterTemplategetStartsWithParameterTemplate. 
- 
getStartsWithParameterEstimationInitializationTemplateRetrieves the initialization template for parameter estimation based on the provided starting string.- Parameters:
- startsWith- The starting string used to find the initialization template.
- Returns:
- The initialization template corresponding to the starting string.
 
- 
startsWithPrefixesstartsWithPrefixes. - Returns:
- a Setobject
 
 
-