smape_vec: Calculate the symmetric mean absolute percentage error

View source: R/metrics.R

smape_vecR Documentation

Calculate the symmetric mean absolute percentage error

Description

Calculate the symmetric mean absolute percentage error of a numeric vector.

Usage

smape_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.

Details

smape_vec() computes the symmetric mean absolute percentage error: abs(estimate - truth) / ((abs(truth) + abs(estimate)) / 2) * 100.

This metric is undefined when both truth and estimate are zero and may return NaN in such cases.

Value

A numeric value.

See Also

Other accuracy functions: mae_vec(), make_accuracy(), make_errors(), mape_vec(), me_vec(), mpe_vec(), mse_vec(), rmse_vec()

Examples

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

smape_vec(truth, estimate)

truth_na <- c(10, 20, NA)
estimate_na <- c(8, 22, 25)
smape_vec(truth_na, estimate_na)

tscv documentation built on May 13, 2026, 9:07 a.m.