Class IndTestGin.OlsRidge

java.lang.Object
edu.cmu.tetrad.search.test.IndTestGin.OlsRidge
All Implemented Interfaces:
IndTestGin.Regressor
Enclosing class:
IndTestGin

public static final class IndTestGin.OlsRidge extends Object implements IndTestGin.Regressor
Represents a ridge-regularized ordinary least squares (OLS) regressor. This implementation combines standard least-squares regression with a ridge penalty to enhance numerical stability and address multicollinearity when solving the regression problem.

This class implements the Regressor interface, providing methods to compute residuals and return a descriptive name for the regressor.

  • Constructor Summary

    Constructors
    Constructor
    Description
    OlsRidge(double ridge)
    Constructs an instance of OlsRidge with the specified ridge parameter.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the name of the regression model, including the ridge parameter value.
    double[]
    residuals(double[] target, double[][] predictors)
    Computes the residuals of a regression model by fitting the target values to the predictors using a least-squares approach with ridge stabilization.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • OlsRidge

      public OlsRidge(double ridge)
      Constructs an instance of OlsRidge with the specified ridge parameter.
      Parameters:
      ridge - The ridge regression parameter, which is used to control the regularization strength in ridge regression. A higher value indicates stronger regularization to prevent overfitting.
  • Method Details

    • name

      public String name()
      Returns the name of the regression model, including the ridge parameter value.
      Specified by:
      name in interface IndTestGin.Regressor
      Returns:
      A string representing the name of the model in the format "OLS(ridge={value})", where {value} is the ridge parameter used in the model.
    • residuals

      public double[] residuals(double[] target, double[][] predictors)
      Computes the residuals of a regression model by fitting the target values to the predictors using a least-squares approach with ridge stabilization. The predictors are standardized, and an intercept is included in the model. If no predictors are provided, the residuals are calculated based on the mean of the target values.
      Specified by:
      residuals in interface IndTestGin.Regressor
      Parameters:
      target - The array of target values (dependent variable) for the model.
      predictors - The 2D array of predictors (independent variables) used in the regression. Each row corresponds to a data point, and each column corresponds to a predictor variable.
      Returns:
      An array of residuals, calculated as the difference between the target values and the predicted values, centered around zero.