# Test for Equivalence of two time series

I wish to test whether two time series are equal. So I believe best way to define equivalence is that given two time series, say $$\{x1_t\}$$ and $$\{x2_t\}$$, we show that both the series come from the same stochastic process, $$\{X_t\}$$.

How to do this?

• Hi: you'd probably have to specify the stochastic process to test something like that. Just testing that they come from the same stochastic process is too general and probably not possible. Hopefully someone else can say more. I've never seen a problem like that discussed in the time-series literature or texts etc. – mark leeds Sep 8 '19 at 13:52
• That's the idea. It's something like fitting the best model to each of them and then compare whether both these models are same or not. So by analyzing either of the series we will have some idea about the stochastic process. As in we may know that they'd follow, say, an AR1. But the coefficient would remain unknown. But we'd have estimates from both models and we can test the hypotheses that they are both same. Hope this makes sense. – Dayne Sep 8 '19 at 18:16
• Hi: If you specify an actual model, then it's a different story and there are ways of doing that but it depends on the underlying model being tested. For an AR(1), you could estimate the first series and get the AR(1) coeffcient estimate, say $\phi_1$. Then, for the second series, do a test of whether the coefficient, $\phi_2$ = $\phi_1$, by estimating another AR(1). – mark leeds Sep 9 '19 at 3:02
• Note that another way of approaching your problem is by comparing the prediction accuracy of the respective model's out of sample forecasts. That's essentially an econometrics field in itself and there are MANY, MANY papers by clark and mcracken on this topic. I wouldn't do it justice by even attempting to describe it here. – mark leeds Sep 9 '19 at 3:04
• I just realized that, IMHO, this kind of question is probably more suited for the econometrics stack exchange group. – mark leeds Sep 9 '19 at 3:05

Hi: Testing for H0: $$\phi_2 = \phi_1$$ in an AR(1) where $$\phi_1$$ can be done using the offset function in R. Do you use R and, if so, are you familiar with the offset function ? If so, I can explain how to do this in more detail.

Note that what I will do here is definitely an approximation ( econometricians might cringe. I'm not sure) because $$\phi_1$$ is an estimate from the original model, rather than a true constant. But, for "government" work, this approximation might be okay. I don't know how precise you want to be.

Okay. So, suppose you're using R and the estimate of the AR(1) for the first series is $$\phi_1$$. Then, you want to use R to test whether the coefficient of the AR(1) for the second series is also $$\phi_{1}$$. You should look at the help for offset by doing ?offset but what it does in a nutshell is allow one to put constants in the call to lm where these constants are viewed as coefficients not to be estimated. They are assumed given.

So, suppose you wanted to simply estimate an AR(1). Since, we don't have to worry about stationarity conditions ( by definition, $$\phi$$ from an AR(1) has to be between -1.0 and 1.0 ), let's just use lm() rather than arima().

The first step is to lag the original series so if the first series is $$y1$$, let's assume that y1lag is the same series but lagged by 1 element. ( just do y1lag <- c(NA, y1[-1] ) ).

So, the standard call to lm ( assuming zero intercept ) would be

ARlm1 <- lm(y1 ~ -1 + y1lag, na.ction = na.omit, data = whatever) and then you could do a summary(AR1lm) to get whatever you want including the AR1 coefficient estimate, call it $$\hat{\phi}_1$$.

Now, suppose you have the second series, along with its lag so $$y2$$ and $$y2lag$$.

So, to run the same model you would do

ARlm2 <- lm(y2 ~ -1 + y2lag , na.action = na.omit, data = whatever).

But we don't want to use the above call in this case. We want to test something. The way to do this is to force the $$\phi_1$$ estimate on to the model and then test whether another coefficient is zero. The call which will allow for such a test is:

AR1lm2test<- lm(y2 ~ -1 + offset( $$\hat{\phi}_1$$ * y2lag) + y2lag, na.action = na.omit, data = whatever).

Do you see what I'm doing with offset ? I force $$\phi_1$$ to be the coefficient of the lagged term but then I add the ylag term on the end which is not offsetted. You can think of what above is doing as testing H0: $$\phi_1 + \phi_2 = \phi_1$$ versus $$\phi_1 + \phi_2 \neq \phi_1$$

In this manner, we end up pseudo estimating an AR1, but the coefficient estimate outputted ( $$\phi_2$$, the coefficient of $$y2lag$$ ) represents how far away from the null we are. This coefficient can be tested to see whether it's value is zero. If the null hypothesis that it's zero cannot be rejected, then this is evidence that $$\phi_2$$ does equal $$\phi_1$$. If the test indicates that there is enough evidence to reject the null, then this is evidence that the $$\phi_2$$ does not equal $$\phi_1$$. The tstat from the output of summary can be used to do the test.

I hope this made sense. Again, even if it does makes sense, I still should emphasize that this procedure is approximate. Another similar ( maybe slightly better ) approach would be to concatenate the two series and then do some test for structural change but then you have to start using other packages along with the arima function and things get messier. Sticking with lm allows for the use of offset. I'm not sure if the base arima() function in R allows for offset. It might but the approach described will be more straightforward while sacrificing some rigor.

                                                        Mark


Coming back to this after some time away so it's an addendum.

I just realized that the call to AR1lm2test should be such that the sum of the coefficients $$\hat{\phi_1}$$ + $$\hat{\phi_2}$$ needs to be restricted to be between -1.0 and +1.0 and the lm() function doesn't allow for this type of constraint. There are two ways to deal with this problem.

1) Run AR1lm2test and, if the constraint holds, then everything is fine and the output can be trusted. If the restriction doesn't hold, then the output has no useful meaning.

2) Check out if there is a version of arima() that allows for the use of offset. If there is such a function, then the restriction will be automatically enforced by that arima() function. There are many packages that have various arima() functions. The CRAN Time Series task site is useful for finding packages that do things in time-series.

• Yes I work in R. I have never used offset function in R. I understand that government work has low reputation. But from what I have observed Corporate is worse. Anyway, that's not the topic. My interest is academic, so I am looking for a thorough answer. But I am very much interested in how to do this with offset. – Dayne Sep 9 '19 at 16:17
• I have to leave but I'll send you some example R code later tonight. I was kidding about "govt" work and corporate is worse but do keep in mind that proposed prcocedure is an approximation because the first AR(1) estimate has uncertainty in it and the procedure I describe assumes that it's a constant. I'll assume that you have the value of $\phi_1$ because, if you do, then the procedure only requires a call to lm() ( rather than to arima() ) which makes things easier. – mark leeds Sep 9 '19 at 19:45
• This helps. I think for simple models this will work. As lags increase this will get messier. For SARMA, this will not work as the models are non-linear. Anyway, I will check for offset use in ARIMA. And I don't think this is strictly an approximation. An approximation would be fitting arima on one series. Fitting the model obtained from first series on the second series and see if the residuals obtained are white noise (using say Box test). Then one can do this exercise by flipping series. If in both cases the same model gives white noise errors then coefficients are reasonably same. – Dayne Sep 10 '19 at 0:58
• Thanks also for bringing up concatenation (or joining). I was hoping for this. Actually I have been working on this thing only. But yhe idea is that we need to leave gap while joining the series so that model doesn't think that last point of the first series and first point of the last series are not dependent. But if we leave space in between estimation must be done in state-space approach. After that also there tests such wald's test or Andrew's tests that will work. – Dayne Sep 10 '19 at 1:03
• @Dayne: I'm glad it helped. Good luck with what sounds like an interesting problem. – mark leeds Sep 10 '19 at 5:26