# Interrupted Time Series, estimates before and after jump

**URL:** <https://discourse.datamethods.org/t/interrupted-time-series-estimates-before-and-after-jump/23181>\
**Category:** models\
**Tags:** interpretation\
**Created:** [November 23, 2024, 6:41am UTC](https://discourse.datamethods.org/t/interrupted-time-series-estimates-before-and-after-jump/23181 "2024-11-23T06:41:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![CP3](https://discourse.datamethods.org/user_avatar/discourse.datamethods.org/cp3/32/4916_2.png) [@CP3](https://discourse.datamethods.org/u/CP3)\
**Post date:** [November 23, 2024, 6:41am UTC](https://discourse.datamethods.org/t/interrupted-time-series-estimates-before-and-after-jump/23181/1 "2024-11-23T06:41:05Z")

</div>

Professor Harrell,

In this example, after fitting spline functions and jump(day of the ban), how do we generate one estimate to indicate, “average”, if that’s the right word.

beta, before the jump (day of ban) , including SE and C.Is  
beta, after the jump(day of ban), including SE and C.Is

```auto
require(rms)  
require(ggplot2)

getHdata(sicily) # fetch dataset from hbiostat.org/data
d <- sicily
dd <- datadist(d); options(datadist='dd')

off <- list(stdpop=mean(d$stdpop)) # offset for prediction (383464.4)
w <- geom_point(aes(x=time, y=rate), data=d)
v <- geom_vline(aes(xintercept=37, col=I('red')))
yl <- ylab('Acute Coronary Cases Per 100,000')

h <- function(x) {
  z <- cbind(rcspline.eval(x, k),
             sin=sin(2*pi*x/12), cos=cos(2*pi*x/12),
             jump=x >= 37)
  attr(z, 'nonlinear') <- 2 : ncol(z)
  z
}
f <- Glm(aces ~ offset(log(stdpop)) + gTrans(time, h),
         data=d, family=poisson, x=TRUE, y=TRUE) # x, y for LRTs

f

```

---

<div class="post-metadata">

**Author:** ![f2harrell](https://discourse.datamethods.org/user_avatar/discourse.datamethods.org/f2harrell/32/165_2.png) [@f2harrell](https://discourse.datamethods.org/u/f2harrell)\
**Post date:** [November 23, 2024, 12:15pm UTC](https://discourse.datamethods.org/t/interrupted-time-series-estimates-before-and-after-jump/23181/2 "2024-11-23T12:15:01Z")

</div>

If I understand your question I don’t think averages are very good summaries for curves that aren’t flat on both sides of the jump. I would concentrate on `contrast()`’s of a specific pair of times.

---

<div class="post-metadata">

**Author:** ![CP3](https://discourse.datamethods.org/user_avatar/discourse.datamethods.org/cp3/32/4916_2.png) [@CP3](https://discourse.datamethods.org/u/CP3)\
**Post date:** [November 23, 2024, 2:40pm UTC](https://discourse.datamethods.org/t/interrupted-time-series-estimates-before-and-after-jump/23181/3 "2024-11-23T14:40:34Z")

</div>

That makes sense. Thanks Professor Harrell.
