Announcement

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

  • ITSA trperiod help

    I'm trying to run an interrupted time series analysis and I ran the following code:

    I want my intervention to start on April 23 2020

    tsset Date, daily

    Output: time variable: Date, 31mar2020 to 30may2020
    delta: 1 day


    Code for ITSA:

    itsa dayaverageallltc, single trperiod(23apr2020) lag(1) posttrend figure
    output: r(121) : trperiod() invalid -- invalid numlist

    Can someone help me figure out the formatting for the date?

    Thank you!

  • #2
    The authors of itsa (a community contributed command available from SSC) chose the easy way in their documentation and used yearly data, where the Stata Internal Format value for, for example, the year 1990 is just the number 1990. For daily dates, you need to use the function td() to conveniently provide the Stata Internal Format value of the daily date.
    Code:
    . display td(23apr2020)
    22028
    
    . display %td 22028
    23apr2020
    So one approach to this command would be
    Code:
    itsa dayaverageallltc, single trperiod(22028) lag(1) posttrend figure
    but a more readable version would be
    Code:
    itsa dayaverageallltc, single trperiod(`=td(23apr2020)') lag(1) posttrend figure

    Comment


    • #3
      Thank you! This worked

      Comment


      • #4
        Hi,
        I am using ITSA (Linden, 2015) command on my monthly data.
        and I used following command before I using "tsset":
        "gen mdate1=monthly(mdate, "YM")
        format mdate1 % tm".

        well, now I can run one intervention with code "itsa logim, single treat(13) trperiod(2017m1) lag(1) posttrend figure"
        but if I use one more intervention time point as the guide shows " itsa logim, single treat(13) trperiod(2017m1 2019m1) lag(1) replace posttr figure"
        the result shows " m(2017m12019m1) invalid, r(198);"

        I don't know what went wrong here.

        Thanks.
        Last edited by Jane Quan; 26 Feb 2022, 03:37.

        Comment


        • #5
          Originally posted by Jane Quan View Post
          Hi,
          I am using ITSA (Linden, 2015) command on my monthly data.
          and I used following command before I using "tsset":
          "gen mdate1=monthly(mdate, "YM")
          format mdate1 % tm".

          well, now I can run one intervention with code "itsa logim, single treat(13) trperiod(2017m1) lag(1) posttrend figure"
          but if I use one more intervention time point as the guide shows " itsa logim, single treat(13) trperiod(2017m1 2019m1) lag(1) replace posttr figure"
          the result shows " m(2017m12019m1) invalid, r(198);"

          I don't know what went wrong here.

          Thanks.
          Well,for my question, the answer is to add an semicolon, which are not introduced in the pdf manual but you can find it with command help ITSA.

          Comment

          Working...
          X