Learn R Programming

wq (version 0.4.3)

seasonTrend: Determine seasonal trends

Description

Finds the trend for each season of a time series (matrix or vector) and indicates statistical significance.

Usage

seasonTrend(x, first, last, type = c("slope", "slope.pct"),
    method = c("mk", "lin"), plot = FALSE, xlab = NULL,
    ylab = NULL, miss = FALSE, legend = FALSE, ...)

Arguments

Value

A data frame with the following fields:trendTheil-Sen slope in original units per year, or percent per year.pp-value for the trend according to the Mann-Kendall test.missingProportion of slopes joining first and last fifths of the data that are missing.seasonSeason number.tsnameName of time series.

Details

The slope estimate and its significance are calculated for each season and time series. If type = "slope.pct", the slopes are multiplied by 100 and divided by the overall mean (not the median, which can be zero even in cases where a trend estimate is useful). If method = 'mk'. the Theil-Sen slope is calculated with the Mann-Kendall test of significance. Otherwise, linear regression is used to determine the slope and significance.

If plot = TRUE, each time series is represented by a box plot showing the trend for each season. The fill colour of the box indicates whether the trend is significant or not (the legend is optional). When method = 'mk', the proportion of slopes joining the first and last fifths of the data is calculated. If this value is 0.5 or more, the corresponding trends can be omitted by setting miss = TRUE; the trend results may not be a good representation of the entire period and a different time window should be considered.

Parameters can be passed to the plotting function, in particular, to facet_wrap in ggplot2. The most useful parameters here are ncol (or nrow), which determines the number of columns (or rows) of plots, and scales, which can be set to "free_x" to allow the x-axis to change for each time series.

See Also

mannKen, plotSeason, facet_wrap

Examples

Run this code
x <- sfbayChla
seasonTrend(x, first=1978, last=2009, ncol = 4, plot = TRUE, legend = TRUE)
seasonTrend(x, type = 'slope.pct')

Run the code above in your browser using DataLab