# Measuring Linearity of a Time Series

Is there a de facto standard process or function to measure the linearity of a time series? I have Googled the problem and have come across a few different papers outlining various methods of doing this. The problem is that I'm not well-versed enough in mathematics to be able to comprehend each of these papers to determine which, if any, of these methods are best for my application.

Here are several papers that I came across:

Just in case I phrased this incorrectly, I'll outline what I'm trying to do: I have a time series data set. I would simply like to know how much the series is like a straight line. For example, a time series derived from f(x)=2x would have a linearity of 1.0, f(x)=sin(x) would be something less, and a random data set would have a linearity of 0.0 or near-zero.

Any ideas on how to derive this measurement given an arbitrary time series?

-

First of all: By linear time series, do you mean a time series with a linear recurrence relation or a time series that is linear with respect to time? the two are entirely different things. The first paper you cited has the definiion of "linear" time series as the one with linear recurrence relation. In the beginning pages of the first paper, the author says that the series is assumed to be a standard $AR(p)$ process and then proceed to determine the linearity.

From your post, I think that you are not concerned with this kind of linearity. Let $X(t)$ be the time series where $t=1,2,\cdots$ Then take t as independent variable, $X(t)$ as dependent variable, fit a line to the data. From the fitted line, obtain the remainders $e(t)=\hat{X}(t)-X(t)$ and check whether they are significantly different from zero using a t-test.

In case you are not well-versed in all this, read up the basic stuff on curve fitting and t-test. The latter can be done very easily in all stat softwares and the former in many math softwares.

-
The test you outlined seems as though it would measure whether or not a data set is different from its linear regression. I don't really care about how different the set is from its linear regression. What I do care about is how straight of a line the set makes. An example of something that would fail your test of linearity but would still be rather straight would be a line that has a big kink in it at the beginning, but then straightens out. Here's a contrived example: i.imgur.com/sLL9O.png See how the set is very divergent from it's linear regression, yet is still quite straight? – Andy Christianson Dec 15 '11 at 19:10
Ok, one can always try piecewise linear regression for the case shown by you. That would solve it. Take a look at this en.wikipedia.org/wiki/Segmented_regression – NikBels Dec 15 '11 at 20:50
That's a fair solution given that appropriate segmentation points are known. In the example series I linked to, segmentation would work fine by splitting the set right after the kink at the beginning. Then testing for significant difference against the two sets would reveal that the second set, consisting of the majority of the data, would in fact be perfectly linear. The wiki page for segmented regression does not specify how many breakpoints to have and where to put them, so it's an incomplete solution. Any suggestions for deriving those values deterministically for arbitrary data sets? – Andy Christianson Dec 15 '11 at 22:47
The crudest and simplest method would recommend to "see" the break point by just plotting the data. When this can't be done (in most cases), there are test procedures to decide the significance of the break point etc. Take a look at the testing procedures given in the wiki page and bear in mind that there exist segmented regression methods for more than one break points. – NikBels Dec 16 '11 at 6:09
Thanks. I see this in the Test Procedures section: "The optimal value of the breakpoint may be found such that the Cd coefficient is maximum." So I segment the set into even pieces at some resolution then test each segment point for significance, culling any breakpoints deemed unjustifiable according to: "Cd needs to be significantly larger than Ra2 to justify the segmentation." What I end up with is a naive algorithm searching for justified segmentation points. Once the segmentation points are identified, it's trivial to test similarity with the segmented regression. Is this correct? – Andy Christianson Dec 16 '11 at 12:55