makeResiduals | R Documentation |
Generate residuals based on variables in imputed data sets
makeResiduals(data, v, confounder, method = c("res", "cc", "pd"))
data |
A data.frame. |
v |
Vector of integers referring to the location of the variable(s) in the data set |
confounder |
Vector of integers referring to the location of the variable(s) in the data set (confounders are not included in the network!) |
method |
Default method 'res' uses residuals, 'cc' uses complete cases and 'pd' uses pairwise deletion |
A data matrix of residuals.
data(windspeed) daten <- mice::ampute(windspeed)$amp # Impute missing values imp <- mice(daten, m = 5) # Build residuals knoten <- 1:4 confounder <- 5:6 # Residuals based on dataset with missing values res.pd <- makeResiduals(daten, v = knoten, confounder = confounder, method = "pd") # Residuals based in multiple imputed data residuals <- list(data = list(), m = 5) imp_c <- mice::complete(imp, "all") for (i in 1:imp$m){ residuals$data[[i]] <- makeResiduals(imp_c[[i]], v = knoten, confounder = confounder) } pc.res <- pcMI(data = residuals, p = length(knoten), alpha = 0.05) fci.res <- fciMI(data = imp, p = length(knoten), alpha = 0.05) if (requireNamespace("Rgraphviz", quietly = TRUE)){ oldpar <- par(mfrow = c(1,2)) plot(pc.res) plot(fci.res) par(oldpar) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.