rpropensity-score-matching

Removing covariates from love plot after multiple imputation and propensity matching


I have used mice to create a series of multiply imputed datasets and then applied MatchThem to match on a number of covariates. I am trying to use the love.plot function from cobalt to create a love plot, but I want to omit one of the variables from the plot as my data set has lots of matching variables and the love plot is too busy.

In the example below I want to drop the variable "married" from the love plot. Is there a way to do this?

My code is:

data("lalonde_mis", package = "cobalt")
set.seed(100)

#Generate imputed data sets
m <- 10 #number of imputed data sets
imp.out <- mice::mice(lalonde_mis, m = m, print = FALSE) 


#Performing propensity score matching in each imputation
match.out <- MatchThem::matchthem(nodegree ~ age + race + 
                              re74 + re75, datasets = imp.out,
                           exact = "married",
                           method = "nearest",
                           caliper = 0.2,
                           distance = "glm")

# Removing the married variable from match.out
match.out$object$data$married <- NULL 

love.plot(match.out, threshold = .05, stats = "m",
      abs = FALSE,
      stars = "std", 
      which.imp = .none, agg.fun = "mean",
      drop.distance = TRUE) `

Solution

  • To give a solution that doesn't require to to modify the ggplot object:

    Just use the formula interface to love.plot(). That's what it was designed for.

    love.plot(nodegree ~ age + race + re74 + re75,
              data = imp.out,
              weights = match.out,
              threshold = .05, stats = "m",
              abs = FALSE,
              stars = "std", 
              which.imp = .none, agg.fun = "mean")
    

    enter image description here

    You can specify exactly the variables you want in the plot by supplying them to the formula.