getD2d: Helper functions for constructing generalized lasso penalty...

View source: R/getD2d.R

getDxxR Documentation

Helper functions for constructing generalized lasso penalty matrices

Description

These are utility functions for creating penalty matrices for the fused lasso and trend filtering problems. Most users will not need to explicitly construct these as they are created internally by the fusedlasso or trendfilter functions. The sparse variants output sparse matrices, which should be used whenever possible because of a significant savings in both construction speed and memory usage.

The function getGraph is an inverse function for fused lasso problems, returning an igraph object (from the igraph package), the graph corresponding to the passed penalty matrix.

Usage

getD1d(n)
getD1dSparse(n)
getD2d(dim1, dim2)
getD2dSparse(dim1, dim2)
getDg(graph)
getDgSparse(graph)
getDtf(n, ord)
getDtfSparse(n, ord) 
getDtfPos(n, ord, pos)
getDtfPosSparse(n, ord, pos)
getGraph(D)

Arguments

The arguments for the sparse variants are identical to those for the regular variants, which are described below.

n

for getD1d, getDtf, and getDtfPos, the number of points in the 1d sequence.

dim1, dim2

for getD2d, the number of rows and columns in the 2d grid, respectively.

graph

for getDg, an igraph object from the igraph package, upon which the penalty matrix should be based (the penalty matrix is the oriented incidence matrix of the graph, with arbitrary orientations assigned to each edge).

ord

for getDtf, and getDtfPos, the order of the polynomial. E.g., ord=0 is the 1d fused lasso and ord=1 is linear trend filtering. Hence the returned matrix is the discrete (ord+1)st derivative operator.

pos

for getDtfPos, a numeric vector giving the positions of points in the 1d sequence. Must have length n.

D

for getGraph, a fused lasso penalty matrix, the incidence matrix of an undirected graph, with arbitrary edge orientations.

Value

All functions except getGraph return a penalty matrix, either in standard R matrix format or as a sparse matrix of class dgCMatrix via the Matrix package. The function getGraph returns an igraph object from the igraph package.

See Also

fusedlasso, trendfilter

Examples

getD1d(9)
getDtfSparse(10,2)

graph = getGraph(getD2dSparse(4,4))
plot(graph)

genlasso documentation built on Aug. 22, 2022, 9:09 a.m.