Class CamAdditivePsplineBic

java.lang.Object
edu.cmu.tetrad.search.score.CamAdditivePsplineBic
All Implemented Interfaces:
AdditiveLocalScorer

public final class CamAdditivePsplineBic extends Object implements AdditiveLocalScorer

CAM scorer using penalized cubic B-splines (P-splines; Eilers & Marx).

  • Main effects only (additive model), one smooth per parent: fy(xj).
  • For each parent, builds a cubic B-spline basis with M basis functions.
  • Penalizes second differences of coefficients with D2T D2 and smoothing λ.
  • Fits by backfitting on partial residuals; chooses λj by GCV over a logarithmic grid.
  • Score is BIC with effective degrees of freedom Σj tr(Hj) + 1 (intercept).

No external dependencies; uses EJML for linear algebra.

  • Constructor Details

    • CamAdditivePsplineBic

      public CamAdditivePsplineBic(DataSet raw)
      Constructs an instance of CamAdditivePsplineBic. Initializes fields and buffers from the provided dataset.
      Parameters:
      raw - the input dataset containing variables and observations; must not be null
  • Method Details

    • setNumBasis

      public CamAdditivePsplineBic setNumBasis(int m)
      Sets the number of basis functions, ensuring a minimum value of 4. Updates the internal state of the object with the specified number of basis functions.
      Parameters:
      m - the requested number of basis functions; must be a positive integer
      Returns:
      the current instance of CamAdditivePsplineBic, allowing for method chaining
    • setPenaltyOrder

      public CamAdditivePsplineBic setPenaltyOrder(int d)
      Sets the penalty order for the P-spline model. The penalty order determines the smoothness of the fitted spline. The value is constrained to be between 1 and 3 (inclusive).
      Parameters:
      d - the desired penalty order; values outside the range [1, 3] will be clamped to the nearest bound
      Returns:
      the current instance of CamAdditivePsplineBic, allowing for method chaining
    • setRidge

      public CamAdditivePsplineBic setRidge(double r)
      Sets the ridge parameter for the P-spline model to control the amount of regularization. The ridge parameter is constrained to be non-negative, and values below 0.0 are clamped to 0.0.
      Specified by:
      setRidge in interface AdditiveLocalScorer
      Parameters:
      r - the desired ridge parameter; if negative, it will be set to 0.0
      Returns:
      the current instance of CamAdditivePsplineBic, enabling method chaining
    • setPenaltyDiscount

      public CamAdditivePsplineBic setPenaltyDiscount(double c)
      Sets the penalty discount parameter for the P-spline model. The penalty discount is a factor that adjusts the balance between the smoothness penalty and goodness-of-fit during spline estimation.
      Specified by:
      setPenaltyDiscount in interface AdditiveLocalScorer
      Parameters:
      c - the desired penalty discount value
      Returns:
      the current instance of CamAdditivePsplineBic, enabling method chaining
    • setMaxBackfitIters

      public CamAdditivePsplineBic setMaxBackfitIters(int it)
      Sets the maximum number of iterations for the backfitting process. Ensures that the number of iterations is at least 1.
      Parameters:
      it - the desired maximum number of backfitting iterations; values less than 1 are clamped to 1
      Returns:
      the current instance of CamAdditivePsplineBic, enabling method chaining
    • setTol

      public CamAdditivePsplineBic setTol(double t)
      Sets the tolerance value for the P-spline model, ensuring it is not lower than 1e-8. The tolerance typically controls the precision in iterative processes or convergence criteria.
      Parameters:
      t - the desired tolerance value; values below 1e-8 will be clamped to 1e-8
      Returns:
      the current instance of CamAdditivePsplineBic, allowing for method chaining
    • localScore

      public double localScore(Node y, Collection<Node> parents)
      Local score: BIC(Y | parents) under additive P-splines, with λ_j by GCV via backfitting.
      Specified by:
      localScore in interface AdditiveLocalScorer
      Parameters:
      y - the target node for which to compute the local score
      parents - the parent nodes of the target node
      Returns:
      the local score for the given node and its parents
    • localScore

      public double localScore(int yIndex, int... parentIdxs)
      Calculates the Bayesian Information Criterion (BIC)-based score for a target variable given its index and optional parent variable indices. It is used to evaluate the fit and complexity of a statistical model.
      Specified by:
      localScore in interface AdditiveLocalScorer
      Parameters:
      yIndex - the index of the target variable.
      parentIdxs - the indices of the parent variables (optional, can be empty or null).
      Returns:
      the calculated BIC score for the given target and parent variables.