class_docstr: Class for representing Structural Equation Models. This class is a wrapper over
  `SEMGraph` and `SEMAlg` to provide a consistent API over the different representations.
  
  Attributes
  ----------
  model: SEMGraph instance
      A graphical representation of the model.
class_docstr_tok: ["Class","for","representing","Structural","Equation","Models",".","This","class","is","a","wrapper","over","`","SEMGraph","`","and","`","SEMAlg","`","to","provide","a","consistent","API","over","the","different","representations",".","Attributes","--","--","--","--","--","model",":","SEMGraph","instance","A","graphical","representation","of","the","model","."]
docstr: Initializes a `SEM` instance using Reticular Action Model(RAM) notation. The model
  is defined as:
  
  ..math::
  
      \mathbf{\eta} = \mathbf{B \eta} + \mathbf{\epsilon} \\
      \mathbf{\y} = \wedge_y \mathbf{\eta}
      \zeta = COV(\mathbf{\epsilon})
  
  where :math:`\mathbf{\eta}` is the set of variables (both latent and observed),
  :math:`\mathbf{\epsilon}` are the error terms, :math:`\mathbf{y}` is the set
  of observed variables, :math:`\wedge_y` is a boolean array of the shape (no of
  observed variables, no of total variables).
  
  Parameters
  ----------
  variables: list, array-like
      List of variables (both latent and observed) in the model.
  
  B: 2-D boolean array (shape: `len(variables)` x `len(variables)`)
      The non-zero parameters in :math:`B` matrix. Refer model definition in docstring for details.
  
  zeta: 2-D boolean array (shape: `len(variables)` x `len(variables)`)
      The non-zero parameters in :math:`\zeta` (error covariance) matrix. Refer model definition
      in docstring for details.
  
  observed: list, array-like (optional: Either `observed` or `wedge_y` needs to be specified)
      List of observed variables in the model.
  
  wedge_y: 2-D array (shape: no. observed x total vars) (optional: Either `observed` or `wedge_y`)
      The :math:`\wedge_y` matrix. Refer model definition in docstring for details.
  
  fixed_values: dict (optional)
      If specified, fixes the parameter values and are not changed during estimation.
      A dict with the keys B, zeta.
  
  Returns
  -------
  pgmpy.models.SEM instance: An instance of the object with initialized values.
  
  Examples
  --------
  >>> from pgmpy.models import SEM
  >>> SEM.from_RAM  # TODO: Finish this
