penalty_matrix: Generate penalty matrix for regularization

View source: R/all_generic.R

penalty_matrixR Documentation

Generate penalty matrix for regularization

Description

Generate a penalty matrix for regularizing HRF basis coefficients. The penalty matrix encodes shape priors that discourage implausible or overly wiggly HRF estimates. Different HRF types use different penalty structures:

  • FIR/B-spline bases: Roughness penalties based on discrete derivatives

  • SPM canonical + derivatives: Differential shrinkage of derivative terms

  • Fourier bases: Penalties on high-frequency components

  • Default: Identity matrix (ridge penalty)

Usage

penalty_matrix(x, ...)

Arguments

x

The HRF object or basis specification

...

Additional arguments passed to specific methods

Details

The penalty matrix R is used in regularized estimation as λ * h^T R h, where h are the basis coefficients and λ is the regularization parameter. Well-designed penalty matrices can significantly improve HRF estimation by encoding smoothness or other shape constraints.

Value

A symmetric positive definite penalty matrix of dimension nbasis(x) × nbasis(x)

See Also

nbasis(), fmrihrf::HRF_objects

Other hrf: fitted_hrf(), nbasis()

Examples

# FIR basis with smoothness penalty
fir_hrf <- HRF_FIR
R_fir <- penalty_matrix(fir_hrf)

# B-spline basis with second-order smoothness
bspline_hrf <- HRF_BSPLINE  
R_bspline <- penalty_matrix(bspline_hrf, order = 2)

# SPM canonical with derivative shrinkage
spmg3_hrf <- HRF_SPMG3
R_spmg3 <- penalty_matrix(spmg3_hrf, shrink_deriv = 4)


bbuchsbaum/fmrireg documentation built on June 10, 2025, 8:18 p.m.