forked from gabraham/flashpca
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcv.scca.Rd
87 lines (72 loc) · 2.12 KB
/
cv.scca.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/scca.R
\name{cv.scca}
\alias{cv.scca}
\title{Cross-validated grid search over SCCA penalties}
\usage{
cv.scca(
X,
Y,
lambda1 = seq(1e-06, 0.001, length = 5),
lambda2 = seq(1e-06, 0.001, length = 5),
ndim = 3,
nfolds = 10,
folds = NULL,
opt.dim = 1,
parallel = FALSE,
init = TRUE,
verbose = FALSE,
...
)
}
\arguments{
\item{X}{A numeric matrix. The use of PLINK datasets is currently not
supported.}
\item{Y}{A numeric matrix}
\item{lambda1}{A numeric vector of non-negative penalties}
\item{lambda2}{A numeric vector of non-negative penalties}
\item{ndim}{Integer. The number of dimensions to infer.}
\item{nfolds}{Integer. The number of cross-validation folds.}
\item{folds}{A numeric vector of integers. The indices of the folds to use}
\item{opt.dim}{Integer. Which dimension to select the optimal penalties
for.}
\item{parallel}{Logical. Whether to parallelise the cross-validation using
the foreach package.}
\item{init}{Logical. Whether to initialise SCCA with the SVD of X'Y.}
\item{verbose}{Logical. Whether to print more information.}
\item{...}{Other arguments that will be passed to \code{scca}.}
}
\value{
\code{cv.scca} returns an array containing the average
cross-validated canonical Pearson correlations between X and Y, as follows:
Dimension 1: the ndim different canonical dimensions;
Dimension 2: along the lambda1 penalties;
Dimension 3: along the lambda2 penalties.
}
\description{
Cross-validated grid search over SCCA penalties
}
\details{
Note that the default penalties may not be appropriate for every dataset
and for some values the algorithm may not converge (especially for small
penalties).
}
\examples{
#######################
## HapMap3 chr1 example
data(hm3.chr1)
X <- scale2(hm3.chr1$bed)
n <- nrow(X)
m <- ncol(X)
k <- 5
B <- matrix(stats::rnorm(m * k), m, k)
Y <- X \%*\% B + stats::rnorm(n * k)
r <- cv.scca(X, Y,
standx = "sd", standy = "sd", nfolds = 3, ndim = 2,
lambda1 = seq(1e-3, 1e-1, length = 10),
lambda2 = seq(1e-4, 0.5, length = 8)
)
par(mfrow = c(1, 2))
plot(r, dim = 1)
plot(r, dim = 2)
}