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

intFun.rmse

Root mean square error (RMSE)


Description

This function computes the root mean square error (RMSE), which is defined as:

$rmse(λ, φ)=√{\frac{1}{t_{f}-t_{0}}\int_{t_{0}}^{t_{f}}(v_{mod}(t,λ, φ)-v_{ref}(t,λ, φ))^{2}dt}$

where λ is the longitude, φ 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 and v_{ref} is the corresponding reference variable.

Usage

intFun.rmse(mod, ref)

Arguments

mod

An R object (model output data)

ref

An R object (reference data)

Value

An R object that gives the root mean square error when comparing mod against ref.

Examples

library(raster)
# create two raster stacks
for(i in 1:100)
{
 mod <- raster::raster(matrix(runif(100,-1,1), ncol=10))
 ref <- raster::raster(matrix(runif(100,-2,2), 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 RMSE
rmse <- intFun.rmse(mod,ref)
plot(rmse); text(rmse, digits=2)

amber

Automated Model Benchmarking R Package

v1.0.3
GPL-3
Authors
Christian Seiler [cre, aut]
Initial release

We don't support your browser anymore

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