View source: R/flash_add_intercept.R
flash_add_intercept | R Documentation |
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 k = 1
,
a fixed set of loadings gives:
\mathbf{y}_{i \cdot} \approx \mathbf{f}_1 + \sum_{k = 2}^K \ell_{i k}
\mathbf{f}_k,
so that the (estimated) factor \mathbf{f}_1 \in \mathbf{R}^p
is shared
by all row-wise observations \mathbf{y}_{i \cdot} \in \mathbf{R}^p
.
A fixed factor gives:
\mathbf{y}_{\cdot j} \approx \boldsymbol{\ell}_1 + \sum_{k = 2}^K f_{j k}
\boldsymbol{\ell}_k,
so that the (estimated) set of loadings \ell_1 \in \mathbf{R}^n
is
shared by all column-wise observations y_{\cdot j} \in \mathbf{R}^n
.
flash_add_intercept(flash, rowwise = TRUE, ebnm_fn = ebnm_point_normal)
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 |
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
.
The flash
object from argument flash
, with an
"intercept" added.
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.