Convergence plots for smcfcs in R

The smcfcs package in R imputes missing values of covariates compatibly (congenially) with the user’s specified outcome or substantive model. Just like the regular chained equations (fully conditional specification) multiple imputation method, smcfcs is an iterative procedure, and users should check that they have used enough iterations for the process to have (hopefully) converged to its stationary distribution. The smcfcs package returns a matrix with the parameter estimates of the outcome/substantive model from each imputed dataset and iteration within these. But it requires the user to figure out how to appropriately plot these.

Now, thanks to Edouard Bonneville, smcfcs has a plot function which, using ggplot2 automatically produces some nice plots that can be used to assess convergence. To illustrate, let’s use the example code for imputing missing covariates with some competing risks data, setting the number of iterations to 50 so that we can more reliably assess convergence:

library(survival)
library(smcfcs)
set.seed(6723432)
imps <- smcfcs(
  originaldata = ex_compet,
  smtype = "compet",
  smformula = list(
    "Surv(t, d == 1) ~ x1 + x2",
    "Surv(t, d == 2) ~ x1 + x2"
  ),
  numit=50,  method = c("", "", "norm", "norm")
)

Afterwards, we can simply call plot on the object returns by smcfcs:

plot(imps)

which produces:

The plot shows trace plots for each of the 5 imputations for each of the 4 parameters. There are 4 parameters because in this situation, we have two Cox models (one for each cause of failure), and each has two covariates. The plots suggest rapid convergence, except for x2 in the Cox model for cause 1, where convergence seems to take at least 10 iterations.

The convergence plot functionality is available now in the development version of smcfcs on Github, and will be on CRAN soon. Many thanks to Edouard for this really nice addition to the package.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.