SER: Short-period Environmental Regime (SER)

View source: R/SER.R

SERR Documentation

Short-period Environmental Regime (SER)

Description

Short-period Environmental Regime (SER)

Usage

SER(
  env_date,
  env_val,
  sample_date,
  days_bf = NULL,
  type = NULL,
  include_sample.date = FALSE,
  include_successive = FALSE,
  simplify = TRUE
)

Arguments

env_date

a vector containing dates that a environmental variables were measured, make sure it is in date format before passing it to the function

env_val

a vector containing environmental values for corresponding dates in **env_date**, make sure it is in numeric format

sample_date

a vector containing days for biological sampling date for initiation of the experiment (measurements) should be included as the first element of the vector, and also make sure it is in date format

days_bf

a numeric vector representing N days (months or years) before the sampling date; if days_bf = NULL (by default), then days_bf = days (months/years) between two successive sampling dates

type

a character vector indicating whether the 'days_bf' is "day", "month", or "year" specific

include_sample.date

TRUE or FALSE (by default), indicates whether environmental data at sample.date is included or not during the calculation

include_successive

TRUE or FALSE (by default), indicates whether environmental data between two successive sampling dates is used for calculating 'BetwSamT' environmental regime

simplify

TRUE (by default) or FALSE, indicates whether the simplified result is returned. Set simplify = TRUE if you want to check the intermediate results

Details

SER is extremely useful in linking time-series environmental variables to discrete biological responses. Specifically, SER function summaries time-series environmental variables into indices covering different facets i.e., magnitude, frequency, and rate of change of the data in any focused period, which are typically masked by using simple average or median values in conventional way. In total, 11 elementary indices were developed, and users can developed their own environmental regimes by changing the argument **days_bf**. Besides, it is recommended that users carefully read the vignette and check published studies (Guo et al. 2020, 2021; Wu et al. 2022) that used SER to make most out of your own data set with this package.

Value

a data frame with the first column as the sampling date(s), whereas the rest columns are calculated indices.

Examples


# inspect the discharge data
str(hydro_df)

# inspect the sample date data
str(sample_date)

#############
#day- specific SER
# calculate short-period hydrological indices
SER(hydro_df$Date, hydro_df$Discharge, sample_date)
SER(hydro_df$Date, hydro_df$Discharge, sample_date, days_bf=c(3,7,14))
SER(hydro_df$Date, hydro_df$Discharge, sample_date, days_bf=c(3,7,14), include_sample.date = TRUE)
SER(hydro_df$Date, hydro_df$Discharge, sample_date, days_bf=c(3,7,14), include_successive = TRUE)
SER(hydro_df$Date, hydro_df$Discharge, sample_date, days_bf=c(3,7,14),
include_sample.date = TRUE, include_successive = TRUE)

##################
# month-specific SER
# only include the first and last dates in sample_dates
test.date.m <- sample_date[c(1, 13)]
SER(hydro_df$Date, hydro_df$Discharge, test.date.m, days_bf = NULL, type = "month")
SER(hydro_df$Date, hydro_df$Discharge, test.date.m, days_bf = c(2, 4, 6),
type = "month", include_sample.date = TRUE)
SER(hydro_df$Date, hydro_df$Discharge, test.date.m, days_bf = c(2, 4, 6),
 type = "month", include_successive = TRUE)
SER(hydro_df$Date, hydro_df$Discharge, test.date.m, days_bf = c(2, 4, 6),
type = "month", include_sample.date = TRUE, include_successive = TRUE)

##################
# year-specific SER
# generate data for testing
test.df <- data.frame(Date = seq(ymd("2010-1-1"), ymd("2020-1-1"), by="1 day"),
                      Env = sample( hydro_df$Discharge, 3653, replace = TRUE))
test.date.y <-  seq(ymd("2012-1-1"), ymd("2020-1-1"), by="2 year")
SER(test.df$Date, test.df$Env, test.date.y, days_bf = NULL, type = "year")
SER(test.df$Date, test.df$Env, test.date.y, days_bf = c(2),
type = "year", include_sample.date = TRUE)
SER(test.df$Date, test.df$Env, test.date.y, days_bf = c(2),
type = "year", include_successive = TRUE)
SER(test.df$Date, test.df$Env, test.date.y, days_bf = c(2), type = "year",
include_successive = TRUE, include_sample.date = TRUE)

kun-ecology/SER documentation built on Dec. 2, 2023, 10:13 p.m.