Class DagScorer

java.lang.Object
edu.cmu.tetrad.sem.DagScorer
All Implemented Interfaces:
Scorer, TetradSerializable, Serializable

public final class DagScorer extends Object implements TetradSerializable, Scorer
Estimates a SemIm given a CovarianceMatrix and a SemPm. (A DataSet may be substituted for the CovarianceMatrix.) Uses regression to do the estimation, so this is only for DAG models. But the DAG model may be reset on the fly and the estimation redone. Variables whose parents have not changed will not be reestimated. Intended to speed up estimation for algorithm that require repeated estimation of DAG models over the same variables. Assumes all variables are measured.
Version:
$Id: $Id
Author:
josephramsey
See Also:
  • Constructor Details

    • DagScorer

      public DagScorer(DataSet dataSet)
      Constructs a new SemEstimator that uses the specified optimizer.
      Parameters:
      dataSet - a DataSet, all of whose variables are contained in the given SemPm. (They are identified by name.)
    • DagScorer

      public DagScorer(ICovarianceMatrix covMatrix)
      Constructs a new SemEstimator that uses the specified optimizer.
      Parameters:
      covMatrix - a covariance matrix, all of whose variables are contained in the given SemPm. (They are identified by name.)
  • Method Details

    • serializableInstance

      public static Scorer serializableInstance()
      Generates a simple exemplar of this class to test serialization.
      Returns:
      a Scorer object
    • score

      public double score(Graph dag)
      Scores the given DAG using the implemented algorithm.
      Specified by:
      score in interface Scorer
      Parameters:
      dag - the DAG to be scored
      Returns:
      the score of the DAG
    • getCovMatrix

      public ICovarianceMatrix getCovMatrix()

      Getter for the field covMatrix.

      Specified by:
      getCovMatrix in interface Scorer
      Returns:
      a ICovarianceMatrix object
    • toString

      public String toString()

      toString.

      Specified by:
      toString in interface Scorer
      Overrides:
      toString in class Object
      Returns:
      a string representation of the Sem.
    • getFml

      public double getFml()
      The value of the maximum likelihood function for the getModel the model (Bollen 107). To optimize, this should be minimized.
      Specified by:
      getFml in interface Scorer
      Returns:
      a double
    • getBicScore

      public double getBicScore()

      getBicScore.

      Specified by:
      getBicScore in interface Scorer
      Returns:
      BIC score, calculated as chisq - dof. This is equal to getFullBicScore() up to a constant.
    • getChiSquare

      public double getChiSquare()

      getChiSquare.

      Specified by:
      getChiSquare in interface Scorer
      Returns:
      the chi square value for the model.
    • getPValue

      public double getPValue()

      getPValue.

      Specified by:
      getPValue in interface Scorer
      Returns:
      the p-value for the model.
    • getDataSet

      public DataSet getDataSet()

      Getter for the field dataSet.

      Specified by:
      getDataSet in interface Scorer
      Returns:
      a DataSet object
    • getNumFreeParams

      public int getNumFreeParams()

      getNumFreeParams.

      Specified by:
      getNumFreeParams in interface Scorer
      Returns:
      a int
    • getDof

      public int getDof()

      getDof.

      Specified by:
      getDof in interface Scorer
      Returns:
      a int
    • getSampleSize

      public int getSampleSize()

      getSampleSize.

      Specified by:
      getSampleSize in interface Scorer
      Returns:
      a int
    • getMeasuredNodes

      public List<Node> getMeasuredNodes()

      getMeasuredNodes.

      Specified by:
      getMeasuredNodes in interface Scorer
      Returns:
      a List object
    • getSampleCovar

      public Matrix getSampleCovar()

      Getter for the field sampleCovar.

      Specified by:
      getSampleCovar in interface Scorer
      Returns:
      a Matrix object
    • getEdgeCoef

      public Matrix getEdgeCoef()

      Getter for the field edgeCoef.

      Specified by:
      getEdgeCoef in interface Scorer
      Returns:
      a Matrix object
    • getErrorCovar

      public Matrix getErrorCovar()

      Getter for the field errorCovar.

      Specified by:
      getErrorCovar in interface Scorer
      Returns:
      a Matrix object
    • getVariables

      public List<Node> getVariables()

      Getter for the field variables.

      Specified by:
      getVariables in interface Scorer
      Returns:
      a List object
    • getEstSem

      public SemIm getEstSem()

      getEstSem.

      Specified by:
      getEstSem in interface Scorer
      Returns:
      a SemIm object