with_graph | R Documentation |
Evaluate Causal Graph Discovery Algorithm in Multiple Imputed Data sets
with_graph(data, algo = c("pc", "fci", "fciPlus", "ges"), args, score = FALSE)
data |
An object of type mids, which stands for 'multiply imputed data set', typically created by a call to function mice() |
algo |
An algorithm for causal discovery from the package 'pcalg' (see details). |
args |
Additional arguments passed to the algo. Must be a string vector starting with comma, i.e. ", ..." |
score |
Logical indicating whether a score-based or a constrained-based algorithm is applied. |
A list object of S3 class mice::mira-class
.
data(windspeed) dat <- as.matrix(windspeed) ## delete some observations set.seed(123) dat[sample(1:length(dat), 260)] <- NA ## Impute missing values under normal model imp <- mice(dat, method = "norm", printFlag = FALSE) mylabels <- names(imp$imp) out.fci <- with_graph(data = imp, algo = "fciPlus", args = ", indepTest = gaussCItest, verbose = FALSE, labels = mylabels, alpha = 0.01") out.ges <- with_graph(data = imp, algo = "ges", arg = NULL, score = TRUE) if (requireNamespace("Rgraphviz", quietly = TRUE)){ oldpar <- par(mfrow = c(1,2)) plot(out.fci$res[[1]]) plot(out.ges$res[[1]]$essgraph) par(oldpar) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.