# Instrumental variable analysis after (propensity) matching

I am trying to replicate the methods used in this paper by Paul Rosenbaum and colleagues (Near-Far matching). I have been studying the methods in the referenced papers by Michael Baoicchi.

My work examines the (binary) outcome (dead/alive) a treatment where there is a 'health system' discouragement that acts as the instrument. The treatment is usually selected for the sickest patients, and I am hoping that the 'discouragement' instrument will allow me to evaluate the outcome without selection bias.

I have posted a sample data set here and the code to github

I have replicated the matching steps, and now have a balanced discouraged group and an encouraged group.

Summary of balance for matched data:
Means Treated Means Control SD Control Std. Mean Diff. eCDF Med eCDF Mean eCDF Max
distance        0.2998        0.2996     0.0347          0.0051   0.0055    0.0047   0.0330
age            70.1648       70.3901    16.3334         -0.0133   0.0110    0.0148   0.0495
male            0.4945        0.5165     0.5011         -0.0438   0.0110    0.0110   0.0220
illness        16.2363       16.1978     7.7234          0.0050   0.0110    0.0123   0.0604


I can see that there appears to be an effect of discouragement on both the treatment and the outcome.

> with(mdt.match, table(treat, discourage)) # treatment is 'discouraged'
discourage
treat   0   1
0 132 140
1  50  42
> with(mdt.match, table(dead, discourage))  # mortality is lower when discouraged
discourage
0 106 120
1  76  62


A simple t-test now shows me the difference by 'discouragement', but doesn't exploit the IV effect.

First, reshape the data (one row per pair).

> mdt <- data.table(
+     z0=tdf[matchit.out$match.matrix[,1], 'discourage'], + d0=tdf[matchit.out$match.matrix[,1], 'treat'],
+     y0=tdf[matchit.out$match.matrix[,1], 'dead'], + z1=tdf[row.names(matchit.out$match.matrix), 'discourage'],
+     d1=tdf[row.names(matchit.out$match.matrix), 'treat'], + y1=tdf[row.names(matchit.out$match.matrix), 'dead'])
> mdt[,id.pair := .I, by=.I]
z0 d0 y0 z1 d1 y1 id.pair
1:  0  0  0  1  0  0       1
2:  0  1  1  1  0  0       2
3:  0  0  0  1  0  0       3
4:  0  0  0  1  0  0       4
5:  0  0  0  1  1  0       5
6:  0  0  0  1  0  1       6
7:  0  0  1  1  1  1       7
8:  0  1  1  1  0  1       8
9:  0  0  0  1  0  0       9
10:  0  0  0  1  0  0      10


Now the paired t-test

> with(mdt, t.test(y1, y0, paired=TRUE))

Paired t-test

data:  y1 and y0
t = -1.552, df = 181, p-value = 0.1224
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-0.17471948  0.02087332
sample estimates:
mean of the differences
-0.07692308


What I can't get calculate is the effect ratio, and its confidence interval. Can anyone point me to a walk-through, or offer some simple guidance.

• Have you considered using the twang package in R? I prefer its built in propensity score models and calculations. It uses a gradient boosting machine approach to obtaining the propensity scores and selects the number of iterations that minimizes the average (or maximum) average treatment effect or the average treatment effect of the treated. The methods have show better performance than logistic regression and other propensity score estimation procedures in balancing covariates. The twang package does it all for you. . . – StatsStudent Jul 29 '15 at 2:11
• @StatsStudent - Thanks for the nod toward twang. Any clues on the IV step? – drstevok Jul 29 '15 at 7:16
• I'm interested in near-far matching and am learning it now. You may consider the "nbpMatching" package in R. The schema used in Baiocchi and Rosenbaum (2010) is actually based on Lu et al. (2001), and Lu et al. (2011) created the "nbpMatching" package. Could you provide your code of creating discouraged group and encouraged group for reference? Thanks. – user127691 Aug 15 '16 at 5:09
• Thanks for the references and link to nbpMatching @Joy. The code you asked about might be this – drstevok Aug 17 '16 at 22:14