create_constraint_matrix: Create Diffusion Constraint Matrix

View source: R/constraint_matrices.R

create_constraint_matrixR Documentation

Create Diffusion Constraint Matrix

Description

Builds a square constraint matrix K encoding the prior belief that temporally distant tasks should have more orthogonal coefficients. Off-diagonal entries accumulate weight proportional to the distance between task indices, implementing a diffusion-like pattern.

Usage

create_constraint_matrix(numTasks, diag_val = 0.5)

Arguments

numTasks

An integer specifying the number of tasks.

diag_val

A numeric value for the diagonal of K. Default: 0.5. This value is typically overridden during cross-validation (see cv_orthoMTL).

Details

This matrix is passed to orthoMTL via the K argument to control the orthogonality penalty between tasks.

The construction rule: for each distance level h from 1 to numTasks, add 1 to all entries where |row - col| > h. This produces a matrix where nearby tasks (adjacent thresholds) share more support, while distant tasks are pushed toward orthogonality.

For survival analysis with time thresholds, this encodes the assumption that the set of predictive features changes gradually over time rather than abruptly.

Value

A numeric square matrix of dimensions numTasks x numTasks. Off-diagonal entry K[i,j] is larger when tasks i and j are further apart. Diagonal entries are set to diag_val.

See Also

cv_orthoMTL

Examples

# 5-task constraint matrix
K <- create_constraint_matrix(5)
K

# Override diagonal for a specific penalty balance
K <- create_constraint_matrix(7, diag_val = 6)
K

orthoMTL documentation built on Aug. 23, 2026, 5:10 p.m.