Search code examples
rrd

How to include a linear trend in a regression discontinuity design using rddtools


I am implementing the RDDtools package on the Card et al Medicare data. I have been able to establish a simple parametric regression. What I would like to do now is include a linear trend in ageyrs. I enter ageyrs as a covariate but am returning an error:

library(rddtools)
load(file ="C:/Users/perdue/Desktop/Adv.MicroEconometrics/HA 9/medicare.Rdata")

rd.medic<-rdd_data(y=er,x=ageyrs, covar=ageyrs, cutpoint=65, data = medicare)

rd.reg <- rdd_reg_lm(rdd_object=rd.medic, covariates = rd.medic$ageyrs, slope =("same"), covar.opt = ("include"))

    Error: $ operator is invalid for atomic vectors
4.
match.arg(covar.opt$strategy, choices = c("include", "residual"))
3.
model.matrix.rdd_data(rdd_object, covariates = covariates, order = order, bw = bw, slope = slope, covar.opt = covar.opt)
2.
model.matrix(rdd_object, covariates = covariates, order = order, bw = bw, slope = slope, covar.opt = covar.opt)
1.
rdd_reg_lm(rdd_object = rd.medic, covariates = rd.medic$ageyrs, slope = ("same"), covar.opt = ("include"))

In the documentation it says that I am supposed to enter the covariates as a formula. Does anyone have an idea of what that formula is?


Solution

  • The problem might be that covar.opt has to be a list. This did not produce any error:

    rd.reg <- rdd_reg_lm(rdd_object=rd.medic, covariates = 'ageyrs', slope =
    ("same"), covar.opt = list("include"))