lsam: Perform alternating minimization for a latent source model

Description Usage Arguments Value

View source: R/latent_factor.R

Description

This is minimizing ||Y - Phi * W^T||_2^2 + lambda * ||W||_1 over W and Phi, by alternatively minimizing over each term. Note that Phi is fixed across people for each time, which is why it is a shorter dimension than Y. I.e., this model can also be written as y_ijt = phi_t ^ T w_j + noise.

Usage

1
lsam(Y, time_mask, Phi0, n_iter = 10, model_funs = NULL)

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.

time_mask

An N x T matrix, where T is the unique number of time points across all samples, where the it^th entry is 1 is sample i was taken at time i.

Phi0

The initial value of Phi, the basis matrix.

n_iter

The number of iterations to run the alternating minimization.

model_funs

A list of functions that, when given a matrix x and vector y, will return the coefficients of x on y. Must have two elemets "Phi" and "W" for fitting the two parts of the alternating minimization.

Value

A list with the following elements,
$Phi The learned basis matrix across times.
$W The learned coefficients matrix.
$obj The RSS, and l1 / l2 of W across iterations.


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