# What model is appropriate for predicting time series trends?

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?

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

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

set.seed(1)
xx <- seq(0,4,by=0.05)
obs <- sin(xx*pi/2)+rnorm(length(xx),0,0.2)
plot(xx,obs,type="o",xlab="",ylab="")


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(
xx,
pmax(xx-1,0),
pmax(xx-3,0)
)

model <- lm(obs~spline.regressors)

plot(xx,obs,type="o",xlab="",ylab="")
lines(xx,predict(model),lwd=2,col="red")


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.