Mean squared error
In statistics, the mean squared error or mean squared deviation of an estimator measures the average of the squares of the errors—that is, the average squared difference between the estimated values and the true value. MSE is a risk function, corresponding to the expected value of the squared error loss. The fact that MSE is almost always strictly positive is because of randomness or because the estimator does not account for information that could produce a more accurate estimate. In machine learning, specifically empirical risk minimization, MSE may refer to the empirical risk, as an estimate of the true MSE.
The MSE is a measure of the quality of an estimator. As it is derived from the square of Euclidean distance, it is always a positive value that decreases as the error approaches zero.
The MSE is the second moment of the error, and thus incorporates both the variance of the estimator and its bias. For an unbiased estimator, the MSE is the variance of the estimator. Like the variance, MSE has the same units of measurement as the square of the quantity being estimated. In an analogy to standard deviation, taking the square root of MSE yields the root-mean-square error or root-mean-square deviation, which has the same units as the quantity being estimated; for an unbiased estimator, the RMSE is the square root of the variance, known as the standard error.
Definition and basic properties
The MSE either assesses the quality of a predictor, or of an estimator. In the context of prediction, understanding the prediction interval can also be useful as it provides a range within which a future observation will fall, with a certain probability. The definition of an MSE differs according to whether one is describing a predictor or an estimator.Predictor
If a vector of predictions is generated from a sample of data points on all variables, and is the vector of observed values of the variable being predicted, with being the predicted values, then the within-sample MSE of the predictor is computed asIn other words, the MSE is the mean of the squares of the errors. This is an easily computable quantity for a particular sample.
In matrix notation,
where is and is a column vector.
The MSE can also be computed on q data points that were not used in estimating the model, either because they were held back for this purpose, or because these data have been newly obtained. Within this process, known as cross-validation, the MSE is often called the test MSE, and is computed as
Estimator
The MSE of an estimator with respect to an unknown parameter is defined asThis definition depends on the unknown parameter, therefore the MSE is a priori property of an estimator. The MSE could be a function of unknown parameters, in which case any estimator of the MSE based on estimates of these parameters would be a function of the data. If the estimator is derived as a sample statistic and is used to estimate some population parameter, then the expectation is with respect to the sampling distribution of the sample statistic.
The MSE can be written as the sum of the variance of the estimator and the squared bias of the estimator, providing a useful way to calculate the MSE and implying that in the case of unbiased estimators, the MSE and variance are equivalent.
Proof of variance and bias relationship
An even shorter proof can be achieved using the well-known formula that for a random variable,. By substituting with,, we haveBut in real modeling case, MSE could be described as the addition of model variance, model bias, and irreducible uncertainty. According to the relationship, the MSE of the estimators could be simply used for the efficiency comparison, which includes the information of estimator variance and bias. This is called MSE criterion.
In regression
In regression analysis, plotting is a more natural way to view the overall trend of the whole data. The mean of the distance from each point to the predicted regression model can be calculated, and shown as the mean squared error. The squaring is critical to reduce the complexity with negative signs. To minimize MSE, the model could be more accurate, which would mean the model is closer to actual data. One example of a linear regression using this method is the least squares method—which evaluates appropriateness of linear regression model to model bivariate dataset, but whose limitation is related to known distribution of the data.The term mean squared error is sometimes used to refer to the unbiased estimate of error variance: the residual sum of squares divided by the number of degrees of freedom. This definition for a known, computed quantity differs from the above definition for the computed MSE of a predictor, in that a different denominator is used. The denominator is the sample size reduced by the number of model parameters estimated from the same data, for p regressors or if an intercept is used. Although the MSE is not an unbiased estimator of the error variance, it is consistent, given the consistency of the predictor.
In regression analysis, "mean squared error", often referred to as mean squared prediction error or "out-of-sample mean squared error", can also refer to the mean value of the squared deviations of the predictions from the true values, over an out-of-sample test space, generated by a model estimated over a particular sample space. This also is a known, computed quantity, and it varies by sample and by out-of-sample test space.
In the context of gradient descent algorithms, it is common to introduce a factor of to the MSE for ease of computation after taking the derivative. So a value which is technically half the mean of squared errors may be called the MSE.
Examples
Mean
Suppose we have a random sample of size from a population,. Suppose the sample units were chosen with replacement. That is, the units are selected one at a time, and previously selected units are still eligible for selection for all draws. The usual estimator for the population mean is the sample averagewhich has an expected value equal to the true mean and a mean squared error of
where is the population variance.
For a Gaussian distribution this is the best unbiased estimator of the population mean, that is the one with the lowest MSE among all unbiased estimators. One can check that the MSE above equals the inverse of the Fisher information. But the same sample mean is not the best estimator of the population mean, say, for a uniform distribution.
Variance
The usual estimator for the variance is the corrected sample variance:This is unbiased, hence also called the unbiased sample variance, and its MSE is
where is the fourth central moment of the distribution or population, and is the excess kurtosis.
However, one can use other estimators for which are proportional to, and an appropriate choice can always give a lower mean squared error. If we define
then we calculate:
This is minimized when
For a Gaussian distribution, where, this means that the MSE is minimized when dividing the sum by. The minimum excess kurtosis is, which is achieved by a Bernoulli distribution with p = 1/2, and the MSE is minimized for Hence regardless of the kurtosis, we get a "better" estimate by scaling down the unbiased estimator a little bit; this is a simple example of a shrinkage estimator: one "shrinks" the estimator towards zero.
Further, while the corrected sample variance is the best unbiased estimator of variance for Gaussian distributions, if the distribution is not Gaussian, then even among unbiased estimators, the best unbiased estimator of the variance may not be
Gaussian distribution
The following table gives several estimators of the true parameters of the population, μ and σ2, for the Gaussian case.| True value | Estimator | Mean squared error |
| = the unbiased estimator of the population mean, | ||
| = the unbiased estimator of the population variance, | ||
| = the biased estimator of the population variance, | ||
| = the biased estimator of the population variance, |
Interpretation
An MSE of zero, meaning that the estimator predicts observations of the parameter with perfect accuracy, is ideal.Values of MSE may be used for comparative purposes. Two or more statistical models may be compared using their MSEs—as a measure of how well they explain a given set of observations: An unbiased estimator with the smallest variance among all unbiased estimators is the best unbiased estimator or MVUE.
Both analysis of variance and linear regression techniques estimate the MSE as part of the analysis and use the estimated MSE to determine the statistical significance of the factors or predictors under study. The goal of experimental design is to construct experiments in such a way that when the observations are analyzed, the MSE is close to zero relative to the magnitude of at least one of the estimated treatment effects.
In one-way analysis of variance, MSE can be calculated by the division of the sum of squared errors and the degree of freedom. Also, the f-value is the ratio of the mean squared treatment and the MSE.
MSE is also used in several stepwise regression techniques as part of the determination as to how many predictors from a candidate set to include in a model for a given set of observations.
Applications
Minimizing MSE is a key criterion in selecting estimators; see minimum mean-square error. Among unbiased estimators, minimizing the MSE is equivalent to minimizing the variance, and the estimator that does this is the minimum variance unbiased estimator. However, a biased estimator may have lower MSE; see estimator bias.In statistical modelling the MSE can represent the difference between the actual observations and the observation values predicted by the model. In this context, it is used to determine the extent to which the model fits the data as well as whether removing some explanatory variables is possible without significantly harming the model's predictive ability.
In forecasting and prediction, the Brier score is a measure of forecast skill based on MSE.