View source: R/TaylorDiagram.R
| TaylorDiagram | R Documentation |
Function to draw Taylor Diagrams for model evaluation. The function allows conditioning by any categorical or numeric variables, which makes the function very flexible.
TaylorDiagram(
mydata,
obs = "obs",
mod = "mod",
group = NULL,
type = "default",
normalise = FALSE,
pos.cor = NULL,
cols = "brewer1",
rms.col = "darkgoldenrod",
cor.col = "black",
arrow.lwd = 3,
annotate = "centred\nRMS error",
text.obs = "observed",
key.title = group,
key.columns = 1,
key.position = "right",
strip.position = "top",
auto.text = TRUE,
plot = TRUE,
key = NULL,
...
)
mydata |
A data frame minimally containing a column of observations and a column of predictions. |
obs |
A column of observations with which the predictions ( |
mod |
A column of model predictions. Note, |
group |
The
|
type |
Character string(s) defining how data should be split/conditioned
before plotting.
Most |
normalise |
Should the data be normalised by dividing the standard
deviation of the observations? The statistics can be normalised (and
non-dimensionalised) by dividing both the RMS difference and the standard
deviation of the |
pos.cor |
Show only positive correlations ( |
cols |
Colours to use for plotting. Can be a pre-set palette (e.g.,
|
rms.col |
Colour for centred-RMS lines and text. |
cor.col |
Colour for correlation coefficient lines and text. |
arrow.lwd |
Width of arrow used when used for comparing two model outputs. |
annotate |
Annotation shown for RMS error. |
text.obs |
The plot annotation for observed values; default is "observed". |
key.title |
Used to set the title of the legend. The legend title is
passed to |
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 |
auto.text |
Either |
plot |
When |
key |
Deprecated; please use |
... |
Addition options are passed on to
|
The Taylor Diagram is a very useful model evaluation tool. The diagram provides a way of showing how three complementary model performance statistics vary simultaneously. These statistics are the correlation coefficient R, the standard deviation (sigma) and the (centred) root-mean-square error. These three statistics can be plotted on one (2D) graph because of the way they are related to one another which can be represented through the Law of Cosines.
The openair version of the Taylor Diagram has several enhancements that
increase its flexibility. In particular, the straightforward way of producing
conditioning plots should prove valuable under many circumstances (using the
type option). Many examples of Taylor Diagrams focus on model-observation
comparisons for several models using all the available data. However, more
insight can be gained into model performance by partitioning the data in
various ways e.g. by season, daylight/nighttime, day of the week, by levels
of a numeric variable e.g. wind speed or by land-use type etc.
To consider several pollutants on one plot, a column identifying the
pollutant name can be used e.g. pollutant. Then the Taylor Diagram can be
plotted as (assuming a data frame thedata):
TaylorDiagram(thedata, obs = "obs", mod = "mod", group = "model", type = "pollutant")
which will give the model performance by pollutant in each panel.
Note that it is important that each panel represents data with the same mean
observed data across different groups. Therefore TaylorDiagram(mydata, group = "model", type = "season") is OK, whereas TaylorDiagram(mydata, group = "season", type = "model") is not because each panel (representing a model)
will have four different mean values — one for each season. Generally, the
option group is either missing (one model being evaluated) or represents a
column giving the model name. However, the data can be normalised using the
normalise option. Normalisation is carried out on a per group/type
basis making it possible to compare data on different scales e.g.
TaylorDiagram(mydata, group = "season", type = "model", normalise = TRUE).
In this way it is possible to compare different pollutants, sites etc. in the
same panel.
Also note that if multiple sites are present it makes sense to use type = "site" to ensure that each panel represents an individual site with its own
specific standard deviation etc. If this is not the case then select a single
site from the data first e.g. subset(mydata, site == "Harwell").
an openair object. If retained, e.g., using
output <- TaylorDiagram(thedata, obs = "nox", mod = "mod"), this output
can be used to recover the data, reproduce or rework the original plot or
undertake further analysis. For example, output$data will be a data frame
consisting of the group, type, correlation coefficient (R), the standard
deviation of the observations and measurements.
David Carslaw
Jack Davison
Taylor, K.E.: Summarizing multiple aspects of model performance in a single diagram. J. Geophys. Res., 106, 7183-7192, 2001 (also see PCMDI Report 55).
Other model evaluation functions:
conditionalEval(),
conditionalQuantile(),
modStats()
# in the examples below, most effort goes into making some artificial data
# the function itself can be run very simply
## Not run:
library(dplyr)
dummy model data for 2003
dat <- selectByDate(mydata, year = 2003) |>
transmute(date, obs = nox, mod = nox, month = as.integer(format(date, "%m")))
# now make mod worse by adding bias and noise according to the month
# do this for 3 different models
mod1 <- dat |>
mutate(
mod = mod + 10 * month + 10 * month * rnorm(n()),
model = "model 1"
) |>
# lag the results to make the correlation coefficient worse without affecting the sd
mutate(mod = c(mod[5:n()], mod[(n() - 3):n()]))
mod2 <- dat |>
mutate(
mod = mod + 7 * month + 7 * month * rnorm(n()),
model = "model 2"
)
mod3 <- dat |>
mutate(
mod = mod + 3 * month + 3 * month * rnorm(n()),
model = "model 3"
)
mod.dat <- bind_rows(mod1, mod2, mod3)
# basic Taylor plot
TaylorDiagram(mod.dat, obs = "obs", mod = "mod", group = "model")
# Taylor plot by season
TaylorDiagram(
mod.dat,
obs = "obs",
mod = "mod",
group = "model",
type = "season"
)
# now show how to evaluate model improvement (or otherwise)
mod1a <- dat |>
mutate(
mod = mod + 2 * month + 2 * month * rnorm(n()),
model = "model 1"
)
mod2a <- mod2 |> mutate(mod = mod * 1.3)
mod3a <- dat |>
mutate(
mod = mod + 10 * month + 10 * month * rnorm(n()),
model = "model 3"
)
# now we have a data frame with 3 models, 1 set of observations
# and two sets of model predictions (mod and mod2)
mod.dat <- mod.dat |>
mutate(mod2 = bind_rows(mod1a, mod2a, mod3a) |> pull(mod))
# do for all models
TaylorDiagram(mod.dat, obs = "obs", mod = c("mod", "mod2"), group = "model")
# all models, by season
TaylorDiagram(
mod.dat,
obs = "obs",
mod = c("mod", "mod2"),
group = "model",
type = "season"
)
# consider two groups (model/month). In this case all months are shown by
# model but are only differentiated by model.
TaylorDiagram(mod.dat, obs = "obs", mod = "mod", group = c("model", "month"))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.