docstr_tok: ["Initializes","a","`","SEM","`","instance","using","Reticular","Action","Model","(","RAM",")","notation",".","The","model","is","defined","as",":","..","math",":",":","\\mathbf","{","\\eta","}","=","\\mathbf","{","B","\\eta","}","+","\\mathbf","{","\\epsilon","}","\\\\","\\mathbf","{","\\y","}","=","\\wedge_y","\\mathbf","{","\\eta","}","\\zeta","=","COV","(","\\mathbf","{","\\epsilon","}",")","where",":","math",":","`","\\mathbf","{","\\eta","}","`","is","the","set","of","variables","(","both","latent","and","observed",")",",",":","math",":","`","\\mathbf","{","\\epsilon","}","`","are","the","error","terms",",",":","math",":","`","\\mathbf","{","y","}","`","is","the","set","of","observed","variables",",",":","math",":","`","\\wedge_y","`","is","a","boolean","array","of","the","shape","(","no","of","observed","variables",",","no","of","total","variables",")",".","Parameters","--","--","--","--","--","variables",":","list",",","array-like","List","of","variables","(","both","latent","and","observed",")","in","the","model",".","B",":","2-D","boolean","array","(","shape",":","`","len","(","variables",")","`","x","`","len","(","variables",")","`",")","The","non-zero","parameters","in",":","math",":","`","B","`","matrix",".","Refer","model","definition","in","docstring","for","details",".","zeta",":","2-D","boolean","array","(","shape",":","`","len","(","variables",")","`","x","`","len","(","variables",")","`",")","The","non-zero","parameters","in",":","math",":","`","\\zeta","`","(","error","covariance",")","matrix",".","Refer","model","definition","in","docstring","for","details",".","observed",":","list",",","array-like","(","optional",":","Either","`","observed","`","or","`","wedge_y","`","needs","to","be","specified",")","List","of","observed","variables","in","the","model",".","wedge_y",":","2-D","array","(","shape",":","no",".","observed","x","total","vars",")","(","optional",":","Either","`","observed","`","or","`","wedge_y","`",")","The",":","math",":","`","\\wedge_y","`","matrix",".","Refer","model","definition","in","docstring","for","details",".","fixed_values",":","dict","(","optional",")","If","specified",",","fixes","the","parameter","values","and","are","not","changed","during","estimation",".","A","dict","with","the","keys","B",",","zeta",".","Returns","--","--","--","-","pgmpy.models.SEM","instance",":","An","instance","of","the","object","with","initialized","values",".","Examples","--","--","--","--",">",">",">","from","pgmpy.models","import","SEM",">",">",">","SEM.from_RAM","#","TODO",":","Finish","this"]
code: def from_RAM(
      cls,
      variables,
      B,
      zeta,
      observed=None,
      wedge_y=None,
      fixed_values=None,
  ):
      r"""
          Initializes a `SEM` instance using Reticular Action Model(RAM) notation. The model
          is defined as:
  
          ..math::
  
              \mathbf{\eta} = \mathbf{B \eta} + \mathbf{\epsilon} \\
              \mathbf{\y} = \wedge_y \mathbf{\eta}
              \zeta = COV(\mathbf{\epsilon})
  
          where :math:`\mathbf{\eta}` is the set of variables (both latent and observed),
          :math:`\mathbf{\epsilon}` are the error terms, :math:`\mathbf{y}` is the set
          of observed variables, :math:`\wedge_y` is a boolean array of the shape (no of
          observed variables, no of total variables).
  
          Parameters
          ----------
          variables: list, array-like
              List of variables (both latent and observed) in the model.
  
          B: 2-D boolean array (shape: `len(variables)` x `len(variables)`)
              The non-zero parameters in :math:`B` matrix. Refer model definition in docstring for details.
  
          zeta: 2-D boolean array (shape: `len(variables)` x `len(variables)`)
              The non-zero parameters in :math:`\zeta` (error covariance) matrix. Refer model definition
              in docstring for details.
  
          observed: list, array-like (optional: Either `observed` or `wedge_y` needs to be specified)
              List of observed variables in the model.
  
          wedge_y: 2-D array (shape: no. observed x total vars) (optional: Either `observed` or `wedge_y`)
              The :math:`\wedge_y` matrix. Refer model definition in docstring for details.
  
          fixed_values: dict (optional)
              If specified, fixes the parameter values and are not changed during estimation.
              A dict with the keys B, zeta.
  
          Returns
          -------
          pgmpy.models.SEM instance: An instance of the object with initialized values.
  
          Examples
          --------
          >>> from pgmpy.models import SEM
          >>> SEM.from_RAM  # TODO: Finish this
          """
      if observed:
          wedge_y = np.zeros((len(variables), len(observed)))
          obs_dict = {var: index for index, var in enumerate(observed)}
          all_dict = {var: index for index, var in enumerate(variables)}
          for var in observed:
              wedge_y[obs_dict[var], all_dict[var]] = 1
  
      return cls(
          syntax="ram",
          var_names=variables,
          B=B,
          zeta=zeta,
          wedge_y=wedge_y,
          fixed_values=fixed_values,
      )
  
imports: import itertools
  import networkx
  import numpy
  import pandas
  from networkx.algorithms.dag import descendants
  from pyparsing import OneOrMore, Optional, Suppress, Word, alphanums, nums
  from pgmpy.base import DAG
  from pgmpy.global_vars import logger
label_desc: Use image node_id 5 for calling the SEM obj's underlying member method code with example usage: obj.from_RAM(cls, variables, B, zeta, observed, wedge_y, fixed_values) and returns: cls