Learn R Programming

trend (version 0.0.1)

sens.slope: Sen's slope and intercept

Description

Computes Sen's slope for linear rate of change and the corresponding intercept

Usage

sens.slope(x, level = 0.95)

Arguments

x
an time series object of class "ts"
level
the level of significance

Value

  • A list of class "trend.test".
  • b.senThe value of Sen's slope
  • b.sen.up, b.sen.loThe corresponding value of Sen's slope for the upper (lower) confidence limit
  • interceptThe intercept
  • nobsNumber of records
  • DA vector of individual slopes
  • varSThe variance of the Mann-Kendall score
  • conf.intThe confidence intervall for the upper and lower bounds

Warning

Current Version is for complete observations only.

Details

This test computes both the slope (i.e. linear rate of change) and intercept according to Sen's method. First, a set of linear slopes is calculated as follows: $$d_{k} = \frac{x_j - x_i}{j - i}$$ for $\left(1 \le i < j \le n \right)$, where d is the slope, x denotes the variable, n is the number of data, and i, j are indices. Sen's slope is then calculated as the median from all slopes: $b_{Sen} = \textnormal{median}(d_k)$. The intercepts are computed for each timestep i as given by $$a_i = x_i - b_{Sen} \times i$$ and the corresponding intercept is as well the median of all intercepts. This function also computes the upper and lower confidence limits for sens slope.

References

Hipel, K.W. and McLeod, A.I., (2005). Time Series Modelling of Water Resources and Environmental Systems. http://www.stats.uwo.ca/faculty/aim/1994Book/. Sen, P.K., (1968): Estimates of the regression coefficient based on Kendall's tau, Journal of the American Statistical Association, 63, 1379--1389.

See Also

mk.test, zyp.sen, lm

Examples

Run this code
data(maxau) ; plot(maxau[,"s"])
sen.res <- sens.slope(maxau[,"s"])
t <- (1:(length(maxau[,"s"])))
s.pred <- sen.res$intercept + sen.res$b.sen * t
s.pred.ts <- ts(s.pred)
tsp(s.pred.ts) <- tsp(maxau[,"s"])
lines(s.pred.ts, lty=2)

Run the code above in your browser using DataLab