the MSE is the mean of the square of the errors, corresponding to the expected value of the squared error loss or quadratic loss. The difference occurs because of randomness or because the estimator doesn't account for information that could produce a more accurate estimate.
mse(observados, estimados, k)
vector of values observed.
vector of regression model data.
the number of model parameters
mse = (sum(estimados-observados)^2)/(length(observados)-k)
See https://en.wikipedia.org/wiki/Mean_squared_error for more details.