Iterates through the factors of a flash 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 = flash_default_ebnm_param(ebnm_fn), verbose = FALSE,
  nullcheck = TRUE, maxiter = 1000)

Arguments

data

An n by p matrix or a flash data object created using flash_set_data.

f_init

A fitted flash object to be refined.

kset

The indices of factors to be optimized (NULL indicates all factors).

var_type

The type of variance structure to assume for residuals.

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.

ebnm_param

A named list containing parameters to be passed to ebnm_fn when optimizing; defaults are set by flash_default_ebnm_param().

verbose

If TRUE, various progress updates will be printed.

nullcheck

If TRUE, then after running hill-climbing updates, flash will check whether the achieved optimum is better than setting the factor to 0. If the check is performed and fails then the factor will be set to 0 in the returned fit.

maxiter

A maximum number of iterations to perform (in the inner loop). To perform just one iteration we suggest setting maxiter = 1 and nullcheck = FALSE.

Value

A fitted flash object.

Examples

l = rnorm(100) #simulate some rank 1 data f = rnorm(10) Y = outer(l,f) + matrix(rnorm(1000),nrow=100) fg = flash_add_greedy(Y,10)
#> fitting factor/loading 1
#> fitting factor/loading 2
fb = flash_backfit(Y,fg) # refines fit from greedy by backfitting flash_get_ldf(fb)$d
#> [1] 34.12