View source: R/impute_expected_values.R
impute_expected_values | R Documentation |
Impute the missing values with expected values given the observed values and estimated parameters assuming a multivariate normal distribution
impute_expected_values( ds, mu, S, stochastic = FALSE, M = is.na(ds), verbose = FALSE )
ds |
A data frame or matrix with missing values. |
mu |
Vector of means for the variables. |
S |
Covariance matrix of the variables. |
stochastic |
Logical, should residuals be added to the expected values. |
M |
Missing data indicator matrix. |
verbose |
Should messages be given for special cases (see details)? |
Normally, this function is called by other imputation function and should not be called directly. The function imputes the missing values assuming a multivariate normal distribution. This is equivalent to imputing the least squares estimate of the missing values in some kind of way.
If no values is observed in a row or a relevant submatrix of the
covariance matrix (S_22
) is not invertible, the missing values are imputed
with (parts of) mu
(plus a residuum, if stochastich = TRUE
). If
verbose = TRUE
, these cases will be listed in a message. Otherwise, they
will be imputed silently.
An object of the same class as ds
with imputed missing values.
ds_orig <- mvtnorm::rmvnorm(100, rep(0, 2)) ds_mis <- delete_MCAR(ds_orig, p = 0.2) # impute using true parameters: ds_imp <- impute_expected_values(ds_mis, mu = c(0, 0), diag(1, 2))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.