View source: R/flash_factors_init.R
flash_factors_init | R Documentation |
Initializes factor/loadings pairs at values specified by init
. This
function has two primary uses: 1. One can initialize multiple
factor/loadings pairs at once using an SVD-like function and then optimize
them via function flash_backfit
. Sometimes this results in
a better fit than adding them one at a time via
flash_greedy
. 2. One can initialize factor/loadings pairs
and then fix the factor (or loadings) via function
flash_factors_fix
to incorporate "known" factors into a
flash
object. See below for examples of both use cases.
flash_factors_init(flash, init, ebnm_fn = ebnm_point_normal)
flash |
A |
init |
An SVD-like object (specifically, a list containing fields
|
ebnm_fn |
The function or functions used to solve the empirical Bayes
normal means (EBNM) subproblems. Most importantly, these functions specify
the families of distributions Any EBNM function provided by package |
The flash
object from argument flash
, with
factors and loadings initialized as specified.
# Initialize several factors at once and backfit.
fl <- flash_init(gtex) %>%
flash_factors_init(init = svd(gtex, nu = 5, nv = 5)) %>%
flash_backfit()
# Add fixed loadings with \ell_i identically equal to one. This can be
# interpreted as giving a "mean" factor that accounts for different
# row-wise means.
ones <- matrix(1, nrow = nrow(gtex), ncol = 1)
# Initialize the factor at the least squares solution.
ls_soln <- t(solve(crossprod(ones), crossprod(ones, gtex)))
fl <- flash_init(gtex) %>%
flash_factors_init(init = list(ones, ls_soln)) %>%
flash_factors_fix(kset = 1, which_dim = "loadings") %>%
flash_backfit() %>%
flash_greedy(Kmax = 5L)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.