Description Usage Arguments Examples
The function plots an hclust
tree with branches and leaves colored
based on group membership. The groups span the covariate indices {1, ..., nvars
}.
Covariates from the same group share equal coefficient (beta
), and sibling
groups have different coefficients. The function determines groups based on
the sparsity in gamma
. In an hclust
tree with beta[i]
on the
i
th leaf, the branch and leaf are colored in blue, red or gray according to beta[i]
being positive, negative or zero, respectively. The larger the magnitude of beta[i]
is,
the darker the color will be. So branches and leaves from the same group will have the
same color.
1 | group.plot(beta, gamma, A, hc, nbreaks = 20)
|
beta |
Length- |
gamma |
Length- |
A |
|
hc |
An |
nbreaks |
Number of breaks in binning |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ## 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)
# Visualize the groups at optimal beta and gamma
ibest.lambda <- ourfit.cv$ibest[1]
ibest.alpha <- ourfit.cv$ibest[2]
beta.opt <- ourfit$beta[[ibest.alpha]][, ibest.lambda]
gamma.opt <- ourfit$gamma[[ibest.alpha]][, ibest.lambda] # works if ibest.alpha > 1
# Visualize the groups at optimal beta and gamma
group.plot(beta.opt, gamma.opt, ourfit$A, data.hc)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.