0
$\begingroup$

I have 2 lists, representing a time series:

list_a = [23,43,29,45,6,12,240]
list_b = [13,23,11,35,60,52,40]

i.e. list_a[0] is value in first year....list_a[6] is values in 7th year.

I want to check if increase in values in list_a is followed by an increase or decrease in list_b in the subsequent year. Is there a statistical test that will allow me to do that? The key is looking at the direction of change rather than the magnitude of change.

Even better if I can say something about the temporal linkage between the two lists. I.e, perhaps increase in list_a precedes changes in list_b by 2 years.

$\endgroup$
  • $\begingroup$ Your feedback will be appreciated. $\endgroup$ – rnso Nov 2 '14 at 17:17
2
$\begingroup$

Try correlation in R as follows:

> list_a = c(23,43,29,45,6,12,240)
> list_b = c(13,23,11,35,60,52,40)
> 
> a = list_a
> b = list_b
> 
> dd = data.frame(a,b)
> 
> dd$diffa = c(0,diff(a))
> dd
    a  b diffa
1  23 13     0
2  43 23    20
3  29 11   -14
4  45 35    16
5   6 60   -39
6  12 52     6
7 240 40   228
> 
> with(dd[-1,], cor.test(b, diffa))

        Pearson's product-moment correlation

data:  b and diffa
t = -0.008, df = 4, p-value = 0.994
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 -0.8129184  0.8101954
sample estimates:
         cor 
-0.003988337 

Edit:

For using other methods:

with(dd[-1,], cor.test(b, diffa, method='spearman'))
with(dd[-1,], cor.test(b, diffa, method='kendall'))

A graph will clearly show how much delay is there. Such graph can be obtained with following code:

dd$time = rownames(dd)
mm = melt(dd[-3], id='time')
ggplot(mm, aes(x=time, y=value, color=variable, group=variable))+geom_point()+geom_line()

enter image description here

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ thanks! I am looking at granger causality right now, not sure if statistically pearson's is the right metric. $\endgroup$ – user308827 Nov 2 '14 at 18:06
  • $\begingroup$ Other methods of correlation can be specified as mentioned in my edit above. $\endgroup$ – rnso Nov 3 '14 at 0:55
  • 1
    $\begingroup$ A graph will be helpful to find the delay. The code for such graph has been added above. $\endgroup$ – rnso Nov 3 '14 at 1:43
  • $\begingroup$ @user308827 I was going to suggest Granger causality $\endgroup$ – shadowtalker Nov 3 '14 at 10:24
  • $\begingroup$ thanks @ssdecontrol, do you know why that would be better than pure correlation? $\endgroup$ – user308827 Nov 3 '14 at 13:07

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.