Computes the mean squared error (MSE) between predicted
and reference values.
Usage
mse(x, ...)
# Default S3 method
mse(x, ref, na.rm = FALSE, ...)
Arguments
- x
a numeric vector of predicted values.
Methods for fitted models are provided by the package alloy.
- ...
additional arguments passed to methods
- ref
numeric vector of reference (true) values
- na.rm
logical; whether to remove missing values
Value
a numeric scalar containing the MSE
Details
The mean squared error is defined as:
$$
\frac{1}{n} \sum (ref - x)^2
$$
Examples
x <- c(2.5, 3.0, 2.8)
ref <- c(3.0, 2.5, 3.0)
mse(x, ref)
#> [1] 0.18