| smoothTrend | R Documentation |
Use non-parametric methods to calculate time series trends
smoothTrend(
mydata,
pollutant = "nox",
avg.time = "month",
data.thresh = 0,
statistic = "mean",
percentile = NA,
k = NULL,
deseason = FALSE,
simulate = FALSE,
n = 200,
autocor = FALSE,
type = "default",
cols = "brewer1",
x.relation = "same",
y.relation = "same",
ref.x = NULL,
ref.y = NULL,
key.columns = 1,
key.position = "bottom",
strip.position = "top",
name.pol = NULL,
date.breaks = 7,
date.format = NULL,
auto.text = TRUE,
ci = TRUE,
alpha = 0.2,
progress = TRUE,
plot = TRUE,
key = NULL,
...
)
mydata |
A data frame of time series. Must include a |
pollutant |
Name of variable to plot. Two or more pollutants can be
plotted, in which case a form like |
avg.time |
This defines the time period to average to. Can be Note that |
data.thresh |
The data capture threshold to use (%). 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 100
will mean that all data will need to be present for the average to be
calculated, else it is recorded as |
statistic |
Statistic used for calculating monthly values. Default is
|
percentile |
Percentile value(s) to use if |
k |
This is the smoothing parameter used by the |
deseason |
Should the data be de-deasonalized first? If |
simulate |
Should simulations be carried out to determine the
Mann-Kendall tau and p-value. The default is |
n |
Number of bootstrap simulations if |
autocor |
Should autocorrelation be considered in the trend uncertainty
estimates? The default is |
type |
Character string(s) defining how data should be split/conditioned
before plotting.
Most |
cols |
Colours to use for plotting. Can be a pre-set palette (e.g.,
|
x.relation, y.relation |
This determines how the x- and y-axis scales are
plotted. |
ref.x |
See |
ref.y |
A list with details of the horizontal lines to be added
representing reference line(s). For example, |
key.columns |
Number of columns to be used in a categorical legend. With
many categories a single column can make to key too wide. The user can thus
choose to use several columns by setting |
key.position |
Location where the legend is to be placed. Allowed
arguments include |
strip.position |
Location where the facet 'strips' are located when
using |
name.pol |
This option can be used to give alternative names for the
variables plotted. Instead of taking the column headings as names, the user
can supply replacements. For example, if a column had the name "nox" and
the user wanted a different description, then setting |
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. The user can
override this behaviour by adjusting the value of |
date.format |
This option controls the date format on the x-axis. A
sensible format is chosen by default, but the user can set |
auto.text |
Either |
ci |
Should confidence intervals be plotted? The default is |
alpha |
The alpha transparency of shaded confidence intervals - if plotted. A value of 0 is fully transparent and 1 is fully opaque. |
progress |
Show a progress bar when many groups make up |
plot |
When |
key |
Deprecated; please use |
... |
Addition options are passed on to
|
The smoothTrend() function provides a flexible way of estimating the trend
in the concentration of a pollutant or other variable. Monthly mean values
are calculated from an hourly (or higher resolution) or daily time series.
There is the option to deseasonalise the data if there is evidence of a
seasonal cycle.
smoothTrend() uses a Generalized Additive Model (GAM) from the
mgcv::gam() package to find the most appropriate level of smoothing. The
function is particularly suited to situations where trends are not monotonic
(see discussion with TheilSen() for more details on this). The
smoothTrend() function is particularly useful as an exploratory technique
e.g. to check how linear or non-linear trends are.
95% confidence intervals are shown by shading. Bootstrap estimates of the
confidence intervals are also available through the simulate option.
Residual resampling is used.
Trends can be considered in a very wide range of ways, controlled by setting
type - see examples below.
an openair object
David Carslaw
Other time series and trend functions:
TheilSen(),
calendarPlot(),
timePlot(),
timeProp(),
timeVariation()
# trend plot for nox
smoothTrend(mydata, pollutant = "nox")
# trend plot by each of 8 wind sectors
## Not run:
smoothTrend(mydata, pollutant = "o3", type = "wd", ylab = "o3 (ppb)")
# several pollutants, no plotting symbol
smoothTrend(mydata, pollutant = c("no2", "o3", "pm10", "pm25"), pch = NA)
# percentiles
smoothTrend(mydata,
pollutant = "o3", statistic = "percentile",
percentile = 95
)
# several percentiles with control over lines used
smoothTrend(mydata,
pollutant = "o3", statistic = "percentile",
percentile = c(5, 50, 95), lwd = c(1, 2, 1), lty = c(5, 1, 5)
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.