The MSE is a metric that evaluates the goodness of fit between model
simulations and observations (Fisher, 1920). Measured in the squared
units of truth
and estimate
and can vary from \(-\infty\) to
\(+\infty\).
Usage
mse(data, ...)
# S3 method for class 'data.frame'
mse(data, truth, estimate, na_rm = TRUE, ...)
mse_vec(truth, estimate, na_rm = TRUE, ...)
Arguments
- data
A
data.frame
containing the columns specified by thetruth
andestimate
arguments.- ...
Not currently used.
- truth
The column identifier for the true results (that is
numeric
). This should be an unquoted column name although this argument is passed by expression and supports quasiquotation (you can unquote column names). For_vec()
functions, anumeric
vector.- estimate
The column identifier for the predicted results (that is also
numeric
). As withtruth
this can be specified different ways but the primary method is to use an unquoted variable name. For_vec()
functions, anumeric
vector.- na_rm
A
logical
value indicating whetherNA
values should be stripped before the computation proceeds.
Value
A tibble
with columns .metric
, .estimator
,
and .estimate
and 1 row of values.
For grouped data frames, the number of rows returned will be the same as the number of groups.
For mse_vec()
, a single numeric
value (or NA
).
Details
The MSE is estimated as follows (Clark et al., 2021): $$ MSE = \frac{1}{n} \sum_{i=1}^{n}{(sim_i - obs_i)^2} $$ where:
\(sim\) defines model simulations at time step \(i\)
\(obs\) defines model observations at time step \(i\)
References
Fisher, R. A. (1920). Accuracy of observation, a mathematical examination of the methods of determining, by the mean error and by the mean square error. Monthly Notices of the Royal Astronomical Society, 80, 758–770. doi:10.1093/mnras/80.8.758
Clark, M. P., Vogel, R. M., Lamontagne, J. R., Mizukami, N., Knoben, W. J. M., Tang, G., Gharari, S., Freer, J. E., Whitfield, P. H., Shook, K. R., & Papalexiou, S. M. (2021). The Abuse of Popular Performance Metrics in Hydrologic Modeling. Water Resources Research, 57(9), e2020WR029001. doi:10.1029/2020WR029001