get_B: Given Y, H, and W, optimize B coordinate descent

Description Usage Arguments Value Examples

View source: R/RcppExports.R

Description

This is minimizing ||Y - HBW^T||_2^2 over B, with all other matrices assumed known.

Usage

1
get_B(Y, H, W, B0, nu = 1e-05, n_iter = 100L)

Arguments

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.)

W

The samples-to-latent-source coefficients matrix, assumed known.

nu

The learning rate for the coordinate descent. Arbitrarily defaults to 1e-3.

n_iter

The number of sweeps over all entries of B via coordinate descent.

Value

A list with the following elements,
$obj The RSS after each update to an entry of B.
$B The optimized value of B.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# generate data
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)
B_res <- get_B(Y, H, W, B0)

krisrs1128/LFExpers documentation built on May 20, 2019, 1:25 p.m.