testLinearTrend: Test a time series for a linear trend with a permutation test

Description Usage Arguments Details Value Author(s) References Examples

View source: R/testLinearTrend.R

Description

The estimated slope of a linear trend within a time series is tested for significance with a permutation test (shuffling).

Usage

1
testLinearTrend(x, n = 1000, ret.slopes = F)

Arguments

x

numeric vector. Missing values are not allowed and it is assumed that the frequency, at which the observation took place, is constant.

n

integer. Number of permutations, should hold n ≥ 1000.

ret.slopes

logical. Return the slopes as obtained from the permutation procedure?

Details

The null hypothesis H0 is stated as 'no trend present' and the alternative hypothesis HA as 'trend present'. Please note that the test does not account for autocorrelation.

Value

List with entries

b

real number. The coefficient when x is regressed against time.

p.value

real number. The probability of observing a stronger trend than b under H0. If b<0 then p.value amounts to P(B<b) and P(B>b) otherwise.

slopes

numeric vector of length n. The slopes as obtained from the permutation procedure.

Author(s)

Original code provided by Pascal H.

References

Kundzewicz, Z. W., and A. Robson (Editors) (2000). "Detecting trend and other changes in hydrological data". World Climate Program - Water, WMO/UNESCO, Geneva.

Examples

1
2
3
4
5
x <- rnorm(100) + seq(0,5,length.out=100)
y <- testLinearTrend(x=x,n=1000,ret.slopes=TRUE)
par(mfrow=c(1,2))
plot(x,main=paste('slope:',round(y$b,3)))
hist(y$slopes)

hydro-giub/hydroBE documentation built on Sept. 20, 2019, 9:27 a.m.