Learn R Programming

amber (version 1.0.3)

intFun.crmse: Centralized root mean square error (CRMSE)

Description

This function computes the centralized root mean square error, which is defined as:

\($crmse(\lambda, \phi) = \sqrt{\frac{1}{t_{f}-t_{0}}\int_{t_{0}}^{t_{f}}[(v_{mod}(t,\lambda, \phi)-\overline{v_{mod}}(\lambda, \phi))-(v_{ref}(t,\lambda, \phi)-\overline{v_{ref}}(\lambda, \phi))]^{2}dt}$\)

where \(\lambda\) is the longitude, \(\phi\) is the latitude, \(t\) is the time, \(t_0\) is the initial time step, \(t_f\) is the final time time step, \(v_{mod}\) is a modelled variable, \(v_{ref}\) is the corresponding reference variable, \(\overline{v_{mod}}\) is the time-mean modelled variable, and \(\overline{v_{ref}}\) is the time-mean reference variable.

Usage

intFun.crmse(mod.anom, ref.anom)

Arguments

mod.anom

An R object (e.g. monthly anomalies from model output)

ref.anom

An R object (e.g. monthly anomalies from reference data)

Value

An R object that shows the centralized root mean square error

Examples

Run this code
# NOT RUN {
library(raster)
# create two raster stacks
for(i in 1:100)
{
 mod <- raster::raster(matrix(runif(100,0,10), ncol=10))
 ref <- raster::raster(matrix(runif(100,0,10), ncol=10))
 assign(paste('mod', i , sep='_'), mod)
 assign(paste('ref', i , sep='_'), ref)
}
my.list.mod <- lapply(ls(pattern='mod_'), get)
my.list.ref <- lapply(ls(pattern='ref_'), get)
mod <- do.call(stack, my.list.mod)
ref <- do.call(stack, my.list.ref)
# compute anomalies
mod.anom <- intFun.anom(mod)
ref.anom <- intFun.anom(ref)
# compute CRMSE
crmse <- intFun.crmse(mod.anom, ref.anom)
plot(crmse); text(crmse, digits=2)

# }

Run the code above in your browser using DataLab