I have a tme series that when particularly anomalies the overall trend will be either higher or lower than before it started picking up these anomalies. I don't need to predict exactly what value it will have, just the trend.

What model is appropriate for this kind of situation? I have never run across this before.

EDIT: Additional Info Of What I am looking for

Let's call the variable I am interested in is $f$, which at some time $t$, takes on the value $f_t$. I want to know if $f_{t+\delta t}$ is higher or lower than $f_t$ based on anomalies/outliers I pick up from another variable, called $x$. So I supposed the model looks something like $f_{t+\delta t}(x_t)=x_t+x_{t-1}+..$

But this feels awkward to me, what kind of model(s) should I consider?

  • $\begingroup$ Do you know when the anomalies occured (both historically and in the future), or do you need to detect this in the historical data? $\endgroup$ – Stephan Kolassa Jun 12 '17 at 11:57
  • $\begingroup$ I have training data where i know these anomalies occurred but i will need to detect these live for my trend forecasting. $\endgroup$ – guy Jun 12 '17 at 11:59

Historically, you can probably use linear to transform time. Here are some random data:

xx <- seq(0,4,by=0.05)
obs <- sin(xx*pi/2)+rnorm(length(xx),0,0.2)

enter image description here

Assume that we know the trend changes at times $1$ and $3$. We can then include linear spline terms of the form

$$ (t-1)_+=\max\{t-1,0\}\quad\text{and}\quad (t-3)_+=\max\{t-3,0\}$$

along with the linear time trend predictor $t$ itself:

spline.regressors <- cbind(

model <- lm(obs~spline.regressors)


enter image description here

Regression Modeling Strategies by Frank Harrell, section 2.4.2, contains more information.

You might also be able to include your trend changes in a state space model, which would be analogous to adding new components to an exponential smoothing model.

To detect these changes, look at methods for detecting . Most of these are built to detect level changes (i.e., step changes), not changes in trend - so just apply these methods to your series after differencing it. In R, the strucchange package is helpful, and even if you don't use R, it contains some good pointers to literature.

Alternatively, you could use control theory and construct a . Whenever a series is out of control and goes out of your control bounds with a consistent trend, its underlying trend probably has changed.

  • $\begingroup$ Thanks for this answer, I also added more details in my question before I saw your answer if it helps. Not sure if your answer is still applicable in that case. $\endgroup$ – guy Jun 12 '17 at 12:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.