flash_backfit | R Documentation |
Iterates through the factors of a flash fit object, updating each until convergence.
flash_backfit(data, f_init, kset = NULL, var_type = c("by_column",
"by_row", "constant", "zero", "kroneker"), tol = 0.01,
ebnm_fn = "ebnm_pn", ebnm_param = NULL, verbose = TRUE,
nullcheck = TRUE, maxiter = 1000)
data |
An n by p matrix or a flash data object created using
|
f_init |
A flash object or flash fit object to be refined. |
kset |
The indices of factors to be optimized ( |
var_type |
The type of variance structure to assume for residuals. Options include:
|
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 |
maxiter |
A maximum number of iterations to perform (not
including repeated fittings if |
A flash object.
LL = matrix(rnorm(200), ncol=2) # simulate some rank 2 data
FF = matrix(rnorm(20), nrow=2)
Y = LL %*% FF + matrix(rnorm(1000), nrow=100)
fg = flash_add_greedy(Y, 10)
fb = flash_backfit(Y, fg) # refines fit from greedy by backfitting
fb$ldf$d
# Example to illustrate different types of arguments to ebnm_param.
# 1. Fix a N(0, 1) prior on the loadings.
ebnm_param_l = list(g=ashr::normalmix(1,0,1), fixg=TRUE)
fg2 = flash_add_greedy(Y, 10, ebnm_fn="ebnm_ash",
ebnm_param=list(l=ebnm_param_l, f=list()))
# 2. Now refit factors, forcing loadings to use prior from greedy fit.
ebnm_param_f = lapply(fg2$gf, function(g) {list(g=g, fixg=TRUE)})
fb2 = flash_backfit(Y, fg2, kset=1:2, ebnm_fn="ebnm_ash",
ebnm_param=list(l=list(), f=ebnm_param_f))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.