trend.1D: Linear trend analysis

View source: R/climatology.R

trend.1DR Documentation

Linear trend analysis

Description

Atomic function for (linear) trend analysis

Usage

trend.1D(
  ts,
  dates,
  method = c("pearson", "spearman", "kendall"),
  return.pvalue = FALSE,
  conf.level = 0.95
)

Arguments

ts

Numeric vector containing a time series

dates

Dates vector associated to the records in ts. Standard format, as returned for instance by getRefDates

method

Correlation method. Passed to cor.test.

return.pvalue

Logical. Should p-values be returned instead of correlation coefficient estimates?. Default to FALSE.

conf.level

Numeric value indicating the confidence level for the significance test. Passed to cor.test.

Details

The function can be conveniently wrapped using climatology. See examples.

Author(s)

J Bedia

See Also

climatology, for computing climatological trend maps from grids

Examples


require(climate4R.datasets)
require(visualizeR)
# Simulate a positive trend
set.seed(1)
ts <- runif(min = 21, max = 23.5, n = 100) + seq(.1, .15, length.out = 100) * 10
dates <- paste0(1901:2000,"-01-01 00:00:00 GMT")
plot(1901:2000, ts, ty = 'l', ylab = "Simulated Mean Temp (degC)", xlab = "Year")
abline(reg = lm(ts ~ I(1901:2000)), col = "red", lty = 2)
trend.1D(ts, dates, return.pvalue = FALSE) # Default to Pearson's r
trend.1D(ts, dates, return.pvalue = TRUE)
# An example of how to compute a trend map using climatology as a wrapper for trend:
data("EOBS_Iberia_tas")
dates <- getRefDates(EOBS_Iberia_tas)
tau.estimate <- climatology(EOBS_Iberia_tas,
                            clim.fun = list(FUN = "trend.1D", dates = dates, method = "kendall"))
spatialPlot(tau.estimate, backdrop.theme = "coastline")
# Adding significant trend points is usually needed: 
pval.estimate <- climatology(EOBS_Iberia_tas,
                             clim.fun = list(FUN = "trend.1D",
                                             dates = dates,
                                             method = "kendall",
                                             return.pvalue = TRUE))
sig.points <- visualizeR::map.stippling(clim = pval.estimate, threshold = 0.05, condition = "LT", 
                                        pch = 19, cex = .25, col = "purple")
spatialPlot(tau.estimate, backdrop.theme = "coastline", sp.layout = list(sig.points))


SantanderMetGroup/transformeR documentation built on Nov. 25, 2024, 1:25 p.m.