mse_vec: Calculate the mean squared error

View source: R/metrics.R

mse_vecR Documentation

Calculate the mean squared error

Description

Calculate the mean squared error of a numeric vector.

Usage

mse_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

mse_vec() computes the average squared forecast error (truth - estimate)^2. The metric is reported in squared units of the original data.

Value

A numeric value.

See Also

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

Examples

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

mse_vec(truth, estimate)

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

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