mse {jjb} | R Documentation |
Mean Squared Error (MSE)
Description
Calculates the mean square of the model by taking the mean of the
sum of squares between the truth, y
, and the predicted, \hat{y}
at each observation i
.
Usage
mse(y, yhat)
Arguments
y |
A |
yhat |
A |
Details
The equation for MSE is:
\frac{1}{n}\sum\limits_{i = 1}^n {{{\left( {{y_i} - {{\hat y}_i}} \right)}^2}}
Value
The MSE in numeric
form.
Examples
# Set seed for reproducibility
set.seed(100)
# Generate data
n = 1e2
y = rnorm(n)
yhat = rnorm(n, 0.5)
# Compute
o = mse(y, yhat)
[Package jjb version 0.1.1 Index]