group.recover: Recover aggregated groups of leaf indices

Description Usage Arguments Value Examples

Description

The function finds aggregated groups of leaf indices by traversing non-zero gamma elements and finding descendant leaves at each gamma element. In our problem, gamma are latent variables corresponding to tree nodes. The order of the traversal is post-order, i.e., a node is visited after its descendants.

Usage

1
group.recover(gamma, A, postorder = seq(ncol(A)))

Arguments

gamma

Length-nnodes latent variable coefficients. Note that rarefit returns NA as gamma value when alpha is zero, in which case our problem becomes the lasso on beta.

A

nvars-by-nnodes binary matrix encoding ancestor-descendant relationships between leaves and nodes in the tree.

postorder

Length-nnodes integer vector encoding post-order traversal of the tree nodes such that seq(nnodes)[postorder] ensures a node appear after its descendants. Default is seq(nnodes), which gives post-order when A is generated using tree.matrix for an hclust tree.

Value

Returns a list of recovered groups of leaf indices.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## Not run: 
# See vignette for more details.
set.seed(100)
ts <- sample(1:length(data.rating), 400) # Train set indices
# Fit the model on train set
ourfit <- rarefit(y = data.rating[ts], X = data.dtm[ts, ], hc = data.hc, lam.min.ratio = 1e-6,
                  nlam = 20, nalpha = 10, rho = 0.01, eps1 = 1e-5, eps2 = 1e-5, maxite = 1e4)
# Cross validation
ourfit.cv <- rarefit.cv(ourfit, y = data.rating[ts], X = data.dtm[ts, ],
                        rho = 0.01, eps1 = 1e-5, eps2 = 1e-5, maxite = 1e4)
# Group recovered at optimal beta and gamma
ibest.lambda <- ourfit.cv$ibest[1]
ibest.alpha <- ourfit.cv$ibest[2]
gamma.opt <- ourfit$gamma[[ibest.alpha]][, ibest.lambda] # works if ibest.alpha > 1
groups.opt <- group.recover(gamma.opt, ourfit$A)

## End(Not run)

rare documentation built on May 1, 2019, 9:17 p.m.