trend.1D: Linear trend analysis

Description Usage Arguments Details Author(s) See Also Examples

View source: R/climatology.R

Description

Atomic function for (linear) trend analysis

Usage

1
2
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 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"))
plotClimatology(tau.estimate)
# 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 <- transformeR:::map.stippling(clim = pval.estimate, threshold = 0.05, condition = "LT", 
                            pch = 19, cex = .25, col = "purple")
plotClimatology(tau.estimate, sp.layout = list(sig.points))

SantanderMetGroup/transformeR documentation built on April 1, 2020, 5:42 a.m.