Title: | Forecast Verification Routines for Ensemble Forecasts of Weather and Climate |
---|---|
Description: | A collection of forecast verification routines developed for the SPECS FP7 project. The emphasis is on comparative verification of ensemble forecasts of weather and climate. |
Authors: | Stefan Siegert [aut, cre], Jonas Bhend [ctb], Igor Kroener [ctb], Matteo De Felice [ctb] |
Maintainer: | Stefan Siegert <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.5-3 |
Built: | 2024-11-20 04:04:42 UTC |
Source: | https://github.com/cran/SpecsVerification |
Calculate the absolute error between forecast and observation
AbsErr(fcst, obs)
AbsErr(fcst, obs)
fcst |
a N-vector representing N time instances of real-valued forecasts |
obs |
a N-vector representing N time instances of real-valued observations |
numeric N-vector of absolute errors |fcst - obs|
SqErr, ScoreDiff, SkillScore
data(eurotempforecast) mean(AbsErr(rowMeans(ens), obs))
data(eurotempforecast) mean(AbsErr(rowMeans(ens), obs))
Calculate area under the ROC curve (AUC) for a forecast and its verifying binary observation, and estimate the variance of the AUC
Auc( fcst, obs, handle.na = c("na.fail", "only.complete.pairs"), use_fn = c("C++", "R") )
Auc( fcst, obs, handle.na = c("na.fail", "only.complete.pairs"), use_fn = c("C++", "R") )
fcst |
vector of forecasts |
obs |
vector of binary observations (0 for non-occurrence, 1 for occurrence of the event) |
handle.na |
how should missing values in forecasts and observations be handled; possible values are 'na.fail' and 'only.complete.pairs'; default: 'na.fail' |
use_fn |
the function used for the calculation: 'C++' (default) for the fast C++ implementation, or 'R' for the slow (but more readable) R implementation |
vector containing AUC and its estimated sampling standard deviation
DeLong et al (1988): Comparing the Areas under Two or More Correlated Receiver Operating Characteristic Curves: A Nonparametric Approach. Biometrics. https://www.jstor.org/stable/2531595 Sun and Xu (2014): Fast Implementation of DeLong's Algorithm for Comparing the Areas Under Correlated Receiver Operating Characteristic Curves. IEEE Sign Proc Let 21(11). doi:10.1109/LSP.2014.2337313
AucDiff
data(eurotempforecast) Auc(rowMeans(ens.bin), obs.bin)
data(eurotempforecast) Auc(rowMeans(ens.bin), obs.bin)
Calculate AUC and its sampling standard deviation (Internal C++ implementation)
auc_cpp(fcst, obs)
auc_cpp(fcst, obs)
fcst |
numeric vector of forecasts (NAs are not allowed) |
obs |
vector of binary observations (obs[t] evaluates to TRUE if event happens at instance t, to FALSE otherwise) |
AUC and its sampling standard deviation
Auc AucDiff
Calculate difference between areas under the ROC curve (AUC) between a forecast and a reference forecast for the same observation, and estimate the variance of the AUC difference
AucDiff( fcst, fcst.ref, obs, handle.na = c("na.fail", "only.complete.triplets"), use_fn = c("C++", "R") )
AucDiff( fcst, fcst.ref, obs, handle.na = c("na.fail", "only.complete.triplets"), use_fn = c("C++", "R") )
fcst |
vector of forecasts |
fcst.ref |
vector of reference forecasts |
obs |
vector of binary observations (0 for non-occurrence, 1 for occurrence of the event) |
handle.na |
how should missing values in forecasts and observations be handled; possible values are 'na.fail' and 'only.complete.triplets'; default: 'na.fail' |
use_fn |
the function used for the calculation: 'C++' (default) for the fast C++ implementation, or 'R' for the slow (but more readable) R implementation |
vector with AUC difference, and estimated standard deviation
DeLong et al (1988): Comparing the Areas under Two or More Correlated Receiver Operating Characteristic Curves: A Nonparametric Approach. Biometrics. https://www.jstor.org/stable/2531595 Sun and Xu (2014): Fast Implementation of DeLong's Algorithm for Comparing the Areas Under Correlated Receiver Operating Characteristic Curves. IEEE Sign Proc Let 21(11). doi:10.1109/LSP.2014.2337313
Auc
data(eurotempforecast) AucDiff(rowMeans(ens.bin), ens.bin[, 1], obs.bin)
data(eurotempforecast) AucDiff(rowMeans(ens.bin), ens.bin[, 1], obs.bin)
Calculate AUC difference 'AUC(fcst,obs) - AUC(fcst_ref, obs)' of two forecasts for the same observations, and the sampling standard deviation of the AUC difference (Internal C++ implementation)
aucdiff_cpp(fcst, fcst_ref, obs)
aucdiff_cpp(fcst, fcst_ref, obs)
fcst |
numeric vector of forecasts (NAs are not allowed) |
fcst_ref |
numeric vector of reference forecasts (NAs are not allowed) |
obs |
vector of binary observations (obs[t] evaluates to TRUE if event happens at instance t, to FALSE otherwise) |
AUC values, their sampling standard deviations, the AUC difference, and their sampling standard deviations
Auc AucDiff
Return decomposition of the Brier Score into Reliability, Resolution and Uncertainty, and estimated standard deviations
BrierDecomp(p, y, bins = 10, bias.corrected = FALSE)
BrierDecomp(p, y, bins = 10, bias.corrected = FALSE)
p |
vector of forecast probabilities |
y |
binary observations, y[t]=1 if an event happens at time t, and y[t]=0 otherwise |
bins |
binning to estimate the calibration function (see Details), default: 10 |
bias.corrected |
logical, default=FALSE, whether the standard (biased) decomposition of Murphy (1973) should be used, or the bias-corrected decomposition of Ferro (2012) |
To estimate the calibration curve, the unit line is categorised into discrete bins, provided by the 'bins' argument. If 'bins' is a single number, it specifies the number of equidistant bins. If 'bins' is a vector of values between zero and one, these values are used as the bin-breaks.
Estimators of the three components and their estimated standard deviations are returned as a 2*3 matrix.
Murphy (1973): A New Vector Partition of the Probability Score. J. Appl. Met. doi:10.1175/1520-0450(1973)012<0595:ANVPOT>2.0.CO;2
Ferro and Fricker (2012): A bias-corrected decomposition of the Brier score. QJRMS. doi:10.1002/qj.1924
Siegert (2013): Variance estimation for Brier Score decomposition. QJRMS. doi:10.1002/qj.2228
ReliabilityDiagram
data(eurotempforecast) BrierDecomp(rowMeans(ens.bin), obs.bin, bins=3, bias.corrected=TRUE)
data(eurotempforecast) BrierDecomp(rowMeans(ens.bin), obs.bin, bins=3, bias.corrected=TRUE)
Construct a climatological ensemble from a vector of observations. Optionally, the climatological ensemble observation at time t can be constructed without the observation at time t (leave-one-out).
ClimEns(obs, leave.one.out=FALSE)
ClimEns(obs, leave.one.out=FALSE)
obs |
vector of length N. The observations. |
leave.one.out |
logical, default=FALSE. If TRUE, the n-th observation is removed from the n-th row of the ensemble matrix. |
matrix with N rows and N-1 columns (if leave.one.out==TRUE) or N columns otherwise.
data(eurotempforecast) ClimEns(obs)
data(eurotempforecast) ClimEns(obs)
Calculate correlation between forecasts and observations, and assess uncertainty
Corr(fcst, obs, N.eff = NA, conf.level = 0.95, handle.na = "na.fail")
Corr(fcst, obs, N.eff = NA, conf.level = 0.95, handle.na = "na.fail")
fcst |
vector of forecasts |
obs |
vector of observations |
N.eff |
user-defined effective sample size to be used in hypothesis test and for confidence bounds; if NA, the length of 'obs' is used after removing missing values; default: NA |
conf.level |
confidence level used the confidence interval; default = 0.95 |
handle.na |
how should missing values in forecasts and observations be handled; possible values are 'na.fail' and 'use.pairwise.complete'; default: 'na.fail' |
vector with correlation, one-sided p-value, and central confidence interval at the user-defined confidence level
Von Storch, Zwiers (2001): Statistical analysis in climate research. Cambridge University Press.
CorrDiff
data(eurotempforecast) Corr(rowMeans(ens), obs)
data(eurotempforecast) Corr(rowMeans(ens), obs)
Calculate correlation difference between a forecast and a reference forecast, and assess uncertainty
CorrDiff( fcst, fcst.ref, obs, N.eff = NA, conf.level = 0.95, handle.na = "na.fail" )
CorrDiff( fcst, fcst.ref, obs, N.eff = NA, conf.level = 0.95, handle.na = "na.fail" )
fcst |
vector of forecasts |
fcst.ref |
vector of reference forecasts |
obs |
vector of observations |
N.eff |
user-defined effective sample size to be used in hypothesis test and for confidence bounds; if NA, the length of 'obs' is used after removing missing values; default: NA |
conf.level |
confidence level for the confidence interval; default = 0.95 |
handle.na |
how should missing values in forecasts and observations be handled; possible values are 'na.fail' and 'only.complete.triplets'; default: 'na.fail' |
vector with correlation difference, one-sided p-value, and central confidence interval at the user-defined confidence level
Steiger (1980): Tests for comparing elements of a correlation matrix. Psychological Bulletin. doi:10.1037/0033-2909.87.2.245 Zou (2007): Toward using confidence intervals to compare correlations. Psychological Methods. doi:10.1037/1082-989X.12.4.399
Corr
data(eurotempforecast) CorrDiff(rowMeans(ens), ens[, 1], obs)
data(eurotempforecast) CorrDiff(rowMeans(ens), ens[, 1], obs)
Detrend fits a linear function to a time-series of observations or to the time-series of ensemble means of an ensemble matrix. The linear trend is removed, and if option demean is true, the total mean is removed as well.
Detrend(x, demean = TRUE)
Detrend(x, demean = TRUE)
x |
A vector, matrix, or data.frame. |
demean |
logical; if true, the total mean is removed from x |
The function returns an object of the same dimensions as the argument 'x', but with its linear trend and (possibly) its mean removed.
data(eurotempforecast) Detrend(ens) Detrend(obs, demean=FALSE)
data(eurotempforecast) Detrend(ens) Detrend(obs, demean=FALSE)
Calculate the Continuous Ranked Probability Score (CRPS) for a mixture of Normal distributions, for example generated by ensemble dressing
DressCrps(dressed.ens, obs)
DressCrps(dressed.ens, obs)
dressed.ens |
a list with elements 'ens', a N*R matrix representing N time instances of kernel centers, and 'ker.wd', a N*R matrix with corresponding kernel standard deviations. See function 'DressEnsemble' |
obs |
a numeric vector of length N with real-valued observations |
numeric vector of length N with the CRPS values
Grimit et al (2006): The continuous ranked probability score for circular variables and its application to mesoscale forecast ensemble verification. Q.J.R. Meteorol. Soc. doi:10.1256/qj.05.235
EnsCrps, ScoreDiff, SkillScore
data(eurotempforecast) dressed.ens <- DressEnsemble(ens) mean(DressCrps(dressed.ens, obs))
data(eurotempforecast) dressed.ens <- DressEnsemble(ens) mean(DressCrps(dressed.ens, obs))
Dress CRPS
dresscrps_cpp(m, s, y)
dresscrps_cpp(m, s, y)
m |
vector of kernel means |
s |
vector of kernel standard deviations |
y |
observation |
crps
Calculate DressCrps Difference (deprecated, use function ScoreDiff instead)
DressCrpsDiff(dressed.ens, dressed.ens.ref, obs, probs = NA)
DressCrpsDiff(dressed.ens, dressed.ens.ref, obs, probs = NA)
dressed.ens |
the ensemble |
dressed.ens.ref |
the reference ensemble |
obs |
the observation |
probs |
not used |
mean DressCrps difference
ScoreDiff DressCrps DressEnsemble
Calculate DressCrps Skill Score (deprecated, use function SkillScore instead)
DressCrpss(dressed.ens, dressed.ens.ref, obs)
DressCrpss(dressed.ens, dressed.ens.ref, obs)
dressed.ens |
the ensemble |
dressed.ens.ref |
the reference ensemble |
obs |
the observation |
DressCrps Skill Score
SkillScore DressCrps DressEnsemble
Transform an ensemble forecast to a continuous forecast distribution by kernel dressing.
DressEnsemble(ens, dressing.method = "silverman", parameters = NA)
DressEnsemble(ens, dressing.method = "silverman", parameters = NA)
ens |
a N*R matrix representing N time instances of real-valued R-member ensemble forecasts |
dressing.method |
One of "silverman" (default), "akd", "akd.fit". See Details. |
parameters |
A list, containing the parameters for the dressing method. See Details. |
The dressing methods currently implemented and their required parameters are:
No parameters are given. At time instance ‘n' each ensemble member is replaced by a Gaussian kernel with mean ens[n, k] and variance (4 / 3 / K)^0.4 * var(ens[n, ]). This method is called "Silverman’s rule of thumb" and provides a simple non-parametric method for smoothing a discrete ensemble.
Affine Kernel Dressing. The required parameters are list(r1, r2, a, s1, s2). The 'k'-th ensemble member at time instance 'n' is dressed with a Gaussian kernel with mean r1 + r2 * mean(ens[n,]) + a * ens[n, k] and variance (4 / 3 / K)^0.4 * (s1 + s2 * a^2 * var(ens[n,])). Negative variances are set to zero. Note that parameters = list(r1=0, r2=0, a=1, s1=0, s2=1) yields the same dressed ensemble as dressing.method="silverman".
Affine Kernel Dressing with fitted parameters. The required parameters is list(obs), where 'obs' is a vector of observations which are used to optimize the parameters r1, r2, a, s1, s2 by CRPS minimization. See ?FitAkdParameters for more information.
The function returns a list with elements 'ens' (a N*R matrix, where ens[t,r] is the mean of the r-th kernel at time instance t) and 'ker.wd' (a N*R matrix, where ker.wd[t,r] is the standard deviation of the r-th kernel at time t)
Silverman, B.W. (1998). Density Estimation for Statistics and Data Analysis. London: Chapman & Hall/CRC. ISBN 0-412-24620-1. Broecker J. and Smith L. (2008). From ensemble forecasts to predictive distribution functions. Tellus (2008), 60A, 663–678. doi:10.1111/j.1600-0870.2008.00333.x.
DressCrps, DressIgn, GetDensity, FitAkdParameters
data(eurotempforecast) d.silverman <- DressEnsemble(ens) d.akd <- DressEnsemble(ens, dressing.method="akd", parameters=list(r1=0, r2=0, a=1, s1=0, s2=0)) d.akd.fit <- DressEnsemble(ens, dressing.method="akd.fit", parameters=list(obs=obs))
data(eurotempforecast) d.silverman <- DressEnsemble(ens) d.akd <- DressEnsemble(ens, dressing.method="akd", parameters=list(r1=0, r2=0, a=1, s1=0, s2=0)) d.akd.fit <- DressEnsemble(ens, dressing.method="akd.fit", parameters=list(obs=obs))
Calculate the Logarithmic (Ignorance) Score for a mixture of Normal distributions, for example generated by ensemble dressing
DressIgn(dressed.ens, obs)
DressIgn(dressed.ens, obs)
dressed.ens |
a list with elements 'ens', a N*R matrix representing N time instances of kernel centers, and 'ker.wd', a N*R matrix with corresponding kernel standard deviations. See function 'DressEnsemble' |
obs |
a numeric vector of length N with real-valued observations |
numeric vector of length N with the Ignorance score values
Roulston and Smith (2002) Evaluating Probabilistic Forecasts Using Information Theory, doi:10.1175/1520-0493(2002)130<1653:EPFUIT>2.0.CO;2
DressEnsemble, DressCrps
data(eurotempforecast) d.ens <- DressEnsemble(ens) DressIgn(d.ens, obs)
data(eurotempforecast) d.ens <- DressEnsemble(ens) DressIgn(d.ens, obs)
Calculate DressIgn Difference (deprecated, use function ScoreDiff instead)
DressIgnDiff(dressed.ens, dressed.ens.ref, obs, probs = NA)
DressIgnDiff(dressed.ens, dressed.ens.ref, obs, probs = NA)
dressed.ens |
the ensemble |
dressed.ens.ref |
the reference ensemble |
obs |
the observation |
probs |
not used |
mean DressIgn difference
ScoreDiff DressIgn
Calculate the ensemble-adjusted Brier Score
EnsBrier(ens, obs, R.new = NA) FairBrier(ens, obs)
EnsBrier(ens, obs, R.new = NA) FairBrier(ens, obs)
ens |
a N*R matrix representing N time instances of R-member ensemble forecasts of binary events; ens[t,r]=1 if the r-th ensemble member at time t predicted the event, otherwise ens[t,r]=0 |
obs |
a numeric vector of length N with binary observations; obs[t]=1 if the event happens at time t, otherwise obs[t]=0 |
R.new |
ensemble size for which the scores should be adjusted |
'FairBrier(ens, obs)' returns 'EnsBrier(ens, obs, R.new=Inf)'
numeric vector of length N with the ensemble-adjusted Brier scores
Ferro CAT, Richardson SR, Weigel AP (2008) On the effect of ensemble size on the discrete and continuous ranked probability scores. Meteorological Applications. doi:10.1002/met.45
EnsRps, EnsCrps, ScoreDiff, SkillScore
data(eurotempforecast) mean(EnsBrier(ens.bin, obs.bin, R.new=Inf))
data(eurotempforecast) mean(EnsBrier(ens.bin, obs.bin, R.new=Inf))
Calculate EnsBrier Difference (deprecated, use function ScoreDiff instead)
EnsBrierDiff(ens, ens.ref, obs, tau = NA, probs = NA)
EnsBrierDiff(ens, ens.ref, obs, tau = NA, probs = NA)
ens |
the ensemble |
ens.ref |
the reference ensemble |
obs |
the observation |
tau |
not used |
probs |
not used |
mean EnsBrier difference
ScoreDiff EnsBrier
Calculate EnsBrier Skill Score (deprecated, use function SkillScore instead)
EnsBrierSs(ens, ens.ref, obs, tau = NA)
EnsBrierSs(ens, ens.ref, obs, tau = NA)
ens |
the ensemble |
ens.ref |
the reference ensemble |
obs |
the observation |
tau |
not used |
EnsBrier skill score
SkillScore EnsBrier
Calculate correlation between forecasts and observations for an ensemble forecast, including an adjustment for finite ensemble sizes
EnsCorr(ens, obs, R.new = NA)
EnsCorr(ens, obs, R.new = NA)
ens |
a N*R matrix representing N time instances of real-valued R-member ensemble forecasts |
obs |
a numeric vector of length N with real-valued observations |
R.new |
positive number, can be |
A vector with 4 entries:
cmy
: Correlation skill of the ensemble mean forecast
cmy_adj
: Correlation skill of the ensemble mean forecast adjusted to ensemble size R.new
cxx
: Average correlation between ensemble members
cxy
: Average correlation between individual ensemble members and observation
Von Storch, Zwiers (2001): Statistical analysis in climate research. Cambridge University Press.
Murphy (1990), Assessment of the practical utility of extended range ensemble forecasts, Q. J. R. Meteorol. Soc., 116, 89-125.
Corr, CorrDiff
data(eurotempforecast) EnsCorr(ens, obs, R.new=Inf)
data(eurotempforecast) EnsCorr(ens, obs, R.new=Inf)
Calculate the ensemble-adjusted Continuous Ranked Probability Score (CRPS)
EnsCrps(ens, obs, R.new = NA) FairCrps(ens, obs)
EnsCrps(ens, obs, R.new = NA) FairCrps(ens, obs)
ens |
a N*R matrix representing N time instances of real-valued R-member ensemble forecasts |
obs |
a numeric vector of length N with real-valued observations |
R.new |
positive number, can be 'Inf', ensemble size for which the scores should be adjusted, default is NA for no adjustment |
'FairCrps(ens, obs)' returns 'EnsCrps(ens, obs, R.new=Inf)'
numeric vector of length N with the ensemble-adjusted CRPS values
Ferro CAT, Richardson SR, Weigel AP (2008) On the effect of ensemble size on the discrete and continuous ranked probability scores. Meteorological Applications. doi:10.1002/met.45
EnsBrier, EnsRps, DressCrps, GaussCrps, ScoreDiff, SkillScore
data(eurotempforecast) mean(EnsCrps(ens, obs, R.new=Inf))
data(eurotempforecast) mean(EnsCrps(ens, obs, R.new=Inf))
CRPS for ensemble forecasts (C++ implementation)
enscrps_cpp(ens, obs, R_new)
enscrps_cpp(ens, obs, R_new)
ens |
Ensemble members as columns of a matrix |
obs |
The verifying observations |
R_new |
Size for ensemble adjustment |
vector of crps values
Calculate EnsCrps Difference (deprecated, use function ScoreDiff instead)
EnsCrpsDiff(ens, ens.ref, obs, probs = NA)
EnsCrpsDiff(ens, ens.ref, obs, probs = NA)
ens |
the ensemble |
ens.ref |
the reference ensemble |
obs |
the observation |
probs |
not used |
mean EnsCrps difference
ScoreDiff EnsCrps
Calculate EnsCrps Skill Score (deprecated, use function SkillScore instead)
EnsCrpss(ens, ens.ref, obs)
EnsCrpss(ens, ens.ref, obs)
ens |
the ensemble |
ens.ref |
the reference ensemble |
obs |
the observation |
EnsCrps skill score
SkillScore EnsCrps
Calculate the ensemble-adjusted Quadratic Score (QS) for categorical forecasts
EnsQs(ens, obs, R.new = NA) FairQs(ens, obs)
EnsQs(ens, obs, R.new = NA) FairQs(ens, obs)
ens |
a N*R matrix of integers, representing N time instances of categorical ensemble forecasts; ens[t,r] indicates the category index that the r-th ensemble member forecasts at time t |
obs |
a vector of length N, obs[t] is the category that occurred at time t |
R.new |
ensemble size for which the scores should be adjusted |
'FairQs(ens, obs)' returns 'EnsQs(ens, obs, R.new=Inf)'
It is assumed that the smallest class index is 1, and the largest class index is calculated by max(c(ens,obs))
numeric vector of length N with the ensemble-adjusted quadratic score values
EnsBrier, EnsRps, EnsCrps, ScoreDiff, SkillScore
data(eurotempforecast) EnsQs(ens.cat, obs.cat, R.new=Inf)
data(eurotempforecast) EnsQs(ens.cat, obs.cat, R.new=Inf)
Calculate the ensemble-adjusted Ranked Probability Score (RPS) for categorical forecasts
EnsRps(ens, obs, R.new = NA, format = c("category", "members")) FairRps(ens, obs, format = c("category", "members"))
EnsRps(ens, obs, R.new = NA, format = c("category", "members")) FairRps(ens, obs, format = c("category", "members"))
ens |
matrix with N rows representing N time instances of categorical ensemble forecasts as follows: If 'format = category' (the default), then ens[t,r] indicates the category that the r-th ensemble member predicts for time t. Note that categories must be positive integers. If 'format = members', then ens[t,k] is the number of ensemble members that predict category k at time t. |
obs |
vector of length N, or matrix with N rows, representing the N observed category as follows: If ‘format = category’, obs is a vector and obs[t] is the category observed at time t. If 'format = members', obs is a matrix where obs[t,k] = 1 (and zero otherwise) if category k was observed at time t |
R.new |
ensemble size for which the scores should be adjusted, defaults to NA (no adjustment) |
format |
string, 'category' (default) or 'members' (can be abbreviated). See descriptions of arguments 'ens' and 'obs' for details. |
'FairRps(ens, obs)' returns 'EnsRps(ens, obs, R.new=Inf)'
numeric vector of length N with the ensemble-adjusted RPS values
EnsBrier, EnsQs, EnsCrps
data(eurotempforecast) EnsRps(ens.cat, obs.cat, R.new=Inf)
data(eurotempforecast) EnsRps(ens.cat, obs.cat, R.new=Inf)
Calculate EnsRps Difference (deprecated, use function ScoreDiff instead)
EnsRpsDiff(ens, ens.ref, obs, probs = NA, format = c("category", "members"))
EnsRpsDiff(ens, ens.ref, obs, probs = NA, format = c("category", "members"))
ens |
the ensemble |
ens.ref |
the reference ensemble |
obs |
the observation |
probs |
not used |
format |
see 'EnsRps' |
mean EnsRps difference
ScoreDiff EnsRps
Calculate EnsRps Skill Score (deprecated, use function SkillScore instead)
EnsRpss(ens, ens.ref, obs, format = c("category", "members"))
EnsRpss(ens, ens.ref, obs, format = c("category", "members"))
ens |
the ensemble |
ens.ref |
the reference ensemble |
obs |
the observation |
format |
see 'EnsRps' |
EnsRps skill score
SkillScore EnsRps
A hindcast dataset of average European (30N,75N,12.5W,42.5E) summer (June/July/August) surface temperatures. Forecasts were initialised in May the same year. Observations and 15-member ensemble forecasts were derived from the publicly available NCEP Reanalysis (Suranjana, 2010) and the NCEP Climate Forecast System Version 2 (Suranjana, 2014), respectively. The data was downloaded through the ECOMS User Data Gateway (Santander Meteorology Group, 2015).
data(eurotempforecast)
data(eurotempforecast)
Variables contained in the data set:
'obs' average European summer temperature observations
'ens' mean-debiased ensemble forecast data, i.e. mean(ens) == mean(obs)
'obs.lag' the observations lagged by one year, same length as 'obs'
'obs.bin' binary observations (0 or 1), obs[i] = 1 indicates that the temperature of year i exceeded the temperature of year i-1
'ens.bin' binary ensemble forecast (each member is either 0 or 1), ens[i, j] = 1 if the j-th ensemble member in year i exceeded the observed temperature of year i-1
'obs.cat' categorical observations. obs.cat[i] is either 1, 2, and 3, indicating that the temperature in year i was lower, similar, higher than temperature in year i-1. Similar is defined as within a half degree interval centered around last years temperature.
'ens.cat' categorical ensemble forecast. ens.cat[i, j] is either 1, 2, or 3. The categories are defined as for 'obs.cat'.
Saha, Suranjana, and Coauthors, 2010: The NCEP Climate Forecast System Reanalysis. Bull. Amer. Meteor. Soc., 91, 1015.1057. doi:10.1175/2010BAMS3001.1 Saha, Suranjana and Coauthors, 2014: The NCEP Climate Forecast System Version 2. J. Clim., 27, 2185–2208, doi:10.1175/JCLI-D-12-00823.1 Santander Meteorology Group (2015). ecomsUDG.Raccess: R interface to the ECOMS User Data Gateway. R package version 4.2-0. http://meteo.unican.es/trac/wiki/udg/ecoms
Calculate FairBrier Difference (deprecated, use function ScoreDiff instead)
FairBrierDiff(ens, ens.ref, obs, tau = NA, probs = NA)
FairBrierDiff(ens, ens.ref, obs, tau = NA, probs = NA)
ens |
the ensemble |
ens.ref |
the reference ensemble |
obs |
the observation |
tau |
not used |
probs |
not used |
mean FairBrier difference
ScoreDiff EnsBrier
Calculate FairBrier Skill Score (deprecated, use function SkillScore instead)
FairBrierSs(ens, ens.ref, obs, tau = NA)
FairBrierSs(ens, ens.ref, obs, tau = NA)
ens |
the ensemble |
ens.ref |
the reference ensemble |
obs |
the observation |
tau |
not used |
FairBrier skill score
SkillScore EnsBrier
Calculate FairCrps Difference (deprecated, use function ScoreDiff instead)
FairCrpsDiff(ens, ens.ref, obs, probs = NA)
FairCrpsDiff(ens, ens.ref, obs, probs = NA)
ens |
the ensemble |
ens.ref |
the reference ensemble |
obs |
the observation |
probs |
not used |
mean FairCrps difference
ScoreDiff EnsCrps
Calculate FairCrps Skill Score (deprecated, use function SkillScore instead)
FairCrpss(ens, ens.ref, obs)
FairCrpss(ens, ens.ref, obs)
ens |
the ensemble |
ens.ref |
the reference ensemble |
obs |
the observation |
FairCrps skill score
SkillScore EnsCrps
Calculate FairRps Difference (deprecated, use function ScoreDiff instead)
FairRpsDiff(ens, ens.ref, obs, probs = NA, format = c("category", "members"))
FairRpsDiff(ens, ens.ref, obs, probs = NA, format = c("category", "members"))
ens |
the ensemble |
ens.ref |
the reference ensemble |
obs |
the observation |
probs |
not used |
format |
see 'EnsRps' |
mean FairRps difference
ScoreDiff EnsRps
Calculate FairRps Skill Score (deprecated, use function SkillScore instead)
FairRpss(ens, ens.ref, obs, format = c("category", "members"))
FairRpss(ens, ens.ref, obs, format = c("category", "members"))
ens |
the ensemble |
ens.ref |
the reference ensemble |
obs |
the observation |
format |
see 'EnsRps' |
FairRps skill score
SkillScore EnsRps
Fit the 5 parameters used for affine kernel dressing by minimum CRPS estimation.
FitAkdParameters(ens, obs)
FitAkdParameters(ens, obs)
ens |
a N*R matrix. An archive of R-member ensemble forecasts for N time instances. |
obs |
a vector of length N. The verifying observations corresponding to the N ensemble forecasts. |
Affine Kernel Dressing transforms the discrete K-member forecast ensemble at time instance n, 'ens[n, ]', to a continuous distribution function for the target 'y' by the equation:
p(y|ens) = 1 / K * sum dnorm(y, z.i, s)
where s = (4/3/K)^0.4 * (s1 + s2 * a^2 * var(ens))
and z.i = r1 + r2 * mean(ens) + a * ens
The parameters r1, r2, a, s1, s2 are fitted by minimizing the continuously ranked probability score (CRPS). The optimization is carried out using the R function 'optim(...)'.
Since the evaluation of the CRPS is numerically expensive, the optimization can take a long time. Speed can be increased by optimizing the parameters only for a part of the forecast instances.
The function returns a list of 5 parameters for affine kernel dressing.
Broecker J. and Smith L. (2008). From ensemble forecasts to predictive distribution functions. Tellus (2008), 60A, 663–678. doi:10.1111/j.1600-0870.2008.00333.x.
DressEnsemble, DressCrps, DressIgn, PlotDressedEns, GetDensity
data(eurotempforecast) FitAkdParameters(ens, obs)
data(eurotempforecast) FitAkdParameters(ens, obs)
Calculate the Continuous Ranked Probability Score (CRPS) for forecasts issued as Normal distributions
GaussCrps(mean, sd, obs)
GaussCrps(mean, sd, obs)
mean |
A vector of length N. The forecast means. |
sd |
A vector of length N. The forecast standard deviations. |
obs |
A numeric vector of length N of real-valued verifying observations |
numeric vector of length N with the CRPS values
Gneiting et al (2005). Calibrated Probabilistic Forecasting Using Ensemble Model Output Statistics and Minimum CRPS Estimation. Mon. Wea. Rev. doi:10.1175/MWR2904.1
EnsCrps, DressCrps, ScoreDiff, SkillScore
data(eurotempforecast) mean <- rowMeans(ens) sd <- apply(ens, 1, sd) mean(GaussCrps(mean, sd, obs))
data(eurotempforecast) mean <- rowMeans(ens) sd <- apply(ens, 1, sd) mean(GaussCrps(mean, sd, obs))
Calculate GaussCrps Difference (deprecated, use function ScoreDiff instead)
GaussCrpsDiff(mean, sd, mean.ref, sd.ref, obs, probs = NA)
GaussCrpsDiff(mean, sd, mean.ref, sd.ref, obs, probs = NA)
mean |
forecast means |
sd |
forecast standard deviations |
mean.ref |
reference forecast means |
sd.ref |
reference forecast standard deviations |
obs |
the observation |
probs |
not used |
mean GaussCrps difference
ScoreDiff GaussCrps
Calculate GaussCrps Skill Score (deprecated, use function SkillScore instead)
GaussCrpss(mean, sd, mean.ref, sd.ref, obs)
GaussCrpss(mean, sd, mean.ref, sd.ref, obs)
mean |
forecast means |
sd |
forecast standard deviations |
mean.ref |
reference forecast means |
sd.ref |
reference forecast standard deviations |
obs |
the observation |
GaussCrps skill score
SkillScore GaussCrps
Generate artificial data for ensemble verification using a signal-plus-noise model
GenerateToyData( N = 20, mu.y = 0, s.s = 7, s.eps = 6, mu.x = 0, beta = 0.2, s.eta = 8, K = 10, mu.x.ref = NA, beta.ref = NA, s.eta.ref = NA, K.ref = NA )
GenerateToyData( N = 20, mu.y = 0, s.s = 7, s.eps = 6, mu.x = 0, beta = 0.2, s.eta = 8, K = 10, mu.x.ref = NA, beta.ref = NA, s.eta.ref = NA, K.ref = NA )
N |
number of forecasts and observations |
mu.y |
expectation value of the observations |
s.s |
standard deviation of the predictable signal |
s.eps |
standard deviation of the unpredictable noise |
mu.x |
expectation value of the ensemble |
beta |
weighting parameter of the signal in the ensemble forecasting system |
s.eta |
average spread of the ensemble |
K |
number of members of the ensemble |
mu.x.ref |
expectation value of the reference ensemble |
beta.ref |
weighting parameter of the signal in the reference ensemble forecasting system |
s.eta.ref |
average spread of the reference ensemble |
K.ref |
number of members of the reference ensemble |
The function simulates data from the latent variable model:
y_t = mu_y + s_t + eps_t
x_t,r = mu_x + beta * s_t + eta_t,r
where y_t is the observation at time t, and x_t,r is the r-th ensemble member at time t. The latent variable s_t is to be understood as the "predictable signal" that generates correlation between observations and ensemble members. If all arguments that end in ".ref" are specified, a reference ensemble is returned to also test comparative verification.
A list with elements:
N-vector of observations
N*K matrix of ensemble members
N*K.ref matrix of reference ensemble members
l <- GenerateToyData() with(l, EnsCrps(ens, obs))
l <- GenerateToyData() with(l, EnsCrps(ens, obs))
Calculate density and integrated density function of a dressed ensemble forecast at a matrix of values
GetDensity(dressed.ens, x, integrated = FALSE)
GetDensity(dressed.ens, x, integrated = FALSE)
dressed.ens |
A list returned by the function 'DressEnsemble'. See '?DressEnsemble' for details. |
x |
A matrix with either 1 row or nrow(dressed.ens[["ens"]]) rows and an arbitrary number of columns, holding the arguments at which the forecast distributions are to be evaluated. See Details. |
integrated |
logical, (default=FALSE): If 'integrated' is TRUE, the integrated density (i.e. the value of the cumulative distribution function) is returned, otherwise the value of the density is returned. |
If you want to evaluate each forecast distribution function at the same x-values, a matrix with one row can be provided, e.g. 'x = matrix(c(-1, 0, 1), nrow=1)'
If the N individual forecast distributions are to be evaluated at different x-values, a matrix with N rows must be provided, where N is the number of time instances.
To calculate the PIT values for the dressed ensemble and observations 'obs', use 'GetDensity(dressed.ens, x = matrix(obs, ncol=1), integrated=TRUE)'
The function returns a matrix, whose rows correspond to the individual ensemble forecasts and whose columns correspond to the values provided by the argument 'x'.
DressEnsemble, DressCrps, DressIgn, PlotDressedEns, FitAkdParameters
data(eurotempforecast) dressed.ens <- DressEnsemble(ens) # calculate each density at the same x-values x1 <- matrix(seq(-3, 3, 0.1), nrow=1) dens1 <- GetDensity(dressed.ens, x1) # get the densities that the forecast # distributions assign to the observations x2 <- matrix(obs, ncol=1) dens2 <- GetDensity(dressed.ens, x2) # get the integrated densities that the forecast # distributions assign to the observations (useful # for constructing a PIT histogram) pit <- GetDensity(dressed.ens, x2, integrated=TRUE)
data(eurotempforecast) dressed.ens <- DressEnsemble(ens) # calculate each density at the same x-values x1 <- matrix(seq(-3, 3, 0.1), nrow=1) dens1 <- GetDensity(dressed.ens, x1) # get the densities that the forecast # distributions assign to the observations x2 <- matrix(obs, ncol=1) dens2 <- GetDensity(dressed.ens, x2) # get the integrated densities that the forecast # distributions assign to the observations (useful # for constructing a PIT histogram) pit <- GetDensity(dressed.ens, x2, integrated=TRUE)
Plot a series forecast distributions of dressed ensembles
PlotDressedEns( dressed.ens, add = FALSE, obs = NULL, plot.ens = FALSE, plot.ker = FALSE )
PlotDressedEns( dressed.ens, add = FALSE, obs = NULL, plot.ens = FALSE, plot.ker = FALSE )
dressed.ens |
An object of class 'dressed.ens'. See ?DressEnsemble for details. |
add |
logical, default=FALSE. If TRUE, no new plotting device is created and everything is added to an existing device. |
obs |
A vector of length N, default=NULL. The verifying observations corresponding to the individual ensemble forecasts. If a vector of length N is provided (N = nrow(dressed.ens[["ens"]]), the values are added to the plot as markers. |
plot.ens |
logical, default=FALSE. If TRUE, the centers of the individual dressing kernels are indicated by markers. |
plot.ker |
logical, default=FALSE. If TRUE, the individual dressing kernels are plotted. |
none
DressEnsemble
data(eurotempforecast) d.ens <- DressEnsemble(ens) PlotDressedEns(d.ens, add=FALSE, obs=obs, plot.ens=FALSE, plot.ker=TRUE)
data(eurotempforecast) d.ens <- DressEnsemble(ens) PlotDressedEns(d.ens, add=FALSE, obs=obs, plot.ens=FALSE, plot.ker=TRUE)
Plots a rank histogram in different modes.
PlotRankhist(rank.hist, mode = "raw")
PlotRankhist(rank.hist, mode = "raw")
rank.hist |
A vector or rank counts. |
mode |
Either "raw" (default) or "prob.paper". Whether to draw the raw rank histogram, or the rank histogram on probability paper. See Details. |
The plotting modes currently implemented are:
raw (the default): A simple bar plot of the counts provided by the 'rank.hist' argument.
prob.paper: The individual counts given by 'rank.hist' are transformed to their cumulative probabilities under the binomial distribution with parameters 'N' and '1/K', where 'N=sum(rank.hist)' and 'K=length(rank.hist)'. This transformation makes possible an assessment of the observed rank counts under the hypothesis of equally likely ranks. The y-axis on the left indicates the cumulative probabilities. The intervals on the right of the plot indicate central 90, 95, and 99 percent _simultaneous_ confidence intervals. That is, if all ranks were equally likely on average, approximately 90 percent of all rank histograms would be _completely_ contained in the 90 percent interval and approximately 10 percent of all rank histograms would have _at least_ one bar that falls outside this interval.
Anderson J.L. (1996). A Method for Producing and Evaluating Probabilistic Forecasts from Ensemble Model Integrations. J. Climate, 9, 1518–1530. Broecker J. (2008). On reliability analysis of multi-categorical forecasts. Nonlin. Processes Geophys., 15, 661-673.
Rankhist, TestRankhist
data(eurotempforecast) rank.hist <- Rankhist(ens, obs) PlotRankhist(rank.hist, mode="prob.paper")
data(eurotempforecast) rank.hist <- Rankhist(ens, obs) PlotRankhist(rank.hist, mode="prob.paper")
Calculate the rank histogram for an archive of ensemble forecasts and their corresponding verifying observations.
Rankhist(ens, obs, reduce.bins = 1, handle.na = "na.fail")
Rankhist(ens, obs, reduce.bins = 1, handle.na = "na.fail")
ens |
matrix of dimension (N,K). An archive of K-member ensemble forecasts for N time instances. |
obs |
vector of length N. The corresponding verifying observations. |
reduce.bins |
number of adjacent bins that will be merged into one bin; has to be a divisor of K+1 |
handle.na |
how should missing values in ensemble and observation data be handled; possible values are 'na.fail' (fails if any data is missing) and 'use.complete' (only uses times where all ensemble members and obs are available); default: 'na.fail' |
a vector of length (K+1)/reduce.bins containing the rank counts
Anderson J.L. (1996). A Method for Producing and Evaluating Probabilistic Forecasts from Ensemble Model Integrations. J. Climate, 9, 1518–1530. Hammill T.M. (2001). Interpretation of Rank Histograms for Verifying Ensemble Forecasts. Mon. Wea. Rev., 129, 550–560.
PlotRankhist, TestRankhist
data(eurotempforecast) rh <- Rankhist(ens, obs)
data(eurotempforecast) rh <- Rankhist(ens, obs)
Reliability diagram for probability forecasts
ReliabilityDiagram( probs, obs, bins = 10, nboot = 500, plot = FALSE, plot.refin = TRUE, cons.probs = 0.95, attributes = FALSE, handle.na = c("na.fail", "use.pairwise.complete") )
ReliabilityDiagram( probs, obs, bins = 10, nboot = 500, plot = FALSE, plot.refin = TRUE, cons.probs = 0.95, attributes = FALSE, handle.na = c("na.fail", "use.pairwise.complete") )
probs |
vector of N probability forecasts for the event obs=1 |
obs |
vector of N binary observations, event/no event are coded as 0/1 |
bins |
binning to estimate the calibration function (see Details), default: 10 |
nboot |
number of bootstrap resamples to calculate the consistency bars, default: 500 |
plot |
logical, whether to plot the reliability diagram, default: FALSE |
plot.refin |
Whether to add the frequency distribution of the forecasts to the reliability diagram. default: TRUE |
cons.probs |
The width of the consitency intervals. default: 0.95. Set to NA for no consistency bars. |
attributes |
locical, whether attributes lines are included in the diagram. default: FALSE |
handle.na |
how should missing values be handled; possible values are 'na.fail' and 'use.pairwise.complete'; default: 'na.fail' |
To estimate the reliability curve, the unit line is categorised into discrete bins, provided by the 'bins' argument. If 'bins' is a single number, it specifies the number of equidistant bins. If 'bins' is a vector of values between zero and one, these values are used as the bin-breaks.
a data.frame with nrows equal to the number of bins (given by the 'bins' argument), with columns: average forecast probability per bin, conditional event frequency per bin, lower and upper limit of the consistency bar per bin, number of forecast probabilities per bin, lower and upper bin limit
Jolliffe IT, Stephenson DB, eds. (2012): Forecast verification: A practitioner's guide in atmospheric science. John Wiley & Sons, 2012. ISBN: 978-0-470-66071-3 Broecker J, Smith LA (2007): Increasing the Reliability of Reliability Diagrams. Wea. Forecasting, 22, 651–661 doi:10.1175/WAF993.1
data(eurotempforecast) p <- rowMeans(ens.bin) ReliabilityDiagram(p, obs.bin, plot=TRUE)
data(eurotempforecast) p <- rowMeans(ens.bin) ReliabilityDiagram(p, obs.bin, plot=TRUE)
Calculate the difference (mean score of the reference forecast) minus (mean score of the forecast). Uncertainty is assessed by the Diebold-Mariano test for equality of predictive accuracy.
ScoreDiff( scores, scores.ref, N.eff = NA, conf.level = 0.95, handle.na = "na.fail" )
ScoreDiff( scores, scores.ref, N.eff = NA, conf.level = 0.95, handle.na = "na.fail" )
scores |
vector of verification scores |
scores.ref |
vector of verification scores of the reference forecast, must be of the same length as 'scores' |
N.eff |
user-defined effective sample size to be used in hypothesis test and for confidence bounds; if NA, the length of 'scores' is used; default: NA |
conf.level |
confidence level for the confidence interval; default = 0.95 |
handle.na |
how should missing values in scores vectors be handled; possible values are 'na.fail' and 'use.pairwise.complete'; default: 'na.fail' |
vector with mean score difference, estimated standard error of the mean, one-sided p-value of the Diebold-Mariano test, and the user-specified confidence interval
Diebold, Mariano (1995): Comparing Predictive Accuracy. Journal of Business & Economic Statistics. https://www.jstor.org/stable/1392185
SkillScore
data(eurotempforecast) ScoreDiff(EnsCrps(ens, obs), EnsCrps(ens[, 1:2], obs))
data(eurotempforecast) ScoreDiff(EnsCrps(ens, obs), EnsCrps(ens[, 1:2], obs))
A skill score is defined as (mean score - mean reference score) / (perfect score - mean reference score). The skill score is zero if the mean score of the forecast equals the mean score of the reference forecast, and equals one if the mean score of the forecast equals the best possible score. Uncertainty is assessed by estimating the standard deviation of the skill score by propagation of uncertainty.
SkillScore( scores, scores.ref, N.eff = NA, score.perf = 0, handle.na = c("na.fail", "use.pairwise.complete") )
SkillScore( scores, scores.ref, N.eff = NA, score.perf = 0, handle.na = c("na.fail", "use.pairwise.complete") )
scores |
vector of verification scores |
scores.ref |
vector of verification scores of the reference forecast, must be of the same length as 'scores' |
N.eff |
user-defined effective sample size to be used to estimate the sampling uncertainty; if NA, the length of 'scores' is used; default: NA |
score.perf |
a numeric constant, indicating the value that the score would assign to the perfect forecast |
handle.na |
how should missing values in scores vectors be handled; possible values are 'na.fail' and 'use.pairwise.complete'; default: 'na.fail' |
vector with skill score and its estimated standard deviation
ScoreDiff
data(eurotempforecast) SkillScore(EnsCrps(ens, obs), EnsCrps(ens[, 1:2], obs))
data(eurotempforecast) SkillScore(EnsCrps(ens, obs), EnsCrps(ens[, 1:2], obs))
SpecsVerification - Forecast verification routines
: Stefan Siegert
Calculate the squared error between forecast and observation
SqErr(fcst, obs)
SqErr(fcst, obs)
fcst |
a N-vector representing N time instances of real-valued forecasts |
obs |
a N-vector representing N time instances of real-valued observations |
numeric N-vector of squared errors
AbsErr, ScoreDiff, SkillScore
data(eurotempforecast) mean(SqErr(rowMeans(ens), obs))
data(eurotempforecast) mean(SqErr(rowMeans(ens), obs))
Perform statistical tests related to the deviation from flatness of a rank histogram.
TestRankhist(rank.hist)
TestRankhist(rank.hist)
rank.hist |
Vector of rank counts. Generated by function 'Rankhist()' |
Given a vector of rank counts 'x', the Pearson Chi^2 statistic is calculated by
sum((x - sum(x)/length(x))^2 / (sum(x)/length(x)))
and has a chi^2 distribution with (length(x)-1) degrees of freedom if every rank is equally likely on average. The Jolliffe-Primo test statistics are calculated by projecting the vector
(x-sum(x)/length(x)) / sqrt(sum(x)/length(x))
onto a linear, respectively squared contrast, i.e. a linear and quadratic function defined over the index set 1:length(x), who are mutually orthogonal, whose elements sum to zero, and whose squared elements sum to one. The projections independently have chi^2 distributions with 1 degree of freedom under the null hypothesis of a flat rank histogram.
A dataframe whose columns refer to the Pearson Chi^2 statistic, the Jolliffe-Primo test statistic for slope, and the Jolliffe-Primo test statistic for convexity. The rows refer to the actual test statistic and its p-value under the null hypothesis of a flat rank histogram.
Pearson K. (1900): X. On the criterion that a given system of deviations from the probable in the case of a correlated system of variables is such that it can be reasonably supposed to have arisen from random sampling. Phil. Mag. Series 5, 50(302) doi:10.1080/14786440009463897
Jolliffe I.T., Primo C. (2008): Evaluating rank histograms using decompositions of the chi-square test statistic. Mon. Wea. Rev. 136(6) doi:10.1175/2007MWR2219.1
Rankhist, PlotRankhist
data(eurotempforecast) rh <- Rankhist(ens, obs) TestRankhist(rh)
data(eurotempforecast) rh <- Rankhist(ens, obs) TestRankhist(rh)