openair (version 0.5-2)

MannKendall: Mann-Kendall trend tests

Description

Mann-Kendall tests for trend with Sen-Theil slope estimates.

Usage

MannKendall(mydata,
pollutant = "nox",
deseason = FALSE,
type = "default",
avg.time = "month",
statistic = "mean",
percentile = NA,
data.thresh = 0,
simulate = FALSE,
alpha = 0.05,
dec.place = 2,
ylab = pollutant,
xlab = "year",
y.relation = "same",
cols = NULL,
main = "",
auto.text = TRUE,
autocor = FALSE,
slope.percent = FALSE,
date.breaks = 7, ...)

Arguments

mydata
A data frame containing the field date and at least one other parameter for which a trend test is required; typically (but not necessarily) a pollutant.
pollutant
The parameter for which a trend test is required. Mandatory.
deseason
Should the data be de-deasonalized first? If TRUE the function stl is used (seasonal trend decomposition using loess). Note that if TRUE missing data are first linearly interpolated because stl
type
type determines how the data are split i.e. conditioned, and then plotted. The default is will produce a single plot using the entire data. Type can be one of the built-in types as detailed in cutData e.g. "season"
avg.time
Either "month" (the default), or "year". Determines whether monthly mean or annual mean trends are plotted. Note that for "annual", six or more years are required.
statistic
Statistic used for calculating monthly values. Default is "mean", but can also be "percentile". See time.average for more details.
percentile
Percentile value(s) to use if statistic = "percentile" is chosen. Can be a vector of numbers e.g. percentile = c(5, 50, 95) will plot the 5th, 50th and 95th percentile values together on the same plot.
data.thresh
The data capture threshold to use (%) when aggregating the data using avg.time. A value of zero means that all available data will be used in a particular period regardless if of the number of values available. Conversely, a value of
simulate
Should simulations be carried out to determine the Mann-Kendall tau and p-value. The default is FALSE. If TRUE, bootstrap simulations are undertaken, which also account for autocorrelation.
alpha
For the confidence interval calculations of the slope. The default is 0.05. To show 99% confidence intervals for the value of the trend, choose alpha = 0.01 etc.
dec.place
The number of decimal places to display the trend estimate at. The default is 2.
ylab
y-axis label.
xlab
x-axis label.
y.relation
This determines how the y-axis scale is plotted. "same" ensures all panels use the same scale and "free" will use panel-specfic scales. The latter is a useful setting when plotting data with very different values.
cols
Predefined colour scheme, currently only enabled for "greyscale".
main
Title of plot, if required.
auto.text
Either TRUE (default) or FALSE. If TRUE titles and axis labels will automatically try and format pollutant names and units properly e.g. by subscripting the 2 in NO2.
autocor
Should autocorrelation be considered in the trend uncertainty estimates? The default is FALSE. Generally, accounting for autocorrelation increases the uncertainty of the trend estimate - sometimes by a large amount.
slope.percent
Should the slope and the slope uncertainties be expressed as a percentage change per year? The default is FALSE and the slope is expressed as an average units/year change e.g. ppb. Percentage changes can often be confusing and should
date.breaks
Number of major x-axis intervals to use. The function will try and choose a sensible number of dates/times as well as formatting the date/time appropriately to the range being considered. This does not always work as desired automatically.
...
Other graphical parameters passed onto lattice:xyplot and cutData. For example, in the case of cutData the option hemisphere = "southern".

Value

  • As well as generating the plot itself, MannKendall also returns an object of class ``openair''. The object includes three main components: call, the command used to generate the plot; data, the data frame of summarised information used to make the plot; and plot, the plot itself. If retained, e.g. using output <- MannKendall(mydata, "nox"), this output can be used to recover the data, reproduce or rework the original plot or undertake further analysis. An openair output can be manipulated using a number of generic operations, including print, plot and summary. See openair.generics for further details. The data component of the MannKendall output includes two subsets: main.data, the monthly data res2 the trend statistics. For output <- MannKendall(mydata, "nox"), these can be extracted as object$data$main.data and object$data$res2, respectively. Note: In the case of the intercept, it is assumed the y-axis crosses the x-axis on 1/1/1970.

Warning

If deseason = TRUE, missing data will be linearly interpolated.

Details

The Mann-Kendall function provides a collection of functions to analyse trends in air pollution data. The Mann-Kendall test is a commonly used test in environmental sciences to detect the presence of a trend. It is often used with the Sen-Theil (or just Sen) estimate of slope. See references. The Mann-Kendall function is flexible in the sense that it can be applied to data in many ways e.g. by day of the week, hour of day and wind direction. This flexibility makes it much easier to draw inferences from data e.g. why is there a strong downward trend in concentration from one wind sector and not another, or why trends on one day of the week or a certain time of day are unexpected. The Mann-Kendall test from trend is for data that are monotonic - see http://en.wikipedia.org/wiki/Monotonic_function. The most appropriate use for this function is for data that are well-behaved i.e. tend to be steadily increasing or decreasing or steady. For data that are strongly seasonal, perhaps from a background site, or a pollutant such as ozone, it will be important to deseasonalise the data (using the option deseason = TRUE.Similarly, for data that increase, then decrease, or show sharp changes it may be better to use smoothTrend. Some of the code used in MannKendall is based on that from Rand Wilcox http://www-rcf.usc.edu/~rwilcox/. This mostly relates to the Sen-Theil slope estimates and uncertainties. Further modifications have been made to take account of correlated data based on Kunsch (1989). The slope estimate and confidence intervals in the slope are plotted and numerical information presented. The basic function have been adapted to take account of auto-correlated data using block bootstrap simulations (Kunsch, 1989). The principal reason for doing so is to gain a better estimate of trend uncertainty.

References

Helsel, D., Hirsch, R., 2002. Statistical methods in water resources. US Geological Survey. http://pubs.usgs.gov/twri/twri4a3/. Note that this is a very good resource for statistics as applied to environmental data. Hirsch, R. M., Slack, J. R., Smith, R. A., 1982. Techniques of trend analysis for monthly water-quality data. Water Resources Research 18 (1), 107-121. Kunsch, H. R., 1989. The jackknife and the bootstrap for general stationary observations. Annals of Statistics 17 (3), 1217-1241. ...see also several of the Air Quality Expert Group (AQEG) reports for the use of similar tests applied to UK/European air quality data, see http://www.defra.gov.uk/ENVIRONMENT/airquality/panels/aqeg/.

See Also

See smoothTrend for a flexible approach to estimating trends using nonparametric regression. The smoothTrend function is suitable for cases where trends are not monotonic and is probably better for exploring the shape of trends.

Examples

Run this code
# load example data from package
data(mydata)

# trend plot for nox
MannKendall(mydata, pollutant = "nox")

# trend plot for ozone with p=0.01 i.e. uncertainty in slope shown at
# 99 % confidence interval

MannKendall(mydata, pollutant = "o3", ylab = "o3 (ppb)", alpha = 0.01)

# trend plot by each of 8 wind sectors
MannKendall(mydata, pollutant = "o3", type = "wd", ylab = "o3 (ppb)")

# and for a subset of data (from year 2000 onwards)
MannKendall(select.by.date(mydata, year = 2000:2005), pollutant = "o3", ylab = "o3 (ppb)")

Run the code above in your browser using DataLab