fracridge: Fractional Ridge Regression

View source: R/fracridge.R

fracridgeR Documentation

Fractional Ridge Regression

Description

Performs fractional ridge regression, approximating regularization parameters to match desired fractions of the Ordinary Least Squares (OLS) parameter vector length.

Usage

fracridge(X, y, fracs = seq(0.1, 1, by = 0.1), tol = 1e-10)

Arguments

X

A numeric matrix of shape (n, p) representing the design matrix, where n is the number of observations and p is the number of predictors.

y

A numeric vector or matrix of shape (n, b) representing the response variable(s), where b is the number of targets. If y is a vector, it is treated as a single target.

fracs

A numeric vector specifying the desired fractions of the OLS parameter vector length. Must be sorted in increasing order and be between 0 and 1. Default is seq(0.1, 1.0, by = 0.1).

tol

A numeric value specifying the tolerance below which singular values are considered zero. Must be positive. Default is 1e-10.

Details

Fractional ridge regression finds ridge regression solutions where the parameter vector lengths equal specified fractions of the OLS solution length. This is achieved by adjusting the regularization parameter alpha for each target fraction.

The function uses Singular Value Decomposition (SVD) for efficient computation. Singular values below tol are treated as zero, and a warning is issued if rank deficiency is detected.

The regularization path is computed using a grid of alpha values on a log scale, with interpolation used to find the exact alpha values that achieve the target fractions.

Value

An object of class fracridge containing:

coef

A numeric array of shape (p, length(fracs), b) containing the estimated coefficients for each fraction and target. If y is a vector, the third dimension is dropped.

alpha

A numeric matrix of shape (length(fracs), b) containing the regularization parameters associated with each solution.

fracs

The fractions used in the regression.

rank

The effective rank of the design matrix X.

singular_values

The singular values of X.

Examples

## Not run: 
# Generate random data
set.seed(0)
X <- matrix(rnorm(100 * 10), nrow = 100, ncol = 10)
y <- rnorm(100)

# Perform fractional ridge regression
result <- fracridge(X, y, fracs = seq(0.3, 0.9, by = 0.1))

# Inspect the coefficients and regularization parameters
print(result$coef)
print(result$alpha)

# Compare with OLS solution length
ols_coef <- solve(crossprod(X), crossprod(X, y))
ols_norm <- sqrt(sum(ols_coef^2))
coef_norm <- sqrt(colSums(result$coef^2))
print(coef_norm / ols_norm)  # Should approximately equal fracs

## End(Not run)


bbuchsbaum/fmrireg documentation built on March 1, 2025, 11:20 a.m.