fsml_ridge Interface

public interface fsml_ridge

The multiple linear Ridge regression models the relationship or linear dependence between a dependent (predictand) variable and one or more independent (predictor) variables, incorporating a penalty term on the size of the regression coefficients to reduce multicollinearity and overfitting.

The procedure estimates the linear regression coefficients by minimising the sum of squared residuals plus a penalty proportional to the square of the magnitude of coefficients:

where (lambda) is the ridge penalty parameter, and is the identity matrix with the first diagonal element corresponding to the intercept set to zero (no penalty on intercept).

The estimated regression model is of the form:

where is the predictand variable, are the predictor variables (x) with nd observations, is the y-intercept (b0), (b) are the ridge regression coefficients, and (nv) is the number of predictors (excluding the intercept).

The subroutine constructs a full matrix internally by prepending a column of ones to account for the intercept. The coefficient of determination (r2), predicted values (y_hat), ridge-adjusted standard errors (se) of the coefficients, and the ridge-adjusted covariance matrix of the predictors (cov_b) can optionally be returned. The covariance matrix and standard errors are adjusted for the ridge penalty as:

where is the residual variance estimate.

Note: This subroutine uses eigh from the stdlib_linalg module.

Calls

interface~~fsml_ridge~~CallsGraph interface~fsml_ridge fsml_ridge proc~s_lin_ridge s_lin_ridge interface~fsml_ridge->proc~s_lin_ridge eigh eigh proc~s_lin_ridge->eigh proc~f_sts_mean_core f_sts_mean_core proc~s_lin_ridge->proc~f_sts_mean_core proc~s_err_print s_err_print proc~s_lin_ridge->proc~s_err_print proc~f_utl_r2c f_utl_r2c proc~s_err_print->proc~f_utl_r2c

Module Procedures

public subroutine s_lin_ridge(x, y, nd, nv, lambda, b0, b, r2, y_hat, se, cov_b)

Multiple Linear Ridge Regression (λ >= 0) with intercept.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x(nd,nv)

predictor data matrix (no intercept column)

real(kind=wp), intent(in) :: y(nd)

response vector

integer(kind=i4), intent(in) :: nd

number of datapoints

integer(kind=i4), intent(in) :: nv

number of predictors (excluding intercept)

real(kind=wp), intent(in) :: lambda

ridge penalty parameter (≥ 0, non-optional)

real(kind=wp), intent(out) :: b0

intercept coefficient

real(kind=wp), intent(out) :: b(nv)

predictor coefficients

real(kind=wp), intent(out) :: r2

coefficient of determination R²

real(kind=wp), intent(out), optional :: y_hat(nd)

predicted y values

real(kind=wp), intent(out), optional :: se(nv)

standard errors of predictor coefficients

real(kind=wp), intent(out), optional :: cov_b(nv,nv)

covariance matrix of predictor coefficients