Description Usage Arguments Value Examples
View source: R/impute_data_mice.R
This function uses the mice package to multiply impute missing values based on the statistical relationships among a set of variables. There is a range of mice documentation and tutorials that is worth getting into to develop and check this function.
1 | impute_data_mice(data, var_names, var_methods, n_imputations)
|
data |
Data table - the Health Survey for England dataset with missing values |
var_names |
Character vector - the names of the variables to be considered in the multiple imputation. |
var_methods |
Character vector - the names of the statistical methods to be used to predict each of the above variables - see the mice documentation. |
n_imputations |
Integer - the number of different versions of the imputed data to produce. |
Returns a list containing
data All versions of the multiply imputed data in a single data table.
object The mice multiple imputation object.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | ## Not run:
# "logreg" - binary Logistic regression
# "polr" - ordered Proportional odds model
# "polyreg" - unordered Polytomous logistic regression
imp_obj <- impute_data_mice(
data = test_data,
c("binary_variable", "order_categorical_variable", "unordered_categorical_variable"),
c("logreg", "polr", "polyreg"),
n_imputations = 5
)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.