correlating three time-series in R

classic Classic list List threaded Threaded
4 messages Options
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

correlating three time-series in R

Tania Bird
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*

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-ecology mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: correlating three time-series in R

Bob O'Hara
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:

> 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*
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-ecology mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
>


--
Bob O'Hara
NOTE: this email will die at some point, so please update you records to
[hidden email]

Institutt for matematiske fag
NTNU
7491 Trondheim
Norway

Mobile: +49 1515 888 5440
Journal of Negative Results - EEB: www.jnr-eeb.org

_______________________________________________
R-sig-ecology mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: correlating three time-series in R

Tania Bird
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 <[hidden email]> wrote:

> 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:
>
>> 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*
>>
>>         [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-ecology mailing list
>> [hidden email]
>> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
>>
>>
>
> --
> Bob O'Hara
> NOTE: this email will die at some point, so please update you records to
> [hidden email]
>
> Institutt for matematiske fag
> NTNU
> 7491 Trondheim
> Norway
>
> Mobile: +49 1515 888 5440
> Journal of Negative Results - EEB: www.jnr-eeb.org
>
> _______________________________________________
> R-sig-ecology mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
>

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-ecology mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: correlating three time-series in R

Thomas Petzoldt
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:

> 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 <[hidden email]> wrote:
>
>> 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:
>>
>>> 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*
>>>
>>>          [[alternative HTML version deleted]]
>>>
>>> _______________________________________________
>>> R-sig-ecology mailing list
>>> [hidden email]
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
>>>
>>>
>>
>> --
>> Bob O'Hara
>> NOTE: this email will die at some point, so please update you records to
>> [hidden email]
>>
>> Institutt for matematiske fag
>> NTNU
>> 7491 Trondheim
>> Norway
>>
>> Mobile: +49 1515 888 5440
>> Journal of Negative Results - EEB: www.jnr-eeb.org
>>



--
Thomas Petzoldt
Technische Universitaet Dresden
Faculty of Environmental Sciences
Institute of Hydrobiology
01062 Dresden, Germany
http://tu-dresden.de/Members/thomas.petzoldt

-- limnology and ecological modelling --

_______________________________________________
R-sig-ecology mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
Loading...