Construct a difference operator, of a given order, for use in trend filtering penalties.

get_diff_mat(p, k)

Arguments

p

Dimension (number of columns) of the difference matrix.

k

Order of the difference matrix.

Value

A sparse matrix of dimension (p - k) x p.