Skip to contents

Calculate the root mean squared error of a numeric vector.

Usage

rmse_vec(truth, estimate, na_rm = TRUE)

Arguments

truth

Numeric vector containing the actual values.

estimate

Numeric vector containing the forecasts.

na_rm

Logical value. If TRUE, missing values are removed.

Value

A numeric value.

Details

rmse_vec() computes the square root of the mean squared forecast error. The metric is reported in the same units as the original data.

Examples

truth <- c(10, 20, 30)
estimate <- c(8, 22, 25)

rmse_vec(truth, estimate)
#> [1] 3.316625

truth_na <- c(10, 20, NA)
estimate_na <- c(8, 22, 25)
rmse_vec(truth_na, estimate_na)
#> [1] 2