1

I would like to run a regression discontinuity in Time in R. First, I would like to visualize the regression using the rdplot function. The code I have used you can find below. With c I should specify the cutoff point based on the running variable. However, the rd package is designed to use a normal continuous variable and not a date as the running variable. So, I get the error message Error in `-.Date`(x_max, c) : can only subtract from "Date" objects. I have the same problem when I use the rdrobust command where I also have to specify the cutoff.

The code for the rdplot I used is:

rdplot(
  df$Date, df$dependentvariable,
  c = as.Date(as.character("20161231"), format = "%Y%m%d"),
  nbins = 4
)

The code for the rdrobust I used is:

rdplot(
  df$Date, df$dependentvariable,
  c = as.Date(as.character("20161231"), format = "%Y%m%d")
)

Does anyone have any idea whether I can use the rdrobust and rdplot command for regression discontinuity in time? If yes, how do I have to adjust the code? Are there any other packages/commands that I can use to run a regression discontinuity in time or are there any workarounds?

Edit due to first answer asking for more information:

Thank you for the answer. The data set is confidential and very large, so I can not share it here. However, I created an exemplary, shorter data set with the same structure as mine. It has the following structure:

No, Company, IPO Date, IPO mechanism, IR (Underpricing), firm age (Age) at listing

1,Company 1, 2016-11-01, 0, 10.3%, 5.9

2,Company 2, 2016-11-10, 0, 5.2%, 10.3

3,Company 3, 2016-11-12, 0, -1.1%, 3.4

4,Company 4, 2016-12-01, 0, 6.5%, 4.3

5,Company 5, 2016-12-09, 0, 8.3%, 6.2

6,Company 6, 2016-12-16, 0, 7.2%, 10.5

7,Company 7, 2016-12-23, 0, 4.1%, 7.4

8,Company 8, 2016-12-28, 0, -6.5%, 7.7

9,Company 9, 2017-01-01, 1, 1.3%, 7.0

10,Company 10, 2017-01-10, 1, 2.2%, 3.4

11,Company 11, 2017-01-12, 1, -4.1%, 5.5

12,Company 12, 2017-01-01, 1, -10.5%, 9.2

13,Company 13, 2017-01-09, 1, 6.2%, 7.6

14,Company 14, 2017-01-16, 1, 2.5%, 11.5

15,Company 15, 2017-02-23, 1, 4.1%, 7.4

16,Company 16, 2017-02-28, 1, -6.5%, 7.7

Note: Various other covariates than age are included, but not shown in the exemplary data set.

A change in the regulatory framework at the 2016-12-31 changed the selling mechanism of the IPO. I want to measure the impact of the regulatory change on underpricing. I know this is not a typical RD design but it should nevertheless be applicable. I am also aware that I have to be very carefully with the definition of the bandwidth.

So what I want to do: I would like to run a discontinuity regression in time where the cutoff is the date when the new regulation was implemented. The running variable is therefore time and the independent variable underpricing. In addition, I would like to include various company and IPO specific covariates like firm age or expected issue size which have an impact on underpricing according to prior research.

Further, I would like to plot the relationship between time and underpricing by grouping the data into points. Similar to what the rdplot function is doing.

So what I did you can see in the original post above

I think that there are mainly two problems with the rdplot and rdrobust function from the rdrobust package: 1. It does not recognize the cutoff as a date (the error message .... appears) 2. I cannot include covariates in the equation

Maybe there is also a workaround by splitting the data set at the cut off and afterwards run two separated regressions. However, for the plot I don't know how I would have to do it.

As I am not an R expert, I am totally lost on how to run this regression. Therefore, thank you very much already beforehand!

Timole95
  • 11
  • 3
  • 1
    Your code is not [reproducible](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) (no sample data, incorrect/missing package name): that lowers your chances of getting an answer. Fixing your problem could be as easy as converting the dates to numbers, `as.numeric(df$Date)`, `as.numeric(as.Date('2016-12-31'))`. – Vincent Zoonekynd Jul 16 '19 at 01:04
  • Now you should be able to reproduce the code, right? Do you have an idea what the problem could be? – Timole95 Jul 24 '19 at 17:54
  • Have you found a solution? I have the same problem! Lmk! – juanjedi Oct 15 '20 at 22:20

0 Answers0