Description Usage Arguments Examples
Get multiple imputation mean statistics
1 2 | get_mi_mean(.data, stat_var, weight_var = NULL, ids = ".id",
imps = ".imp", summary = TRUE, use_random = FALSE)
|
.data |
dataframe that could be converted to the mids object to perform calculations on the multiple imputations data frame. |
stat_var |
variable to apply statistics |
weight_var |
variable for weighting. NULL by default. |
ids, imps |
names of the columns wit the observation-specific ID and number of imputation. |
summary |
return a summary of the pooled analysis. |
use_random |
harmonise imputation of the unequal size randomly. By default if FALSE, therefore, to equalise sizes of the imputed samples, simplu n-first observations is used. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | library(dplyr)
dep <- "price" # Dependent variable
indep <- c("mpg", "headroom", "trunk",
"weight", "length", "turn",
"displacement", "gear_ratio",
"foreign") # independent variables
weight <- "weight" # weight variable
extrar <- "displacement" # any extra variable to bring from period 0 data
bt_groups <- c("psu") # Grouping variable for bootsrapping.
n_nearest <- 5 # numebr of the nearest observations to drow a random match
set.seed(11344)
imputation <-
lassopmm(
source = p_0_exmple,
target = p_1_exmple,
dep_var = dep,
indep_var = indep,
weight_var = weight,
strata_vars = bt_groups,
extra_var = extrar,
n_boot = 5, # Numebr of bootstrap iterations
n_near = 1)
# Getting results of the averages
get_mi_mean(imputation, stat_var = "price_source", use_random = F)
# Same by with weights in means
get_mi_mean(imputation, stat_var = "price_source", weight_var = "weight")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.