Package edu.cmu.tetrad.search.score
Class CamAdditivePsplineBic
java.lang.Object
edu.cmu.tetrad.search.score.CamAdditivePsplineBic
- All Implemented Interfaces:
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 D2and smoothingλ. - Fits by backfitting on partial residuals; chooses
λjby 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 Summary
ConstructorsConstructorDescriptionConstructs an instance of CamAdditivePsplineBic. -
Method Summary
Modifier and TypeMethodDescriptiondoublelocalScore(int yIndex, int... parentIdxs) Calculates the Bayesian Information Criterion (BIC)-based score for a target variable given its index and optional parent variable indices.doublelocalScore(Node y, Collection<Node> parents) Local score: BIC(Y | parents) under additive P-splines, with λ_j by GCV via backfitting.setMaxBackfitIters(int it) Sets the maximum number of iterations for the backfitting process.setNumBasis(int m) Sets the number of basis functions, ensuring a minimum value of 4.setPenaltyDiscount(double c) Sets the penalty discount parameter for the P-spline model.setPenaltyOrder(int d) Sets the penalty order for the P-spline model.setRidge(double r) Sets the ridge parameter for the P-spline model to control the amount of regularization.setTol(double t) Sets the tolerance value for the P-spline model, ensuring it is not lower than 1e-8.
-
Constructor Details
-
CamAdditivePsplineBic
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
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
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
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:
setRidgein interfaceAdditiveLocalScorer- 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
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:
setPenaltyDiscountin interfaceAdditiveLocalScorer- Parameters:
c- the desired penalty discount value- Returns:
- the current instance of
CamAdditivePsplineBic, enabling method chaining
-
setMaxBackfitIters
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
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
Local score: BIC(Y | parents) under additive P-splines, with λ_j by GCV via backfitting.- Specified by:
localScorein interfaceAdditiveLocalScorer- Parameters:
y- the target node for which to compute the local scoreparents- 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:
localScorein interfaceAdditiveLocalScorer- 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.
-