3
$\begingroup$

I need to calculate statistical significance between two time series, each with 4500 terms. My null hypothesis is that $H_0: \mu=\mu_0$ (value in time t of first time series is equal to value in time t-1 of second time series). How can i calculate p value? Is Z test approved for p value calculation? How to get p value after z test? I have $\alpha=0.05$.

$\endgroup$
  • 1
    $\begingroup$ Welcome to Data Science SE! Better ask this question on cross validated. $\endgroup$ – Stereo Mar 1 '17 at 9:58
  • $\begingroup$ general advice is provided in R via: fortunes::fortune(264) $\endgroup$ – Henrik Mar 1 '17 at 15:14
0
$\begingroup$

I will rephrase you setup to make sure I understood it correctly.

You have two time series $x = (x_1, x_2, .., x_n)$ and $y = (y_1, y_2,..,y_n)$, where $n=4500$. You want to understand if $x_t = y_{t-1}$, where $t \in [1,n]$ and by $=$ means approximately equal in statistical sense.

There is one way but you have to make some assumptions.

In general a time series can be thought as a signal plus additional noise. The signal is an explicit function which models some phenomenon and the noise is some alteration of the output which is random by nature. Using this model you split $x_t$ and $y_{t-1}$ into something like:

$$x_t = s^{(x)}_t + w^{(x)}_t$$ $$y_{t-1} = s^{(y)}_{t-1} + w^{(y)}_{t-1}$$

where $s^{(x)}_t$ is the signal of $x$, $w^{(x)}_t$ is the noise of $x$, respectively $s^{(y)}_{t-1}$ is the signal of $y$, and $w^{(y)}_{t-1}$ is the noise in $y$. Notice that $s^{(x)}_t$ and $s^{(y)}_{t-1}$ are well determined and noises are random.

Using this notation the idea of approximately equal in statistical sense means that the signal is the same and if there are difference in samples, than the differences are caused by random components (aka. noises). This means that if you assume that signals are the same and remains only the noise. So what your null hypothesis is $H_0 : x_t-y_{t-1}=0$ can be written as: $$H_0 : s^{(x)}_t + w^{(x)}_t - s^{(y)}_{t-1} - w^{(y)}_{t-1} = 0$$ $$H_0 : w^{(x)}_t - w^{(y)}_{t-1} = 0$$

Now here comes the assumptions. You have two sorts of random variables (noises) which pose some difficulties when you are trying to apply tools based on central limit theorem.

One problem is that the random noises depends on time. You have to assume that the noise does not change with time, in both series. This is translated as independent and identically distributed or ($w^{(x)}_t = w^{(x)}$ and $w^{(y)}_{t-1} = w^{(y)}$).

So, if you assume that noises are independent and identically distributed your question can be worked out with a paired difference test. This means you can test if the differences depart significantly from $0$.

You can use a t-test dependent t-test for paired samples if you additionally assume that the difference is normally distributed. You cannot use z-test on paired differences because you do not know the variance of the difference's distribution (when you use sample variance for variance in a z-test, you fall into a t-test).

If you do not want to assume that the differences are normally distributed (that can be checked graphically at least with histograms or qq plots for skewness) you can use Wilcoxon signed-rank test, which should be fine for the number of samples you have. I would pick this test, for the same reason.

Attention: I restate again that those tests are valid if an only if the noises in both series are independent of time. Also you can test only if they different. You cannot prove that they are equal, you can only state that you do not have evidence that they are different, which for most cases should be enough.

$\endgroup$
0
$\begingroup$

I'm not sure if this helps, but did you know that you can COMPARE two ML models?

It's an API created by Sebastian Raschka (author of "Machine Learning with Python").

I find it very cool.

http://rasbt.github.io/mlxtend/ enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.