0

I am new to time series analysis and am having issues creating an ecological time series dataset in R.

My study is looking at change in stream community following an invasive species removal event. Community data was collected at multiple dates before and after removals in multiple streams and I am interested in how long changes in community persist following the removal, with expected influence of stream characteristics on the magnitude and length of removal effects. I have created a dataset (sample below) of dissimilarity values comparing community at each time point with the community at the earliest sampling date in each stream.

Timeline Stream 1    Stream 2    Stream 3    Stream 4
-19      NA          NA          NA          0
-18      NA          NA          NA          0.271255061
-17      NA          NA          NA          0.501858736
-16      NA          NA          NA          0.597650514
-15      NA          NA          NA          0.111821086
-14      NA          NA          NA          0.572167372
-13      NA          NA          NA          0.398550725
-12      NA          NA          NA          NA
-11      NA          NA          NA          NA
-10      NA          NA          NA          0.491166078
-9       NA          NA          NA          0.429824561
-8       NA          NA          0           0.396138637
-7       NA          NA          0.416184971 0.253012048
-6       NA          NA          0.377593361 0.184313725
-5       0           0           0.34927454  0.455938697
-4       0.301852959 0.151048951 0.300859599 0.463414634
-3       0.175508896 0.177892919 0.383909476 0.591240876
-2       0.2719954   0.276716207 0.338422392 0.74863388
-1       0.378787879 0.289044289 0.321074965 0.382857143
0        0.48840382  0.492374728 0.480812641 0.279352227
1        0.205225912 0.638044914 0.420965058 0.42394822
2        0.307830245 0.412844037 0.306707815 0.176870748
3        0.795081967 0.827380952 0.523809524 0.53125
4        0.665144597 NA          0.457983193 0.460207612
5        0.800165153 NA          0.395833333 0.429467085
6        0.832073887 NA          0.435897436 0.536082474
7        0.760904685 NA          0.483870968 0.535460993
8        0.68080185  NA          0.648854962 0.56466877
9        0.636092468 NA          0.722666667 NA
10       0.866552609 NA          0.615       NA
11       0.635135135 NA          0.605364312 NA
12       0.530864198 NA          0.379032258 NA
13       0.648023863 NA          0.562945368 NA
14       0.660060976 NA          0.68877551  NA
15       0.548478415 NA          0.454545455 NA
16       0.601763409 NA          0.558194774 NA
17       0.676628352 NA          0.588235294 NA
18       0.741626794 NA          0.43776824  NA

My biggest challenge is figuring out how to code the time in R. Due to the time needed to fully sample a stream, not all streams could be sampled on the same day and a full suite of sampling often straddled months. During data collection, the project adopted a time code of cycles (i.e. the first sampling event was labeled "cycle 1", the second "cycle 2", and so on), so there are not set days, months, or frequency to the sampling. Additionally, sampling began later in some streams (streams 1 and 2 were first sampled in cycle 4) and sampling in several streams ended early (stream 2 was only sampled through cycle 17). Streams could also be dry in some cases, in which case they were not sampled for the relevant cycles (stream 4). Finally, most streams were sampled twice in cycle 8, immediately before and immediately after invasive species removals, but invasive removal was delayed in one stream (4) and took place between cycles 20 and 21. To account for this, I've currently adjusted the timeline so that sampling immediately following the removal is coded as time 0; pre-removal time points are negative and additional post removal sampling is positive.

Is there any way to create a time series of this data in R and preserve all these complicated characteristics?

  • Does this solve your problem? https://stackoverflow.com/questions/24699851/convert-multiple-irregular-time-series-into-regular-time-series – Prasanna S Dec 12 '18 at 02:26
  • 1
    welcome to Stack Overflow. It seems difficult to have a time series if none of the variables you recorded is actually time... your "timeline" variable shows a chronological order of events (from oldest to newest), but tells nothing about the duration of the different lapses... If you wanted time series, the best idea is to record dates and times. – PavoDive Dec 12 '18 at 02:27
  • @PrasannaS, that was helpful, thanks – Avery Scherer Dec 19 '18 at 21:13

0 Answers0