| GeoScores | R Documentation |
The function computes predictive scores for observed validation values from
point predictions, kriging prediction objects, or conditional-simulation
objects. Gaussian predictive scores are available from GeoKrig/GeoKrigloc
through the pred/mse convention, while GeoSimcond
objects are scored from their empirical conditional predictive distribution.
GeoScores(data_to_pred,
probject = NULL,
pred = NULL,
mse = NULL,
score = c("pe", "crps", "intscore", "coverage"),
lower95 = NULL,
upper95 = NULL,
threshold = 0.5,
na.rm = TRUE)
data_to_pred |
Numeric vector, matrix or array containing the observed validation values. Values are internally coerced to a numeric vector. |
probject |
Optional object of class For |
pred |
Numeric vector, matrix or array of point predictions. This argument is
required when |
mse |
Optional numeric vector, matrix or array of prediction variances. Predictive
standard errors are computed as |
score |
Character vector specifying which predictive scores should be computed.
Possible values are |
lower95 |
Optional numeric vector, matrix or array containing the lower bounds of the
95 percent prediction intervals. If supplied together with |
upper95 |
Optional numeric vector, matrix or array containing the upper bounds of the
95 percent prediction intervals. See |
threshold |
Finite numeric scalar used to compute the Brier score |
na.rm |
Logical. If |
GeoScores dispatches predictive scoring according to the information
contained in probject.
For a GeoKrig or GeoKrigloc object, pred is the point
predictor and mse its mean squared prediction error. The option
"pe" returns mean absolute error and root mean squared prediction
error. Whenever probabilistic scores are requested, GeoScores uses the
Gaussian predictive convention
Y_0\mid Y \ \dot\sim\ N\{\widehat Y_0, MSE_0\}.
This convention is used for every marginal model. For a Gaussian random field
it is the natural conditional predictive distribution (conditional on fitted
parameters). For a non-Gaussian model, GeoKrig/GeoKrigloc
still returns an optimal linear predictor, so CRPS, LogScore, PIT, Brier score,
and Gaussian intervals obtained this way must be interpreted as Gaussian
predictive approximations based on the OLP and its MSE. GeoScores does
not suppress those quantities; their scientific interpretation is left to the
user.
Predictions and prediction variances can equivalently be supplied directly
through pred and mse; this uses the same Gaussian predictive
convention.
For a GeoSimcond object, the replications stored in
probject$condsim are treated as an empirical conditional predictive
distribution at each prediction location. No Gaussian approximation is used.
The point forecast for "pe" is probject$cond_mean (or the
empirical conditional mean reconstructed from the simulations if needed).
The Brier probability for the event Y>threshold is the empirical
conditional exceedance probability. PIT is the empirical conditional CDF at
the validation observation. The default 95 percent predictive interval is
given by the empirical 0.025 and 0.975 quantiles, unless explicit
lower95/upper95 values are supplied.
The empirical CRPS from conditional draws
x_1,\ldots,x_B is
\widehat{CRPS}(F,y)=
\frac{1}{B}\sum_{b=1}^B |x_b-y|-
\frac{1}{2B^2}\sum_{b=1}^B\sum_{c=1}^B |x_b-x_c|.
It is evaluated internally with an equivalent sorted-sample formula requiring
O(B\log B) rather than O(B^2) work per prediction location.
A logarithmic score is not computed automatically from a
GeoSimcond object. Conditional draws identify the predictive
distribution empirically but do not by themselves provide a predictive
density evaluated exactly at the observed value. If "lscore" is
requested from a GeoSimcond object, LogScore = NA is returned
with a warning; no kernel-density approximation is introduced silently.
In the Gaussian pred/mse path, the Brier score uses the
Gaussian predictive probability of Y>threshold; the logarithmic score
is the mean negative Gaussian log predictive density; PIT uses the Gaussian
CDF; and CRPS uses the closed-form Gaussian expression.
The 95 percent interval score is
(u-l)+\frac{2}{\alpha}(l-y)I(y<l)+
\frac{2}{\alpha}(y-u)I(y>u), \qquad \alpha=0.05.
For GeoKrig/GeoKrigloc without explicit interval bounds,
l and u are Gaussian intervals based on pred and
mse. For GeoSimcond, they are empirical conditional-simulation
quantiles. Empirical coverage is the proportion of validation observations
lying in the corresponding intervals.
A list containing only the components requested through score:
MAE |
Mean absolute error. For |
RMSPE |
Root mean squared prediction error. |
Brier |
Brier score for the event |
LogScore |
Mean negative Gaussian log predictive density for the
|
PIT |
Gaussian PIT values for the |
CRPS |
Mean Gaussian CRPS for the kriging/direct-prediction path, or
mean empirical CRPS from conditional simulations for |
IS95 |
Mean interval score for the 95 percent prediction intervals. |
Cvg95 |
Empirical coverage of the 95 percent prediction intervals. |
Moreno Bevilacqua, moreno.bevilacqua89@gmail.com, https://sites.google.com/view/moreno-bevilacqua/home,
Víctor Morales Oñate, victor.morales@uv.cl, https://sites.google.com/site/moralesonatevictor/,
Christian Caamaño-Carrillo, chcaaman@ubiobio.cl, https://www.researchgate.net/profile/Christian-Caamano
Gneiting, T. and Raftery, A. E. (2007). Strictly Proper Scoring Rules, Prediction, and Estimation. Journal of the American Statistical Association, 102, 359–378.
Heaton, M. J., Datta, A., Finley, A. O., Furrer, R., Guinness, J., Guhaniyogi, R., Gerber, F., Gramacy, R. B., Hammerling, D., Katzfuss, M., Lindgren, F., Nychka, D. W., Sun, F., and Zammit-Mangion, A. (2019). A Case Study Competition Among Methods for Analyzing Large Spatial Data. Journal of Agricultural, Biological, and Environmental Statistics, 24, 398–425.
library(GeoModels)
################################################################
######### Example of predictive score computation #############
################################################################
model <- "Gaussian"
set.seed(79)
N <- 1000
x <- runif(N, 0, 1)
y <- runif(N, 0, 1)
coords <- cbind(x, y)
# Set covariance parameters
corrmodel <- "GenWend"
mean <- 0
sill <- 5
nugget <- 0
scale <- 0.2
smooth <- 0
power2 <- 4
param <- list(mean = mean, sill = sill, nugget = nugget,
scale = scale, smooth = smooth, power2 = power2)
# Simulation of the spatial Gaussian random field
data <- GeoSim(coordx = coords, corrmodel = corrmodel,
param = param)$data
# Training and validation split
sel <- sample(1:N, N * 0.8)
coords_est <- coords[sel, ]
coords_to_pred <- coords[-sel, ]
data_est <- data[sel]
data_to_pred <- data[-sel]
# Pairwise likelihood fitting
fixed <- list(nugget = nugget, smooth = smooth, power2 = power2)
start <- list(mean = 0, scale = scale, sill = 1)
I <- Inf
lower <- list(mean = -I, scale = 0, sill = 0)
upper <- list(mean = I, scale = I, sill = I)
fit <- GeoFit(data_est, coordx = coords_est,
corrmodel = corrmodel, model = model,
likelihood = "Marginal", type = "Pairwise",
neighb = 3, optimizer = "nlminb",
lower = lower, upper = upper,
start = start, fixed = fixed)
# Prediction at validation locations
pr <- GeoKrig(fit,loc = coords_to_pred, data = data_est, mse = TRUE)
# Predictive scores from pred and mse
Pr_scores <- GeoScores(data_to_pred, pred = pr$pred, mse = pr$mse,
score = c("pe", "brie", "crps", "lscore",
"pit", "intscore", "coverage"),
threshold = 0)
Pr_scores$MAE
Pr_scores$RMSPE
Pr_scores$Brier
Pr_scores$CRPS
Pr_scores$LogScore
Pr_scores$IS95
Pr_scores$Cvg95
# Conditional-simulation objects can be scored directly. For example,
# after obtaining cs <- GeoSimcond(..., nrep = 500), use
# GeoScores(data_to_pred, cs)
# to compute point scores, empirical CRPS, empirical 95 percent interval
# score, and empirical coverage from cs$condsim.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.