Skip to content

correlating three time-series in R

4 messages · Bob OHara, Tania Bird, Thomas Petzoldt

#
I have three data sets of abundances through time for plants, insects and
reptiles.
There are 6 samples over a ten year period (all taxa sampled at the same
time).
I recognise this is a small data set for time series.

I would like to correlate the time series to see if
a) increases in abundance of one taxon are correlated to another, and
b) to see if the correlation between plants:insects is greater than
plants:reptiles.

I thought to use the cross-correlation function in R
e.g.  ccf(insects, reptiles)

Currently the data is in one dataframe with time as one column and
abundance of each taxa is the next three columns.

How do I convert the data to a time.series format as given in the R
example?

How can I compare the two ccf outputs?

Thanks

Tania


Tania Bird MSc
*"There is a sufficiency in the world for man's need but not for man's
greed" ~ Mahatma Gandhi*
#
You can pass the columns to ccf() directly:

df <- data.frame(x=rnorm(6), y=rnorm(6))
ccf(df$x, df$y)
print(ccf(df$x, df$y))

You should probably also check the time series task view: 
<https://cran.r-project.org/web/views/TimeSeries.html>, in particular 
the zoo package, to see what can be done with irregular time series.

But with 6 data points I'd be surprised if you have the power to detect 
anything that doesn't jump out when you simply plot the data.

Bob
On 26/07/17 11:07, Tania Bird wrote:

  
    
#
Thanks Bob
This is great,

The correlation does jump out when I plot it- I am just looking for a
quantified way of testing what I see. If there is a more appropriate test
I'd be happy to learn.

Many thanks



Tania Bird MSc
*"There is a sufficiency in the world for man's need but not for man's
greed" ~ Mahatma Gandhi*

https://www.linkedin.com/in/taniabird
https://taniabird.webs.com
On 26 July 2017 at 12:51, Bob O'Hara <bohara at senckenberg.de> wrote:

            

  
  
#
Hi,

a compact, practical and well readable introduction to some time series 
methods can be found in chapter 6 of Kleiber and Zeileis (2008): Applied 
Economics with R. This book is also well suited for ecologists and 
builds a fundamental for further reading and understanding.

Thomas

Am 26.07.2017 um 12:05 schrieb Tania Bird: