Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

seasonTrend

Determine seasonal trends


Description

Finds the trend for each season and each variable in a time series.

Usage

seasonTrend(x, plot = FALSE, type = c("slope", "relative"), pval = 0.05,
  ...)

Arguments

x

Time series vector, or time series matrix with column names

plot

Should the results be plotted?

type

Type of trend to be plotted, actual or relative to series median

pval

p-value for significance

...

Further options to pass to plotting function

Details

The Mann-Kendall test is applied for each season and series (in the case of a matrix). The actual and relative Sen slope (actual divided by median for that specific season and series); the p-value for the trend; and the fraction of missing slopes involving the first and last fifths of the data are calculated (see mannKen).

If plot = TRUE, each season for each series is represented by a bar showing the trend. The fill colour indicates whether p < 0.05 or not. If the fraction of missing slopes is 0.5 or more, the corresponding trends are omitted.

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_y" to allow the y-axis to change for each time series. Like all ggplot2 objects, the plot output can also be customized extensively by modifying and adding layers.

Value

A data frame with the following fields:

series

series names

season

season number

sen.slope

Sen slope in original units per year

sen.slope.rel

Sen slope divided by median for that specific season and series

p

p-value for the trend according to the Mann-Kendall test.

missing

Proportion of slopes joining first and last fifths of the data that are missing

Author(s)

Alan Jassby, James Cloern

See Also

Examples

x <- sfbayChla
seasonTrend(x)
seasonTrend(x, plot = TRUE, ncol = 4)

wql

Exploring Water Quality Monitoring Data

v0.4.9
GPL-2
Authors
Alan Jassby [aut], James Cloern [ctb], Joseph Stachelek [ctb, cre]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.