Description Usage Arguments Value Examples
Minimize (over B and W) ||M(Y - HBW')||_2^2 + lambda * ((1 - alpha) ||W||_2^2 + (alpha) * ||W||_1), where M is a masking matrix that ignores terms in Y that are missing. This is just the usual RSS with a basis matrix H plus an elastic net penalty on W. The interpretation is that HB are latent sources and W are coefficients on those latent sources. The sources are expanded in terms of a basis H, which ensures that it is smooth / piecewise linear, ... The masking matrix and the fact that H is not necessarily orthogonal is the reason we have to optimize B using coordinate descent (and can't just reformulate it as another elastic net problem, like in the lsam() function).
1 |
Y |
An N x J real matrix, with censored values set to NA. The standard application we have in mind is the sample x OTU count matrix. |
H |
The spline basis matrix, from which the latent sources arise (as the linear mixture HB.) |
B0 |
The initial matrix for B in the optimization. |
W0 |
The initial matrix for W in the optimization. Usually initialize eigenvectors from SVD. |
opts |
A (potentially only partially specified) list of options to use during the optimization. See merge_spline_lf_opts() for choices. gradient descent. |
W |
The samples-to-latent-source coefficients matrix, assumed known. |
A list with the following elements,
$obj The matrix of terms of the objective function, after each iteration.
of the alternating minimization.
$W The optimized coefficients matrix.
$B The optimized mixing matrix for the sources.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | N <- 150
P <- 20
K <- 5
L <- 6
library("splines")
H <- bs(1:N, df = L, degree = 1)
W <- matrix(rnorm(P * K), P, K)
B <- matrix(rnorm(L * K), L, K)
E <- matrix(.5 * rnorm(N * P), N, P)
Y <- H %*% B %*% t(W) + E
Y[sample(N * P, N * P * .4)] <- NA # 40% missing at random
# fit the model
B0 <- matrix(rnorm(L * K), L, K)
W0 <- matrix(rnorm(P * K), P, K)
spline_fit <- spline_lf(Y, H, B0, W0)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.