Class BasisFunctionBicScoreFullSample

java.lang.Object
edu.cmu.tetrad.search.score.BasisFunctionBicScoreFullSample
All Implemented Interfaces:
Score

public class BasisFunctionBicScoreFullSample extends Object implements Score
Calculates the basis function BIC score for a given dataset. This is a generalization of the Degenerate Gaussian score by adding basis functions of the continuous variables and retains the function of the degenerate Gaussian for discrete variables by adding indicator variables per category.

This version uses a tabular approach to calculate the score rather than using covariance matrices.

Author:
josephramsey, bryanandrews
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    BasisFunctionBicScoreFullSample(DataSet dataSet, int truncationLimit, double lambda)
    Constructs a BasisFunctionBicScore object with the specified parameters.
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.ejml.simple.SimpleMatrix
    computeOLS(org.ejml.simple.SimpleMatrix B, org.ejml.simple.SimpleMatrix X, double lambda)
    Computes the Ordinary Least Squares (OLS) regression coefficients with L2 regularization.
    int
    Retrieves the maximum degree from the underlying BIC score component.
    int
    Retrieves the sample size from the underlying BIC score component.
    Retrieves the list of nodes representing the variables in the basis function score.
    boolean
    isEffectEdge(double bump)
    Determines if the given bump value represents an effect edge.
    double
    localScore(int i, int... parents)
    Calculates the local score for a given node and its parent nodes.
    double
    localScoreDiff(int x, int y, int[] z)
    Returns the score difference of the graph.
    void
    setDoOneEquationOnly(boolean doOneEquationOnly)
    When calculation the score for X = <X1 = X, X2, X3,..., Xp> use the equation for X1 only, if true; otherwise, use equations for all of X1, X2,...,Xp.
    void
    setPenaltyDiscount(double penaltyDiscount)
    Sets the penalty discount value, which is used to adjust the penalty term in the BIC score calculation.
    Returns a string representation of the BasisFunctionBicScore object.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface edu.cmu.tetrad.search.score.Score

    append, determines, getVariable, localScore, localScore, localScoreDiff
  • Constructor Details

    • BasisFunctionBicScoreFullSample

      public BasisFunctionBicScoreFullSample(DataSet dataSet, int truncationLimit, double lambda)
      Constructs a BasisFunctionBicScore object with the specified parameters.
      Parameters:
      dataSet - the data set on which the score is to be calculated. May contain a mixture of discrete and continuous variables.
      truncationLimit - the truncation limit of the basis.
      lambda - Singularity lambda
      See Also:
  • Method Details

    • computeOLS

      public static org.ejml.simple.SimpleMatrix computeOLS(org.ejml.simple.SimpleMatrix B, org.ejml.simple.SimpleMatrix X, double lambda)
      Computes the Ordinary Least Squares (OLS) regression coefficients with L2 regularization.
      Parameters:
      B - The design matrix where each row represents a sample and each column represents a feature.
      X - The matrix containing the target values for corresponding samples.
      lambda - The regularization parameter to control overfitting (L2 regularization).
      Returns:
      A matrix representing the OLS regression coefficients.
    • localScore

      public double localScore(int i, int... parents)
      Calculates the local score for a given node and its parent nodes.
      Specified by:
      localScore in interface Score
      Parameters:
      i - The index of the node whose score is being calculated.
      parents - The indices for the parent nodes of the given node.
      Returns:
      The calculated local score as a double value.
    • localScoreDiff

      public double localScoreDiff(int x, int y, int[] z)
      Description copied from interface: Score
      Returns the score difference of the graph.
      Specified by:
      localScoreDiff in interface Score
      Parameters:
      x - A node.
      y - TAhe node.
      z - A set of nodes.
      Returns:
      The score difference.
    • getVariables

      public List<Node> getVariables()
      Retrieves the list of nodes representing the variables in the basis function score.
      Specified by:
      getVariables in interface Score
      Returns:
      a list containing the nodes that represent the variables in the basis function score.
    • isEffectEdge

      public boolean isEffectEdge(double bump)
      Determines if the given bump value represents an effect edge.
      Specified by:
      isEffectEdge in interface Score
      Parameters:
      bump - the bump value to be evaluated.
      Returns:
      true if the bump is an effect edge, false otherwise.
    • getSampleSize

      public int getSampleSize()
      Retrieves the sample size from the underlying BIC score component.
      Specified by:
      getSampleSize in interface Score
      Returns:
      the sample size as an integer
    • getMaxDegree

      public int getMaxDegree()
      Retrieves the maximum degree from the underlying BIC score component.
      Specified by:
      getMaxDegree in interface Score
      Returns:
      the maximum degree as an integer.
    • toString

      public String toString()
      Returns a string representation of the BasisFunctionBicScore object.
      Specified by:
      toString in interface Score
      Overrides:
      toString in class Object
      Returns:
      A string detailing the degenerate Gaussian score penalty with the penalty discount formatted to two decimal places.
    • setPenaltyDiscount

      public void setPenaltyDiscount(double penaltyDiscount)
      Sets the penalty discount value, which is used to adjust the penalty term in the BIC score calculation.
      Parameters:
      penaltyDiscount - The multiplier on the penalty term for this score.
    • setDoOneEquationOnly

      public void setDoOneEquationOnly(boolean doOneEquationOnly)
      When calculation the score for X = <X1 = X, X2, X3,..., Xp> use the equation for X1 only, if true; otherwise, use equations for all of X1, X2,...,Xp.
      Parameters:
      doOneEquationOnly - True if only the equation for X1 is to be used for X = X1,...,Xp. *