# Interrupted Time Series Analysis

I'm conducting an interrupted time series analysis at the moment, but I'm stuck with certain parts.

I'm looking at the influence of wine critics on wine prices (auction data).
Example from a dataset called `Pavie` :

```````Lot closed`        price Treatment `Time since treatment`
54 2014-11-20 00:00:00  268.         0                      0
55 2015-03-21 00:00:00  309.         0                      0
56 2015-03-28 00:00:00  247          0                      0
57 2015-06-18 00:00:00  247          0                      0
58 2015-06-18 00:00:00  247          0                      0
59 2015-06-18 00:00:00  247          0                      0
60 2015-09-19 00:00:00  334.         1                      1
61 2015-10-17 00:00:00  288.         1                      2
62 2015-10-17 00:00:00  309.         1                      3
63 2015-12-16 00:00:00  309.         1                      4
64 2016-03-19 00:00:00  329.         1                      5
65 2016-06-04 00:00:00  412.         1                      6
``````

Using the whole data set to produce a scatterplot, implement a vertical line to show the treatment and add a regression line. I applied some code, I found on the web.

``````plot(Pavie\$Lot closed`, Pavie\$price)

abline(v=as.numeric(Pavie\$Lot closed`[59]), lwd=2, col='red')
tsPavie <- lm( Pavie\$price ~ Pavie\$Lot closed` + Pavie\$Treatment + Pavie\$Time since treatment`, data=Pavie )

lines( Pavie\$`Lot closed`, tsPavie\$fitted.values, col="steelblue", lwd=2 )
``````

This gives me the following plot:

The questions:

Why is the pre-treatment regression line straight, and post-intervention isn't? Where is my mistake (either in coding or thinking)?

What does the `fitted.value` function does in this case to the regression line?

The treatment happened on 2015-06-29, how do I code such a line, that the treatment is exactly specified (at this day, there is no price given)?

For the other data sets the time lag between the treatment to the next data point is different and can last from days to years. Does this issue make my regressions comparable?

As I am only interested in the level effect, do I need to de-trend my data?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.