make_call <- function(func_name, ...) {
args <- paste(..., sep=", ")
paste0(func_name, "(", args, ")")
}
make_formula <- function(covar, treat) {
rightside <- paste(covar, collapse=" + ")
paste0(treat, " ~ ", rightside)
}
construct_args <- function(argslist) {
args <- paste0(names(argslist), " = ", argslist)
paste(args, collapse=", ")
}
make_matchit_call <- function(e, method) {
metharg <- method$args[["method"]]
method$args[["method"]] <- shQuote(metharg)
args <- construct_args(method$args)
form <- make_formula(e$covar, e$treat)
make_call("matchit", form, "data = myData", args)
}
assign_matchit_models <- function(e) {
for(m in names(e$methods_list)) {
if(!identical(m, "iptw")) {
mi_call <- make_matchit_call(e, e$methods_list[[m]])
e$methods_list[[m]][["matchit_mod"]] <- eval(parse(text=mi_call))
} else {
e$methods_list[[m]][["matchit_mod"]] <- NULL
}
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.