Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using DateTime as Independent Variable - Regression Discontinuity in Time

    Hi everyone!

    In the same vein as Davis (http://faculty.haas.berkeley.edu/lda...JPE%202008.pdf), I want to estimate the effect of a speed-limit reduction on air quality/pollution emission. I have gathered high-frequency data (hourly air pollution for different pollutants from different monitoring stations over multiple years). I will do a Regression Discontinuity Design where the independent variable is time, also called Regression Discontinuity in time.

    I have already created my set of DateTimes as shown on the screenshot #1 below. However, I cannot use these DateTimes as a the independent variable when I run a regression. Indeed, when using rdrobust and rdplot, it is displayed "c() should be set within the range of DATETIME", c() being the cutoff date (see screenshot #2). It therefore appears that DateTimes is not taken into account as a variable in itself. How can I transform DateTime as a variable I can use in my regression, especially for the cutoff?

    I thank y'all!


    Click image for larger version

Name:	Screenshot 2019-03-21 at 23.10.42.png
Views:	2
Size:	136.5 KB
ID:	1489450



    Click image for larger version

Name:	Screenshot 2019-03-21 at 23.16.53.png
Views:	1
Size:	14.7 KB
ID:	1489451
    Attached Files

  • #2
    The problem is not with your DATETIME variable, it is with your representation of the cutoff. It should be:

    Code:
    rdplot PM25_ln DATETIME, c(`=tc(10jan2014 00:00:00)') p(1)
    I say this with absolutely no knowledge of rdplot, other than it is a Stata program that expects a number in the -c()- option. 10jan2014 00:00:00 is not a number--it is a string. To convert it to the numerical representation of the date that human eyes understand that string to signify, you use the -tc()- function.

    For the future, please read the Forum FAQ for advice about effective posting. Screenshots are not helpful. As is often the case, yours were unreadable, at least on my computer. If you want to show example data (as is always a good idea when looking for help with coding issues), please use the -dataex- command. If you are running version 15.1 or a fully updated version 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.
    Last edited by Clyde Schechter; 21 Mar 2019, 22:29.

    Comment

    Working...
    X