View source: R/overall_trend.R
| overall_trend | R Documentation |
Calculates the overall temporal trend (OT) of selected response variables across the entire dataset. This trend integrates both environmental change and the cumulative effects of sampling bias, and serves as a neutral reference against which species-specific temporal trends are evaluated.
overall_trend(data, predictor, responses)
data |
A |
predictor |
A |
responses |
A |
Longitude (lon) values are transformed to a 0-360 range to ensure statistical consistency near the antimeridian.
A key feature of this function is its specialized handling of latitude. Because the Equator is set at 0, latitude values in the Southern Hemisphere are negative.
To ensure that a direction shift is interpreted consistently across the globe (where a negative increase in the South corresponds to a positive increase in the North), the function employs two complementary approaches:
Hemispheric split: It divides the records based on their location (lat < 0 for South and lat > 0 for North) and performs separate analyses for each.
Global analysis: It performs an analysis using the complete dataset (Global) by transforming all latitudes into absolute values (abs(lat)). This allows for a unified global trend estimation.
Note that this hemispheric division and absolute transformation logic is applied exclusively to the latitude (lat) variable.
A data frame with trend statistics, including:
responses: The name of the variable analyzed.
trend: Slope of the linear model (rate of change over time).
t: t-statistic of the model.
pvalue: Statistical significance of the overall trend.
ci_95_max, ci_95_min: 95\
n: Sample size for the specific species/hemisphere subset
hemisphere: Geographic context (North, South, or Both for global comparison).
data <- data.frame(
species = sample(paste0("spp_", 1:10), 500, replace = TRUE),
year = sample(1950:2020, 500, replace = TRUE),
month = sample(1:12, 500, replace = TRUE),
lon = runif(500, -10, 20),
lat = runif(500, 30, 70),
tme = rnorm(500, 15, 10)
)
data$year_month <- data$year + data$month * 0.075
predictor <- "year_month"
responses <- c("lat", "lon", "tme")
overall_trend_result <- overall_trend(data, predictor, responses)
print(overall_trend_result)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.