-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmmpca.Rd
111 lines (99 loc) · 3.54 KB
/
mmpca.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/mmpca.R
\name{mmpca}
\alias{mmpca}
\title{Multiview principal component analysis}
\usage{
mmpca(
x,
inds,
k,
lambda = NULL,
trace = 0,
max_iter = 20000,
init_theta = NULL,
cachepath = NULL,
enable_rank_selection = TRUE,
enable_sparsity = TRUE,
enable_variable_selection = FALSE,
parallel = TRUE
)
}
\arguments{
\item{x}{List of matrices to analyze}
\item{inds}{Matrix containing view indices. The matrix should have two
columns and the same number of rows as the length of \code{x}. The first
(second) column contains the view index of the rows (columns) of the
corresponding matrix.}
\item{k}{Integer giving the maximum rank of the analysis, i.e. the maximum
number of principal components for each view.}
\item{lambda}{Vector or matrix of lambda values. The length (or width if it
is a matrix) depends on the number of active penalties (2, 3 or 4). If it
is a matrix, try different lambda values (one try for each row). Default: a
matrix where each column is the sequence \code{exp(seq(-6, 0)))}.}
\item{trace}{Integer selecting the amount of log messages. 0 (default): no
output, 3: all output.}
\item{max_iter}{Maximum number of iterations}
\item{init_theta}{NULL, functions or numeric. NULL (default) use initial
values based on ordinary SVD. If init_theta is a list of three functions
(\code{CMF}, \code{matrix_to_triplets} and \code{getCMFopts} from package
\code{CMF}) use the supplied functions to find initial values with
collaborative matrix factorization (CMF). If init_theta is a numeric vector
it is used as initial value.}
\item{cachepath}{Character vector with path to directory to store
intermediate results. If NULL (default) intermediate results are not
stored. For caching to work it is required that the random number
generation seed is constant between calls to mmpca, so \code{set.seed}
needs to be called before mmpca.}
\item{enable_rank_selection}{Boolean deciding if the second penalty that
imposes a low rank model should be enabled.}
\item{enable_sparsity}{Boolean deciding if the third penalty that imposes
sparsity in V should be enabled.}
\item{enable_variable_selection}{Boolean deciding if the fourth penalty that
increases the tendency for sparsity structure of different V columns to be
similar. Defaults to FALSE meaning this penalty is not used.}
\item{parallel}{Boolean deciding if computations should be run on multiple
cores simultaneously.}
}
\value{
A list with components
\item{initial}{initial values used in optimization}
\item{cmf}{solution found with CMF (if init_theta == c(CMF,
matrix_to_triplets, getCMFopts))}
\item{training}{solutions for different values of lambda}
\item{solution}{solution for optimal lambda value}
}
\description{
Analyzes several related matrices of data.
}
\examples{
# Create model with three views, two data matrices of low-rank 3
max_rank <- 3
v <- list(
qr.Q(qr(matrix(rnorm(10 * max_rank), 10, max_rank))),
qr.Q(qr(matrix(rnorm(11 * max_rank), 11, max_rank))),
qr.Q(qr(matrix(rnorm(12 * max_rank), 12, max_rank)))
)
d <- matrix(
c(1, 1, 1, 1, 1, 0, 1, 0, 1),
nrow = max_rank, ncol = 3
)
x <- list(
v[[1]] \%*\% diag(d[, 1] * d[, 2]) \%*\% t(v[[2]]),
v[[1]] \%*\% diag(d[, 1] * d[, 3]) \%*\% t(v[[3]])
)
inds <- matrix(c(1, 1, 2, 3), 2, 2)
result <- mmpca::mmpca(
x, inds, max_rank, parallel = FALSE,
lambda = c(1e-3, 1e-5), enable_sparsity = FALSE,
trace = 3
)
# Investigate the solution
result$solution$D
}
\author{
Jonatan Kallus, \email{kallus@chalmers.se}
}
\keyword{models}
\keyword{multivariate}
\keyword{pca}