Class GeneralizedSemPm

java.lang.Object
edu.cmu.tetrad.sem.GeneralizedSemPm
All Implemented Interfaces:
Pm, TetradSerializable, Serializable

public final class GeneralizedSemPm extends Object implements Pm, TetradSerializable
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 Details

    • GeneralizedSemPm

      public GeneralizedSemPm(Graph graph)
      Constructs a BayesPm from the given Graph, which must be convertible first into a ProtoSemGraph and then into a SemGraph.
    • GeneralizedSemPm

      public GeneralizedSemPm(SemGraph graph)
      Constructs a new SemPm from the given SemGraph.
    • GeneralizedSemPm

      public GeneralizedSemPm(SemPm semPm)
    • GeneralizedSemPm

      public GeneralizedSemPm(GeneralizedSemPm semPm)
      Copy constructor.
  • Method Details

    • serializableInstance

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

      public static List<String> getParameterNames()
    • getNodeExpression

      public Expression getNodeExpression(Node node)
    • getNodeExpressionString

      public String getNodeExpressionString(Node node)
    • setNodeExpression

      public void setNodeExpression(Node node, String expressionString) throws ParseException
      Throws:
      ParseException
    • setParameterExpression

      public void setParameterExpression(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 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

      public Set<String> getParameters()
      Returns:
      the set of freeParameters for the model.
    • getParameterExpression

      public Expression getParameterExpression(String parameter)
      Parameters:
      parameter - The parameter whose initial value needs to be evaluated.
      Returns:
      an expression that can be used to calculate the initial value.
    • getParameterEstimationInitializationExpression

      public Expression getParameterEstimationInitializationExpression(String parameter)
      Parameters:
      parameter - The parameter whose initial value needs to be evaluated.
      Returns:
      an expression that can be used to calculate the initial value.
    • getParameterExpressionString

      public String getParameterExpressionString(String parameter)
      Parameters:
      parameter - The parameter whose initial value needs to be computed.
      Returns:
      The formula string that was set using setParameterExpression, with spacing intact.
    • getParameterEstimationInitializationExpressionString

      public String getParameterEstimationInitializationExpressionString(String parameter)
      Parameters:
      parameter - The parameter whose initial value needs to be computed.
      Returns:
      The formula string that was set using setParameterExpression, with spacing intact.
    • getGraph

      public SemGraph getGraph()
      Returns the structural model graph this SEM PM is using.
    • getNodes

      public List<Node> getNodes()
      Returns:
      all the nodes in the sem, including error nodes.
    • getVariableNodes

      public List<Node> getVariableNodes()
      Returns the list of variable nodes--that is, node that are not error nodes.
    • getMeasuredNodes

      public List<Node> getMeasuredNodes()
      Returns:
      the lsit of measured nodes.
    • getErrorNodes

      public List<Node> getErrorNodes()
      Returns the list of exogenous variableNodes.
    • getErrorNode

      public Node getErrorNode(Node node)
      Parameters:
      node - The variable node in question.
      Returns:
      the error node for the given node.
    • getNode

      public Node getNode(String name)
      Parameters:
      name - the name of the parameter.
      Returns:
      the variable with the given name, if there is one. Otherwise, null.
    • getReferencingNodes

      public Set<Node> getReferencingNodes(String parameter)
      Parameters:
      parameter - The parameter in question.
      Returns:
      the set of nodes that reference a given parameter.
    • getReferencedParameters

      public Set<String> getReferencedParameters(Node node)
      Parameters:
      node - the node doing the referencing.
      Returns:
      the freeParameters referenced by the given variable (variable node or error node).
    • getReferencingNodes

      public Set<Node> getReferencingNodes(Node node)
      Parameters:
      node - the node doing the referencing.
      Returns:
      the set of nodes (variable or error) referenced by the expression for the given node.
    • getReferencedNodes

      public Set<Node> getReferencedNodes(Node node)
      Parameters:
      node - the node doing the referencing.
      Returns:
      the variables referenced by the expression for the given node (variable node or error node).
    • nextParameterName

      public String 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.
      Parameters:
      base - the base string.
      Returns:
      the first string in the sequence not already being used.
    • getParents

      public List<Node> getParents(Node node)
      Parameters:
      node - the given node, variable or error.
      Returns:
      all parents of the given node, with error node(s?) last.
    • toString

      public String 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.
      Overrides:
      toString in class Object
    • getVariablesTemplate

      public String getVariablesTemplate()
    • setVariablesTemplate

      public void setVariablesTemplate(String variablesTemplate) throws ParseException
      Throws:
      ParseException
    • getErrorsTemplate

      public String getErrorsTemplate()
    • setErrorsTemplate

      public void setErrorsTemplate(String errorsTemplate) throws ParseException
      Throws:
      ParseException
    • getParametersTemplate

      public String getParametersTemplate()
    • setParametersTemplate

      public void setParametersTemplate(String parametersTemplate) throws ParseException
      Throws:
      ParseException
    • getParametersEstimationInitializationTemplate

      public String 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

      public String getStartsWithParameterTemplate(String startsWith)
    • getStartsWithParameterEstimationInitializatonTemplate

      public String getStartsWithParameterEstimationInitializatonTemplate(String startsWith)
    • startsWithPrefixes

      public Set<String> startsWithPrefixes()