Solved – Statistical significance in time series (R)

anovahypothesis testingrstatistical significancetime series

Stats newb here, I have to determine if two time series are really different instead of being part of the same population with noise in the samples.

The data is a comparison between two algorithms ctr by day, a control one (a) and an experimental (b)

Plot of algorithms comparison

a      b
1 3.6162 3.6808
2 3.8967 4.0155
3 4.0669 4.2945
4 4.3680 4.4321
5 4.0558 4.2071
6 3.9234 3.9131
7 3.7467 3.9533

We can see the mean is bigger in b (4.070914 vs 3.953386)
But are they statistically significant?
To see that im doing ANOVA to get the p-value and compare to the alpha of 0.05 as far as i know, if it is smaller then the null hypothesis H0 of being equals is false.

The problem is when i do the oneway.test i get a p-value really big, am i doing something wrong?

data
        x name
1  3.6162    a
2  3.6808    b
3  3.7467    a
4  3.8967    a
5  3.9131    b
6  3.9234    a
7  3.9533    b
8  4.0155    b
9  4.0558    a
10 4.0669    a
11 4.2071    b
12 4.2945    b
13 4.3680    a
14 4.4321    b

 oneway.test(x~name, data = data)

    One-way analysis of means (not assuming equal variances)

data:  x and name
F = 0.77477, num df = 1.00, denom df = 11.97, p-value = 0.3961 

Thanks a lot!

Best Answer

As the comment pointed out, the pairing of observation is crucial in this type of data. Instead of treating the data into 2 groups, we introduce a variable d to denote the difference between group 1 and group 2 for each observation.

Then the t-statistics is calculated by

formula
(source: fao.org)

To do this in r, just use the following

a<-c(3.6162,3.8967,4.0669,4.368,4.0558,3.9234,3.7467)
b<-c(3.6808,4.0155,4.2945,4.4321,4.2071,3.9131,3.9533)

t.test(a,b,paired=T)

Then you can see the output,

Paired t-test

data:  a and b
t = -3.6651, df = 6, p-value = 0.01052
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -0.19599321 -0.03906393
sample estimates:
mean of the differences 
         -0.1175286