Replaces the data in a flash object with a new set of observations. Estimates of residual variances and the ELBO are also updated.
flash_update_data(flash, newdata, Y2_diff = NULL)
A flash
or flash_fit
object.
The new observations. Can be a matrix, a sparse matrix of
class Matrix
, or a low-rank matrix representation.
Optionally, users can supply the (summed) changes in the
squared values of the data \(y_{ij}^2\), which are needed to estimate the
residual variance parameters \(s_{ij}^2\) for simple variance structures
(i.e., when var_type
is set to 0, 1, or 2). If calculating
entries \(y_{ij}^2\) from scratch is expensive, supplying an argument
to Y2_diff
can greatly speed up data updates. If specified, the
argument should be a scalar
\(\sum_{i, j} \left( y_{ij}^{2 \text{(new)}} - y_{ij}^{2 \text{(old)}} \right)\)
when var_type = 0
; a vector of length \(n\) with entries
\(\sum_{j = 1}^p \left( y_{ij}^{2 \text{(new)}} - y_{ij}^{2 \text{(old)}} \right)\)
when var_type = 1
; or a vector of length \(p\) with entries
\(\sum_{i = 1}^n \left( y_{ij}^{2 \text{(new)}} - y_{ij}^{2 \text{(old)}} \right)\)
when var_type = 2
. The argument is ignored when any other variance
structure is used.
The flash
object from argument flash
, with
the data modified as specified by newdata
. Residual variances and
ELBO are also updated.