flash_init: Initialize flash object

View source: R/flash_init.R

flash_initR Documentation

Initialize flash object

Description

Sets up a flash object with no factors. Since all other flash_xxx functions take a flash or flash_fit object as their first argument, calling flash_init should be the first step in any flash pipeline. See flash for examples of usage.

Usage

flash_init(data, S = NULL, var_type = 0L, S_dim = NULL)

Arguments

data

The observations. Usually a matrix, but can also be a sparse matrix of class Matrix or a low-rank matrix representation as returned by, for example, svd, irlba, rsvd, or softImpute (in general, any list that includes fields u, d, and v will be interpreted as a low-rank matrix representation).

S

The standard errors. Can be NULL (in which case all residual variance will be estimated) or a matrix, vector, or scalar. S should be a scalar if standard errors are identical across observations. It should be a vector if standard errors either vary across columns but are constant within any given row, or vary across rows but are constant within any given column (flash will use the length of the vector to determine whether the supplied values correspond to rows or columns; if the data matrix is square, then the sense must be specified using parameter S_dim in function flash_init).

var_type

Describes the structure of the estimated residual variance. Can be NULL, 0, 1, 2, or c(1, 2). If NULL, then S accounts for all residual variance. If var_type = 0, then the estimated residual variance (which is added to any variance given by S) is assumed to be constant across all observations. Setting var_type = 1 estimates a single variance parameter for each row; var_type = 2 estimates one parameter for each column; and var_type = c(1, 2) optimizes over all rank-one matrices (that is, it assumes that the residual variance parameter s_{ij} can be written s_{ij} = a_i b_j, where the n-vector a and the p-vector b are to be estimated).

Note that if any portion of the residual variance is to be estimated, then it is usually faster to set S = NULL and to let flash estimate all of the residual variance. Further, var_type = c(1, 2) is typically much slower than other options, so it should be used with care.

S_dim

If the argument to S is a vector and the data matrix is square, then S_dim must specify whether S encodes row-wise or column-wise standard errors. More precisely, if S_dim = 1, then S will be interpreted as giving standard errors that vary across rows but are constant within any particular row; if S_dim = 2, then it will be interpreted as giving standard errors that vary across columns but are constant within any particular column. If S is a matrix or scalar, or if the data matrix is not square, then S_dim should be left unspecified (NULL).

Value

An initialized flash object (with no factors).


flashier documentation built on Oct. 17, 2023, 5:07 p.m.