|
a |
|
b/man/getNcomp.Rd |
|
|
1 |
% Generated by roxygen2: do not edit by hand |
|
|
2 |
% Please edit documentation in R/getNcomp.R |
|
|
3 |
\name{getNcomp} |
|
|
4 |
\alias{getNcomp} |
|
|
5 |
\title{Get optimal number of components} |
|
|
6 |
\usage{ |
|
|
7 |
getNcomp(object, max.ncomp = NULL, X, Y = NULL, indY = NULL, ...) |
|
|
8 |
} |
|
|
9 |
\arguments{ |
|
|
10 |
\item{object}{A mixOmics object of the class `pca`, `spca`, `mixo_pls`, `mixo_spls`, `block.pls`, `block.spls`} |
|
|
11 |
|
|
|
12 |
\item{max.ncomp}{integer, maximum number of component to include. |
|
|
13 |
If no argument is given, `max.ncomp=object$ncomp`} |
|
|
14 |
|
|
|
15 |
\item{X}{a numeric matrix/data.frame or a list of data.frame for \code{block.pls}} |
|
|
16 |
|
|
|
17 |
\item{Y}{(only for \code{pls}, optional for \code{block.spls}) a numeric matrix, with the same nrow as \code{X}} |
|
|
18 |
|
|
|
19 |
\item{indY}{(optional and only for \code{block.pls}, if Y is not provided), an integer which indicates the position of the matrix response in the list X} |
|
|
20 |
|
|
|
21 |
\item{...}{Other arguments to be passed to methods (pca, pls, block.pls)} |
|
|
22 |
} |
|
|
23 |
\value{ |
|
|
24 |
\code{getNcomp} returns a list with class "ncomp.tune.silhouette" containing the following components: |
|
|
25 |
|
|
|
26 |
\item{ncomp}{a vector containing the tested ncomp} |
|
|
27 |
\item{silhouette}{a vector containing the average silhouette coefficient by ncomp} |
|
|
28 |
\item{dmatrix}{the distance matrix used to compute silhouette coefficient} |
|
|
29 |
} |
|
|
30 |
\description{ |
|
|
31 |
Compute the average silhouette coefficient for a given set of components on a mixOmics result. |
|
|
32 |
Foreach given ncomp, the mixOmics method is performed with the sames arguments and the given `ncomp`. |
|
|
33 |
Longitudinal clustering is performed and average silhouette coefficient is computed. |
|
|
34 |
} |
|
|
35 |
\examples{ |
|
|
36 |
# random input data |
|
|
37 |
demo <- suppressWarnings(get_demo_cluster()) |
|
|
38 |
|
|
|
39 |
# pca |
|
|
40 |
pca.res <- mixOmics::pca(X=demo$X, ncomp = 5) |
|
|
41 |
res.ncomp <- getNcomp(pca.res, max.ncomp = 4, X = demo$X) |
|
|
42 |
plot(res.ncomp) |
|
|
43 |
|
|
|
44 |
# pls |
|
|
45 |
pls.res <- mixOmics::pls(X=demo$X, Y=demo$Y) |
|
|
46 |
res.ncomp <- getNcomp(pls.res, max.ncomp = 4, X = demo$X, Y=demo$Y) |
|
|
47 |
plot(res.ncomp) |
|
|
48 |
|
|
|
49 |
# block.pls |
|
|
50 |
block.pls.res <- suppressWarnings(mixOmics::block.pls(X=list(X=demo$X, Z=demo$Z), Y=demo$Y)) |
|
|
51 |
res.ncomp <- suppressWarnings(getNcomp(block.pls.res, max.ncomp = 4, |
|
|
52 |
X=list(X=demo$X, Z=demo$Z), Y=demo$Y)) |
|
|
53 |
plot(res.ncomp) |
|
|
54 |
|
|
|
55 |
} |
|
|
56 |
\seealso{ |
|
|
57 |
\code{\link{getCluster}}, \code{\link{silhouette}}, \code{\link[mixOmics]{pca}}, \code{\link[mixOmics]{pls}}, \code{\link[mixOmics]{block.pls}} |
|
|
58 |
} |