Pattern-Mixture Models — MNAR (R)¶

mice delta-adjustment: the tipping-point sensitivity analysis¶

The R counterpart to patternmix_python.ipynb. The Python notebook builds the pattern-mixture imputation-and-combine engine from scratch; here we run the same delta-adjustment sensitivity analysis with mice, exactly as described in van Buuren's Flexible Imputation of Missing Data. The recipe: impute under MAR, then use mice's post hook to add a shift $\delta$ to the imputed values of the dropouts (here, the drug-arm dropouts), sweep $\delta$, and watch the treatment effect. Data: the same antidepressant trial with drug-arm dropout.

In [1]:
options(repr.plot.width=9, repr.plot.height=4.5)
.libPaths(c("C:/Users/user/R/win-library/4.6", .libPaths())); suppressMessages(library(mice))
BLUE<-"#2b6cb0"; RED<-"#c53030"; GREEN<-"#2f855a"; PURP<-"#6b46c1"; GREY<-"#718096"
d<-read.csv("antidep.csv")
w<-reshape(d[,c("id","week","y")], idvar="id", timevar="week", direction="wide")
names(w)<-c("id","w0","w1","w3","w6"); w$drug<-d$drug[match(w$id,d$id)]
w$base<-ifelse(is.na(w$w0), w$w1, w$w0); w$base[is.na(w$base)]<-mean(w$base,na.rm=TRUE)
cat("n =", nrow(w), " drug:", sum(w$drug==1), " placebo:", sum(w$drug==0), "\n")
cat("week-6 dropout:", sum(is.na(w$w6)), " (drug", sum(is.na(w$w6)&w$drug==1), ", placebo", sum(is.na(w$w6)&w$drug==0), ")\n")
Warning message:
"package 'mice' was built under R version 4.6.1"
n = 28  drug: 18  placebo: 10 
week-6 dropout: 6  (drug 5 , placebo 1 )

1. Delta-adjustment with mice's post hook¶

We impute the missing week-6 score under MAR, then for each $\delta$ post-process the imputations so that the drug-arm dropouts are shifted up by $\delta$ (worse), using the documented post expression. Fitting w6 ~ drug + base on each set of imputations and pooling by Rubin's rules gives the drug effect as a function of $\delta$ — the tipping-point curve.

In [2]:
dat<-w[,c("w6","drug","base")]
ini<-mice(dat, maxit=0, print=FALSE)
deltas<-seq(0,3,0.25); est<-lo<-hi<-numeric(length(deltas))
for(k in seq_along(deltas)){
  post<-ini$post
  post["w6"]<-sprintf("imp[[j]][data$drug[!r[,j]]==1, i] <- imp[[j]][data$drug[!r[,j]]==1, i] + %f", deltas[k])
  imp<-mice(dat, m=30, method="norm", post=post, seed=1, print=FALSE)
  ps<-summary(pool(with(imp, lm(w6 ~ drug + base))))
  row<-ps[ps$term=="drug",]; est[k]<-row$estimate; lo[k]<-row$estimate-1.96*row$std.error; hi[k]<-row$estimate+1.96*row$std.error
}
plot(deltas, est, type="l", lwd=2, col=PURP, ylim=range(c(lo,hi,0)), xlab=expression(delta~"on drug-arm dropouts"),
     ylab="drug effect on week-6 score", main="mice delta-adjustment: antidepressant trial")
polygon(c(deltas,rev(deltas)), c(lo,rev(hi)), col=adjustcolor(PURP,.2), border=NA); lines(deltas,est,lwd=2,col=PURP)
abline(h=0, lwd=1)
cat(sprintf("MAR (delta=0) drug effect: %+.2f  95%% CI [%+.2f, %+.2f]\n", est[1], lo[1], hi[1]))
cat("The drug effect is negative (lower depression) but its interval includes zero even at delta=0: with 28 patients\n")
cat("and dropout concentrated in the drug arm, the trial cannot establish the benefit, and any MNAR shift weakens it.\n")
cat("mice's post-processing delta-adjustment reproduces the from-scratch pattern-mixture sensitivity curve.\n")
MAR (delta=0) drug effect: -1.21  95% CI [-2.64, +0.22]
The drug effect is negative (lower depression) but its interval includes zero even at delta=0: with 28 patients
and dropout concentrated in the drug arm, the trial cannot establish the benefit, and any MNAR shift weakens it.
mice's post-processing delta-adjustment reproduces the from-scratch pattern-mixture sensitivity curve.
No description has been provided for this image

2. Summary¶

mice implements the pattern-mixture delta-adjustment directly: impute under MAR, then shift the imputed values of the dropouts by $\delta$ through the post hook, pool with Rubin's rules, and sweep $\delta$ to trace the treatment effect. On the antidepressant trial it reproduces the from-scratch curve of patternmix_python.ipynb — a drug effect that points toward benefit but is not significant even under MAR, and that only weakens as the drug-arm dropouts are assumed to have fared worse.

This is the standard applied route to a sensitivity analysis for MNAR dropout, and the package mirror of the from-scratch pattern-mixture engine. mice (from Project 2) does double duty: the same multiple-imputation machinery, now with an explicit MNAR shift. Pattern-mixture and the selection models of Project 4 are the two factorisations of non-ignorable missingness — $p(y\mid r)p(r)$ versus $p(y)p(r\mid y)$ — the former making the untestable assumption an interpretable, deliberately varied $\delta$. The last project of the arc turns to categorical missing data, back on ignorable ground and tying into the latent-class work.