1

How do I specify covariates for regression discontinuity model using 'rdrobust' package in R?

The problem is with 'covs' parameter in the code below. It is supposed to allow specifying additional covariates for the model. I have tried providing a vector of vectors from the dataset (as in the code below) and a vector of variable names but neither seem to work.

fm = rdrobust(datasets$CONTINUANCE,
              dataset$T,
              p=3,
              covs=c(dataset$CONTENT_LENGTH, dataset$CONTENT_SNIPPET),
              kernel='uniform',
              weights=dataset$USERS,
              bwselect='msetwo',
              vce='nn',
              nnmatch=7,
              level=95)

As a result, I get the following error:

Error in if (c <= x_min | c >= x_max) { : 
  missing value where TRUE/FALSE needed
Calls: rdrobust
Execution halted

2 Answers2

4

The documentation for this package is unhelpful, unfortunately. You specify the covariates like a formula (var1 + var2) rather than as a vector (c(var1, var2)), so something like this should work:

fm = rdrobust(datasets$CONTINUANCE,
              dataset$T,
              p=3,
              covs=dataset$CONTENT_LENGTH + dataset$CONTENT_SNIPPET,
              kernel='uniform',
              weights=dataset$USERS,
              bwselect='msetwo',
              vce='nn',
              nnmatch=7,
              level=95)

James Martherus
  • 1,033
  • 1
  • 9
  • 20
1

In the current version of rdrobust (0.99.4) the covariates should be incorporated as a combined object via cbind. In the example above:

fm = rdrobust(datasets$CONTINUANCE,
              dataset$T,
              p=3,
              covs=cbind(dataset$CONTENT_LENGTH, dataset$CONTENT_SNIPPET),
              kernel='uniform',
              weights=dataset$USERS,
              bwselect='msetwo',
              vce='nn',
              nnmatch=7,
              level=95)

We will keep this in mind for the next version coming soon. Thanks, Sebastian.