Apart from detecting trend from a time series plot, how do you test for its presence before removing the trend using moving average?
I fitted a mathematical trend to the data and the slope was approximately zero, does that mean there is no trend?
hypothesis testingtime seriestrend
Apart from detecting trend from a time series plot, how do you test for its presence before removing the trend using moving average?
I fitted a mathematical trend to the data and the slope was approximately zero, does that mean there is no trend?
Best Answer
You make assumptions about the behaviour of your trend. Without assumptions you cannot hope to ever test data.
Detrending a time series is effectively modelling a time series.
The most common (and often violated) assumptions you first need to make when dealing with time series are the following.
The $\gamma$ in item 3 refers to the correlation function taking $s,r$ indices of the time series as arguments.
Time series that comply are referred to as weakly stationary.
Your data sounds like it already complies to 2. If your data doesn't get "noisier" as time go forward then it also complies to 1.
Often the first step in modelling time series is transforming your data to approximately meet these assumptions, where possible. A simple means of meeting items 1,2, that works some of the time, is to difference the data (repeatedly), wherein you subtract each element of the time-series from the element preceding it. Other options include fitting polynomial regression to the data or performing regression on concatenated windows of a cyclical trends.
What you're hopefully left with is a series that approximately meets these assumptions. There's still plenty of trend to be devoured by your model.
Here's a function to compute $\gamma$.
Now let's look at realizations of some stationary data.
If you want an explicit test then $\frac{1.96}{\sqrt n}$, where n is the length of the time-series, is the 95% confidence bounds on null autocorrelation.
You can get pretty wild with time series modelling, but this is the linear regression analog of time series. The collection of these tricks form the guts of what is known as (S)ARIMA.