Announcement

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

  • tsset to use with itsa

    Hi,

    I'm getting stuck on what I suspect is a small point and couldn't find the solution. I would like to conduct a single-group interrupted time series analysis using Linden's itsa package using the data copied at bottom.

    The intervention is at time point 31.

    Code:
    tsset id obsday
    itsa sleep, single trperiod(31) lag(1) posttrend figure
    This generates the following error:
    Code:
    d(31) invalid
    r(198);
    Clearly my knowledge of time series data is lacking, but I can't seem to get this to work.

    I'm using 'itsa' from SSC in Stata 17.0.

    Thanks.

    Owen


    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float(id group obsday sleep)
     1 1  1 353
     1 1  9 345
     1 1 15 340
     1 1 21 337
     1 1 26 324
     1 1 33 332
     1 1 41 326
     1 1 49 329
     2 1  1 362
     2 1  9 361
     2 1 15 355
     2 1 23 365
     2 1 28 350
     2 1 33 343
     2 1 39 333
     2 1 45 320
     3 1  1 345
     3 1  9 360
     3 1 16 347
     3 1 24 348
     3 1 29 351
     3 1 37 348
     3 1 44 334
     3 1 50 335
     4 1  1 338
     4 1  9 357
     4 1 16 384
     4 1 21 418
     4 1 26 408
     4 1 31 404
     4 1 36 423
     4 1 43 403
     5 1  1 341
     5 1  8 341
     5 1 15 356
     5 1 21 368
     5 1 27 377
     5 1 33 367
     5 1 40 363
     5 1 46 362
     6 1  1 353
     6 1  8 340
     6 1 15 334
     6 1 22 330
     6 1 28 327
     6 1 35 306
     6 1 41 321
     6 1 49 319
     7 1  1 373
     7 1  7 373
     7 1 13 380
     7 1 21 377
     7 1 27 372
     7 1 31 372
     7 1 38 361
     7 1 45 347
     8 1  1 323
     8 1  7 327
     8 1 12 335
     8 1 19 307
     8 1 25 314
     8 1 32 284
     8 1 40 244
     8 1 47 235
     9 1  1 353
     9 1  7 361
     9 1 13 350
     9 1 19 342
     9 1 25 317
     9 1 30 301
     9 1 36 306
     9 1 43 303
    10 1  1 365
    10 1  8 366
    10 1 14 368
    10 1 21 374
    10 1 27 396
    10 1 34 369
    10 1 39 393
    10 1 47 391
    11 1  1 343
    11 1  7 347
    11 1 14 334
    11 1 20 327
    11 1 25 326
    11 1 33 312
    11 1 38 348
    11 1 45 356
    12 1  1 360
    12 1  8 356
    12 1 14 342
    12 1 20 360
    12 1 26 366
    12 1 32 350
    12 1 38 383
    12 1 45 385
    13 1  1 347
    13 1  8 353
    13 1 12 339
    13 1 18 316
    end
    format %td obsday
    label values group group
    label def group 1 "Control", modify

  • #2
    based on the help file, which says, "Dates should be specified using the respective pseudofunction (see datetime), such as trperiod(2020) for a four-digit year or trperiod(2019m11) for quarterly data." try
    Code:
    itsa sleep, single trperiod(31jan1960) lag(1) posttrend figure
    however, since you have more than one panel, you also need to specify the "treatid" option - see
    Code:
    h itsa

    Comment


    • #3
      Thank you, Rich! I clearly was missing something quite simple in my time series specification.

      The second part is another area where I think I'm off the track a little. I managed to follow other guidance to conduct an ITSA using this code:

      Code:
      mkspline knot1 31 knot2 = obsday, marginal
      
      *First, generate an intervention indicator (0=pre-intervention, 1=intervention).
      gen period = .
      replace period = 0 if obsday < 31
      replace period = 1 if obsday >= 31 & !missing(obsday)
      
      *Estimate ITSA
      xtmixed sleep i.period c.knot1 c.knot2 || id: period knot1 knot2, covariance(unstructured)
      
      *Test different in slopes before vs after intervention
      margins, expression(_b[knot1] + _b[knot2])
      I try to replicate it using 'itsa' package which would enable the use of Newey-West standard errors and the use of the 'actest' command to test the autocorrelation structure. I would have thought the following would work, but not so much.

      Code:
      tsset id obsday, daily
      itsa sleep, single trperiod(31jan1960) lag(1) posttrend figure
      But with multiple respondents, I get the message about having to specify a 'treatid' option. Is there a way to specify either 'tsset' or 'itsa' to include all respondents in the same analysis?

      Or am I possibly just misunderstanding what the 'itsa' can do?

      Thanks.

      Owen

      Comment


      • #4
        I'm confused about what you are trying to do; however, yes, if you only include a timevar in your -tsset- statement you should get something

        Comment


        • #5
          I'm not being very clear. Let me try again in a more general way

          I've got the data above and I would like to conduct a single-group interrupted time series analysis using the 'itsa' package to see if an intervention at day 31 has any effect. I'm getting stuck on implementing it.

          Thanks!

          Owen

          Comment

          Working...
          X