R/make_boxplot.R

make_boxplot <- function(e) {
  mods <- getModels(e)
  # Hack to get rid of iptw
  mods[["iptw"]] <- NULL
  sum_mods <- list()
  for(i in seq(length(mods))) {
    sum_mods[[i]] <- do.call("summary", list(mods[[i]], standardize=TRUE))
  }
  sum_matched <- lapply(sum_mods, `[[`, "sum.matched")
  std_mean_diff <- sapply(sum_matched, `[`, "Std. Mean Diff.")
  allbiases <- unname(abs(unlist(std_mean_diff)))
  len <- length(std_mean_diff[[1]])
  id <- rep(seq(1, length(mods)), each=len)
  par(cex.axis=0.6)
  boxplot(allbiases ~ id, main="Abs. std. biases for remaining models", 
          names=names(mods), ylab="Absolute standardized biases", las=3)
}

getModels <- function(e) {
  lapply(e$methods_list, "[[", "matchit_mod")
}
ncarchedi/iMatchIt documentation built on May 23, 2019, 1:05 p.m.