overall_trend: Overall trend analysis

View source: R/overall_trend.R

overall_trendR Documentation

Overall trend analysis

Description

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.

Usage

overall_trend(data, predictor, responses)

Arguments

data

A ⁠data frame⁠ containing the variables for the model, including species, year, month, lon, lat, tme and ele.

predictor

A charactervector of predictor variable names representing a temporal variable (year_month).

responses

A character vector of response variable names to analyze.

Details

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.

Value

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).

Examples


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)


SppTrend documentation built on Feb. 7, 2026, 5:07 p.m.