Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

RMS

Computes Root Mean Square Error


Description

Computes the root mean square error for an array of forecasts, var_exp and an array of observations, var_obs, which should have the same dimensions except along the posloop dimension where the lengths can be different, with the number of experiments/models for var_exp (nexp) and the number of obserational datasets for var_obs (nobs).
The RMSE is computed along the posRMS dimension which should correspond to the startdate dimension.
If compROW is given, the RMSE is computed only if rows along the compROW dimension are complete between limits[1] and limits[2], i.e. there are no NAs between limits[1] and limits[2]. This option can be activated if the user wishes to account only for the forecasts for which observations are available at all leadtimes.
Default: limits[1] = 1 and limits[2] = length(compROW dimension).
The confidence interval relies on a chi2 distribution.

.RMS provides the same functionality but taking a matrix of ensemble members as input (exp).

Usage

RMS(
  var_exp,
  var_obs,
  posloop = 1,
  posRMS = 2,
  compROW = NULL,
  limits = NULL,
  siglev = 0.95,
  conf = TRUE
)

.RMS(exp, obs, siglev = 0.95, conf = TRUE)

Arguments

var_exp

Matrix of experimental data.

var_obs

Matrix of observational data, same dimensions as var_exp except along posloop dimension, where the length can be nobs instead of nexp.

posloop

Dimension nobs and nexp.

posRMS

Dimension along which RMSE are to be computed (the dimension of the start dates).

compROW

Data taken into account only if (compROW)th row is complete.
Default = NULL.

limits

Complete between limits[1] & limits[2]. Default = NULL.

siglev

Confidence level of the computed confidence interval. 0.95 by default.

conf

Whether to compute confidence interval or not. TRUE by default.

exp

N by M matrix of N forecasts from M ensemble members.

obs

Vector of the corresponding observations of length N.

Value

RMS: Array with dimensions:
c(length(posloop) in var_exp, length(posloop) in var_obs, 1 or 3, all other dimensions of var_exp & var_obs except posRMS).
The 3rd dimension corresponds to the lower limit of the 95% confidence interval (only present if conf = TRUE), the RMSE, and the upper limit of the 95% confidence interval (only present if conf = TRUE).

.RMS:

$rms

The root mean square error,

$conf_low

Corresponding to the lower limit of the siglev% confidence interval (only present if conf = TRUE) for the rms.

$conf_high

Corresponding to the upper limit of the siglev% confidence interval (only present if conf = TRUE) for the rms.

Author(s)

History:
0.1 - 2011-05 (V. Guemas, vguemas@ic3.cat) - Original code
1.0 - 2013-09 (N. Manubens, nicolau.manubens2@ic3.cat) - Formatting to R CRAN
1.1 - 2017-02 (A. Hunter, alasdair.hunter@bsc.es) - Adapted to veriApply()

Examples

# Load sample data as in Load() example:
example(Load)
clim <- Clim(sampleData$mod, sampleData$obs)
ano_exp <- Ano(sampleData$mod, clim$clim_exp)
ano_obs <- Ano(sampleData$obs, clim$clim_obs)
runmean_months <- 12
dim_to_smooth <- 4  # Smooth along lead-times
smooth_ano_exp <- Smoothing(ano_exp, runmean_months, dim_to_smooth)
smooth_ano_obs <- Smoothing(ano_obs, runmean_months, dim_to_smooth)
dim_to_mean <- 2  # Mean along members
# Discard start-dates for which some leadtimes are missing
required_complete_row <- 3
leadtimes_per_startdate <- 60
rms <- RMS(Mean1Dim(smooth_ano_exp, dim_to_mean), 
          Mean1Dim(smooth_ano_obs, dim_to_mean), 
          compROW = required_complete_row, 
          limits = c(ceiling((runmean_months + 1) / 2), 
                     leadtimes_per_startdate - floor(runmean_months / 2)))
 
PlotVsLTime(rms, toptitle = "Root Mean Square Error", ytitle = "K", 
           monini = 11, limits = NULL, listexp = c('CMIP5 IC3'), 
           listobs = c('ERSST'), biglab = FALSE, hlines = c(0), 
           fileout = 'tos_rms.eps')
 
# The following example uses veriApply combined with .RMS instead of RMS
 ## Not run: 
require(easyVerification)
RMS2 <- s2dverification:::.RMS
rms2 <- veriApply("RMS2",
                 smooth_ano_exp,
                 # see ?veriApply for how to use the 'parallel' option
                 Mean1Dim(smooth_ano_obs, dim_to_mean),
                 tdim = 3, ensdim = 2)
 
## End(Not run)

s2dverification

Set of Common Tools for Forecast Verification

v2.10.0
Apache License 2.0
Authors
BSC-CNS [aut, cph], Virginie Guemas [aut], Nicolau Manubens [aut], An-Chi Ho [ctb, cre], Nuria Perez-Zanon [ctb], Javier Garcia-Serrano [aut], Neven Fuckar [aut], Louis-Philippe Caron [aut], Omar Bellprat [aut], Luis Rodrigues [aut], Veronica Torralba [aut], Alasdair Hunter [aut], Chloe Prodhomme [aut], Martin Menegoz [aut], Domingo Manubens [ctb], Constantin Ardilouze [ctb], Lauriane Batte [ctb], Fabian Lienert [ctb], Julia Giner [ctb], Jean-Philippe Baudouin [ctb], Nube Gonzalez [ctb], Ludovic Auger [ctb], Nicola Cortesi [ctb], Eleftheria Exarchou [ctb], Ruben Cruz [ctb], Isabel Andreu-Burillo [ctb], Ramiro Saurral [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.