flash_add_intercept {flashier} | R Documentation |
Add "intercept" to a flash object
Description
Adds an all-ones vector as a fixed set of loadings (if rowwise = TRUE
)
or fixed factor (if rowwise = FALSE
). Assuming (without loss of
generality) that the fixed factor/loadings is indexed as ,
a fixed set of loadings gives:
so that the (estimated) factor is shared
by all row-wise observations
.
A fixed factor gives:
so that the (estimated) set of loadings is
shared by all column-wise observations
.
Usage
flash_add_intercept(flash, rowwise = TRUE, ebnm_fn = ebnm_point_normal)
Arguments
flash |
A |
rowwise |
Should the all-ones vector be added as a fixed set of loadings ("row-wise") or a fixed factor ("column-wise")? See above for details. |
ebnm_fn |
As with other factor/loadings pairs, a prior is put on the
estimated factor (if |
Details
The estimated factor (if rowwise = TRUE
) or set of loadings
(if rowwise = FALSE
) is initialized at the column-
or row-wise means of the data (or, if factor/loadings pairs have previously
been added, at the column- or row-wise means of the matrix of residuals)
and then backfit via function flash_backfit
.
Value
The flash
object from argument flash
, with an
"intercept" added.
Examples
# The following are equivalent:
init <- list(matrix(rowMeans(gtex), ncol = 1),
matrix(1, nrow = ncol(gtex)))
fl <- flash_init(gtex) %>%
flash_factors_init(init) %>%
flash_factors_fix(kset = 1, which_dim = "factors") %>%
flash_backfit(kset = 1)
fl <- flash_init(gtex) %>%
flash_add_intercept(rowwise = FALSE)