group.recover function

Recover aggregated groups of leaf indices

Recover aggregated groups of leaf indices

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.

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.

Returns

Returns a list of recovered groups of leaf indices.

Examples

## 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)
  • Maintainer: Xiaohan Yan
  • License: GPL-3
  • Last published: 2018-08-03