# 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")