Fit mipca() at a rank from a mipca_tune() table, with the nu, transform
and sampler settings of that tuning run.
Usage
mipca_fit(
object,
obj,
rank = NULL,
...,
chains,
iter_warmup,
iter_sampling,
thin,
spectra,
init,
refresh = 100L,
keep_state = FALSE,
prop_diag = 0.5,
seed = NULL,
nu = NULL,
transform,
abb
)Arguments
- object
A
si_tuneobject. The tablemipca_tune()returns, or a subset of its rows.- obj
A double matrix. The matrix
objectwas tuned on, passed again. The table does not carry it.- rank
Integer or
NULL. A rank inobject. WithNULL, the rank with the lowestcrps. Defaults toNULL.- ...
Not used. Name every argument after
rank.- chains
Integer. Number of independent chains. Taken from
objectwhen left out.- iter_warmup
Integer. Number of iterations discarded at the start of each chain,
0or more. Taken fromobjectwhen left out.- iter_sampling
Integer. Number of draws kept per chain. Taken from
objectwhen left out.- thin
Integer. After warmup, each chain keeps one iteration in every
thin, as inmipca(). Taken fromobjectwhen left out.- spectra
A
spectra_optsobject. Settings for the eigensolver, fromspectra_opts(). Taken fromobjectwhen left out.- init
Numeric. How widely each chain's starting values are spread, as in
mipca(). Taken fromobjectwhen left out.- refresh
Integer. Print a progress line every
refreshiterations of each chain, or0for none. Defaults to100.- keep_state
Logical. If
TRUE, return a fit thatupdate()can extend at the cost of memory. Defaults toFALSE.- prop_diag
Numeric scalar between
0and1. Proportion of each column's missing values on whichsummary()computes Rhat and ESS.0is refused. Defaults to0.5.- seed
Integer, numeric, or
NULL. Seed for the sampler. WithNULL, the seed is drawn from R's random number stream. Defaults toNULL.- nu
Numeric or
NULL. Degrees of freedom of the noise drawn for a missing value, as inmipca(). WithNULL, theimplied_nuofrankinobject, or5if it is lower. Defaults toNULL.- transform, abb
Not used. The fit uses the transform and
abbstored inobject. To change them, runmipca_tune()again, or callmipca().
Value
As mipca(): with keep_state = FALSE, a finalized fit of class
si_mi. With keep_state = TRUE, a resumable fit of class si_mi_pca.
Details
The matrix. obj must be the same matrix object was tuned on. Another
matrix is refused. The held-out values are not held out in the fit: every
observed value of obj is used.
The rank and nu. With rank = NULL, the rank is the one with the
lowest crps among the ranks whose fit did not fail. A given rank must be
in object. When the implied_nu is below 5, the fit uses 5 and a
message says so. A nu that is given is used as it is, with the warning
mipca() gives below 5.
The same fit as mipca(). The fit is the one mipca() returns for the
same obj, rank, nu, transform, abb, sampler settings and seed.
See also
mipca_tune()to make the table.mipca()to fit with a rank andnuof your own.
Examples
set.seed(1)
sim <- sim_mat(n = 50, p = 20, beta = TRUE)
tuned <- mipca_tune(
sim$input,
rank = 1:3,
transform = "logit_biwhiten",
n_cols = 10,
seed = 1
)
# The rank with the lowest crps
fit <- mipca_fit(tuned, sim$input, refresh = 0, seed = 1)
#> the implied nu at rank 1 is 2.6, under the floor of 5, so the fit uses nu = 5. Pass 'nu' to use another value
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
# Another tuned rank, with more draws per chain
fit3 <- mipca_fit(tuned, sim$input, rank = 3, iter_sampling = 200, refresh = 0, seed = 1)
#> the implied nu at rank 3 is 3.41, under the floor of 5, so the fit uses nu = 5. Pass 'nu' to use another value