flash_add_greedy | R Documentation |
This implements the greedy algorithm from Wang and
Stephens. It can be used to adds factors to an existing fit, or
start from scratch. It adds factors iteratively, at each stage
adding a new factor and then optimizing it. It is "greedy" in that
it does not return to re-optimize previous factors. The function
stops when an added factor contributes nothing, or Kmax is reached.
Each new factor is intialized by applying the function
init_fn
to the residuals after removing previously-fitted
factors.
flash_add_greedy(data, Kmax = 100, f_init = NULL,
var_type = c("by_column", "by_row", "constant", "zero", "kroneker"),
init_fn = "udv_si", tol = 0.01, ebnm_fn = "ebnm_pn",
ebnm_param = NULL, verbose = TRUE, nullcheck = TRUE, seed = 123)
data |
An n by p matrix or a flash data object created using
|
Kmax |
The maximum number of factors to be added to the flash object. |
f_init |
The flash object or flash fit object to which new
factors are to be added. If |
var_type |
The type of variance structure to assume for residuals. Options include:
|
init_fn |
The function used to initialize factors. Options include:
A user-specified function can also be used. This function should
take parameters |
tol |
Specifies how much the objective can change in a single iteration to be considered not converged. |
ebnm_fn |
The function used to solve the Empirical Bayes Normal
Means problem. Either a single character string (giving the name of
of the function) or a list with fields
|
ebnm_param |
A named list containing parameters to be passed to
|
verbose |
If |
nullcheck |
If |
seed |
A random number seed to use before running |
A flash object.
l = rnorm(100)
f = rnorm(10)
Y = outer(l, f) + matrix(rnorm(1000), nrow=100)
f = flash_add_greedy(Y,10)
# Gives the weights for each factor (analogue of singular values).
f$ldf$d
# Example to show how to use a different initialization function.
library(softImpute)
f2 = flash_add_greedy(Y, 10, init_fn=function(x, K=1) {
softImpute(x, K, lambda=10)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.