Fill the missing values of obj with one draw from a finalized fit.
Arguments
- x
A
si_miobject. A finalized fit, frommipca(),mipca_fit()ormipca_finalize().- ...
Not used.
- draw
Integer. The kept draw that fills the missing values, from
1to the number of kept draws. Defaults to1.
Details
The completed matrix. A completed matrix is obj with its missing values
filled by one draw, on the scale of obj. The observed values are unchanged,
and the row and column names are kept. A fit made with subset gives a
matrix of the selected columns only.
Which draws. print() shows the number of kept draws. They are numbered
chain by chain: with k draws per chain, draws 1 to k are the first
chain's, k + 1 to 2 * k the second's, and so on.
Multiple imputation. Call as.matrix() once per draw. Draws evenly
spaced from the first to the last are spread across the chains. Each
completed matrix is a full copy of obj, so m of them take m times its
memory. On a large obj, use each matrix in turn instead of keeping all of
them.
Refusals. A resumable fit, made with keep_state = TRUE, is refused.
Finalize it with mipca_finalize() first.
[ does not work on a finalized fit: choose the columns with subset when fitting, or subset a completed matrix.
See also
mipca()to make a finalized fit.mipca_finalize()to finalize a resumable fit.
Examples
set.seed(1)
sim <- sim_mat(n = 50, p = 20, beta = TRUE)
fit <- mipca(sim$input, rank = 2, transform = "logit_biwhiten", seed = 1)
fit
#> si_mi fit: 50 x 20, 100 imputed cells, 400 draws
#> next: as.matrix() with 'draw' for a completed matrix, summary() for Rhat and ESS
# The matrix completed by draw 10
x10 <- as.matrix(fit, draw = 10)
# Five completed matrices, at draws spread over the 400 kept
b <- round(seq(1, 400, length.out = 5))
completed <- lapply(b, function(d) as.matrix(fit, draw = d))