pyacs.gts.lib.l1trend.l1trend2d module

2D L1-trend filtering using CVXPY.

This module provides 2D L1-trend filtering functionality with support for modern CVXPY solvers including the new default Clarabel solver.

pyacs.gts.lib.l1trend.l1trend2d.find_optimal_lambda(Y, lambda_range=None, method='cross_validation', cv_folds=5, solver='CLARABEL', verbose=False)[source]

Find the optimal lambda value for L1-trend filtering using various criteria.

Parameters:
  • Y (array_like) – Input data of shape (T, 2)

  • lambda_range (array_like, optional) – Range of lambda values to test. If None, uses a logarithmic range.

  • method (str, optional) – Method to use for optimization. Options: ‘cross_validation’, ‘aic’, ‘bic’, ‘gcv’

  • cv_folds (int, optional) – Number of folds for cross-validation

  • solver (str, optional) – Solver to use for optimization

  • verbose (bool, optional) – Whether to print progress information

Returns:

  • float – Optimal lambda value

  • dict – Dictionary containing optimization results

pyacs.gts.lib.l1trend.l1trend2d.l1_trendfilter_2d(Y, lam=1.0, solver='CLARABEL', verbose=False, scs_kwargs=None, clarabel_kwargs=None, warm_start=None)[source]
pyacs.gts.lib.l1trend.l1trend2d.plot_lambda_selection(results, title=None)[source]

Plot lambda selection results.

Parameters:
  • results (dict) – Results from find_optimal_lambda

  • title (str, optional) – Title for the plot

pyacs.gts.lib.l1trend.l1trend2d.second_diff_matrix(n)[source]

Generate the second difference matrix for L1-trend filtering.

Parameters:

n (int) – Size of the matrix

Returns:

Second difference matrix of shape (n-2, n)

Return type:

numpy.ndarray