# Measuring the treatment effect of a binary variable on a binary outcome in R

I have a data set with 10000 entries of projects that take part in an auction for financial support. In that auction all of the bids below a certain cutpoint receive the support.

The data includes the bids, the distance of the bid to the cutpoint, the received support (0,1) and if the project was realized (0,1) in the end.

This is what my data looks like

The links have been automatically created by StackExchange since i have not yet earned the privilege of directly showing pictures in the post.

                     | quantities      |
| ------------------ | --------------- |
| support = 0        | 5036            |
| ------------------ | --------------- |
| Support = 1        | 4964            |
| ------------------ | --------------- |
| realization = 0    | 5513            |
| ------------------ | --------------- |
| realization = 1    | 4487            |
| ------------------ | --------------- |

| support = 0     | support = 1   |
| ------------------ | --------------- | ------------- |
| realization = 0    | 4035            | 1478          |
| ------------------ | --------------- | ------------- |
| realization = 1    | 1001            | 3486          |
| ------------------ | --------------- | ------------- |


This is the visualization of the discontinuity of the outcome at the cutpoint

I now want to measure the treatment-effect at the cutpoint with a regression discontinuity approach. I tried to do that with a logistic regression.

model_bandwith1 <- glm(realization ~ support + bid_centered ,family = binomial(link= "logit"),
data = filter(auction,
bid_centered <= 1,
bid_centered >= -1))


From there on i'm not sure what to do. Do i measure the odds ratio or the marginal effects to measure the size of the discontinuity at the cutpoint?

My approach to measuring the discontinuity at the cutpoint:

library(margins)
#gives the AME as default for probit and logit
model_bandwith1 <- glm(realization ~ support + bid_centered ,family = binomial(link= "logit"),
data = filter(auction,
bid_centered <= 1,
bid_centered >= -1))
logitmargins <- margins(model_bandwith1, type = "response")
tidy(logitmargins)

# Marginal effects
library(mfx) # marginal effect at the mean (MEM)
# base model no weights
model_logit <- logitmfx(formula = realization ~ support + bid_centered, data = filter(auction,
bid_centered <= 1,
bid_centered >= -1))

model_logitor <- logitor(formula = realization ~ support +
bid_centered , data = filter(auction,
bid_centered <= 1,
bid_centered >= -1))


The estimate of the AME for support is 0.404 while the estimate of the MEM for support is 0.4977. The Odds Ratio is 9.227.

How can i interpret the difference between the AME and the MEM? the MEM seems to measure the gap shown in the visualization of the discontinuity pretty accurately.

• Please edit your question to show code and images directly on this site. It's very hard to understand otherwise, and it's dangerous to depend on external sites not directly affiliated with this site. You can paste a block of code as text into the question and then use the {} tool on the toolbar to indent it by 4 spaces so that it is displayed in an easy-to read and easy-to-copy format. There is a picture-insertion tool (picture icon on the tool bar, next to the {} tool) that allows drag-and-drop or a browsing interface.
– EdM
Commented Jan 19, 2022 at 20:17
• @EdM thank you for your comment, i will edit the post to show the code. Since i am new here i have not yet earned the privilege to directly insert pictures into the post. Commented Jan 20, 2022 at 8:35

Before you move on to the best way to describe the discontinuity, I'd suggest that you take advantage of the size of your data set to model the continuous predictor more closely near the discontinuity.

So far, you've only assumed a linear association (around the discontinuity attributed to the support predictor) between log-odds of project realization and the continuous bid_centered predictor. You restricted analysis to values close to the cutoff to emphasize local behavior near there, but you have enough data to try more flexible modeling with regression splines to get a more refined model.

Once you've done that, you can express the magnitude of the discontinuity in any terms that make sense to you and to your audience. The coefficient for support describes the discontinuity in log-odds scale. It might be easier to explain if you use a prediction from the model to translate that into a difference in probability of project realization at the bid_centered cutoff of 0.

• Thank you for your help! I do not quite understand what you mean with "use a prediction from the model to translate that into a difference in probability of project realization at the bid_centered cutoff of 0." I will edit the post to show my approach. Commented Jan 20, 2022 at 21:08
• @FyHub if the assumptions of the regression discontinuity model hold, all that matters is the shift in estimated values at the cutoff point, 0 in your case. Marginalization takes averages of some type over multiple data points instead, which involves points away from the cutoff. You don’t care about the data points over which you would marginalize except insofar as they determine the estimated values at your cutoff. Use the model to make two probability predictions at bid_centered =0: one with support = 0, the other with support =1. That difference in probability is pretty simple to explain.
– EdM
Commented Jan 20, 2022 at 21:42
• @FyHub I don't have experience with the packages you use to calculate the marginal effects, so it's possible that one of them does what I suggest, which is to estimate a difference in model predictions between support = 0 and support = 1 specifically at the point of discontinuity.
– EdM
Commented Jan 20, 2022 at 21:57