aqtrends is an R package for conducting trend analysis of time series with different lengths.
It is a often useful, in air quality as well as in other fields, to aggregate multiple time series into a single representative trend. In air quality monitoring networks, simply averaging the individual time series often misrepresents the true trend due to biases in the monitoring network. Movement of roadside monitoring sites to more polluted locations is common, as a consequence of legislative requirements to monitor air quality at the most polluted locations. Consequently, opening sites (i.e. starting time series) in later years can leverage the average trend upwards, causing an increase in the average trend that is not necessarily a reflection of trends of individual time series.
The aqtrends
functions are designed to identify and mitigate the biasing effects of monitoring site flux on trends in air pollutant concentrations in air quality monitoring networks.
More details on the methods applied in this package, as well as a detailed case study using London air quality monitoring data, are given in a paper which is currently in preparation.
To install aqtrends from GitHub, the devtools package must first be installed. Then copy the following code into R:
# Load devtools package
library(devtools)
# Install aqtrends from GitHub
install_github("pollylang/aqtrends")
average_trends
to compare the average trends of all time series with the average trend for the long term time series only (i.e. time series with equal duration). Also returns average trends of individual sites which can be examined and compared to the average trend to identify biases.site_flux_bias
to visualise the bias due to differences in pollutant concentration between time series that are starting and time series that are ending as a function of time.rolling_trends
to compare rolling trends in pollutant concentration with the average trend.rolling_change_trend
to compute the rolling change trend, which represents the true trend in pollutant concentration.The aqtrends
functions are demonstrated below by a trend analysis of monthly NOx concentration data at 115 roadside monitoring sites in London between 2000-2017. During this period, 9 monitoring sites were constantly open over the duration (long term sites). The data were sourced from the Automatic Urban and Rural Network, the London Air Quality Network and Air Quality England.
The differences between the average trend (left) and the long term trend (right) in NOx, plotted using the average_trends
function, suggest a biasing effect may be influencing the average trend.
nox.av.trends <- average_trends(london_nox_data, pollutant = "nox", stat = "median",
start.date = "2000-01-01", end.date = "2017-12-31")
cowplot::plot_grid(nox.av.trends$average.trend, nox.av.trends$longterm.trend, ncol = 2)
The presence of a biasing effect can be confirmed by plotting the differences in concentration between opening sites and closing sites as a function of year using the site_flux_bias
function (see below). In this case, it is clear that opening sites have a consistently higher average NOx concentration than closing sites. Taking into account the relative frequency of opening and closing sites (as shown in the plot of the weighted cumulative sum of differences in concentration as a function of time on the far right), a bias towards more polluted locations is evident.
site_flux_bias(london_nox_data, pollutant = "nox", stat = "median")$all
Further evidence of the effect of the bias on the average trend can be visualised using the rolling_trends
function, as demonstrated below. The plots on the left shows rolling trends over a short moving window, each offset from its neighbours by a single year. The plot on the right shows the average trend over all data included in the rolling trend plots. The larger the width of the moving window, the more constraining the data capture filters on the data. Comparison of the rolling trends and average trends over different moving window widths (i.e. data capture filters - in this case moving window widths = 2, 5, 7, 10, 12, 15 years) demonstrates that some of the features of the average trend, most notably in this case the increase in concentration between 2008-2013, are artefacts of bias in the monitoring network rather than features of the true trend.
rolling_trends(london_nox_data, pollutant = "nox", window.width = c(2, 5, 7, 10, 12, 15))
## $`moving_window_width=2`
##
## $`moving_window_width=5`
##
## $`moving_window_width=7`
##
## $`moving_window_width=10`
##
## $`moving_window_width=12`
##
## $`moving_window_width=15`
Having identified the effect of bias on the average trend, the rolling_change_trend
function can be used to extract the true trend from the data, as shown below.
rolling_change_trend(london_nox_data, "nox", window.width = 3, avg.ts = "year")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.