Lably
Skip to content

Mean squared error

Measure of the error of an estimator

  • 9 min read
  • 6 chapters

Related on Lably

Through Statistics, Expected value and Loss function

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 (about the origin) of the error, and thus incorporates both the variance of the estimator (how widely spread the estimates are from one data sample to another) and its bias (how far off the average estimated value is from the true value). 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 (RMSE or RMSD), 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 (i.e., a function mapping arbitrary inputs to a sample of values of some random variable), or of an estimator (i.e., a mathematical function mapping a sample of data to an estimate of a parameter of the population from which the data is sampled). 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 n predictions is generated from a sample of n data points on all variables, and Y is the vector of observed values of the variable being predicted, with Y^ being the predicted values (e.g. as from a least-squares fit), then the within-sample MSE of the predictor is computed as

MSE=1n∑i=1n(Yi−Yi^)2

In other words, the MSE is the mean (1n∑i=1n) of the squares of the errors (Yi−Yi^)2. This is an easily computable quantity for a particular sample (and hence is sample-dependent).

In matrix notation, MSE=1n∑i=1n(ei)2=1neTe where ei is Yi−Yi^ and e is a n×1 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

MSE=1q∑i=n+1n+q(Yi−Yi^)2

Estimator

The MSE of an estimator θ^ with respect to an unknown parameter θ is defined as

MSE⁡(θ^)=Eθ⁡[(θ^−θ)2].

This 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 (and thus a random variable). 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.

MSE⁡(θ^)=Varθ⁡(θ^)+Bias⁡(θ^,θ)2.

Proof of variance and bias relationship

MSE⁡(θ^)=Eθ⁡[(θ^−θ)2]=Eθ⁡[(θ^−Eθ⁡[θ^]+Eθ⁡[θ^]−θ)2]=Eθ⁡[(θ^−Eθ⁡[θ^])2+2(θ^−Eθ⁡[θ^])(Eθ⁡[θ^]−θ)+(Eθ⁡[θ^]−θ)2]=Eθ⁡[(θ^−Eθ⁡[θ^])2]+Eθ⁡[2(θ^−Eθ⁡[θ^])(Eθ⁡[θ^]−θ)]+Eθ⁡[(Eθ⁡[θ^]−θ)2]=Eθ⁡[(θ^−Eθ⁡[θ^])2]+2(Eθ⁡[θ^]−θ)Eθ⁡[θ^−Eθ⁡[θ^]]+(Eθ⁡[θ^]−θ)2Eθ⁡[θ^]−θ=constant=Eθ⁡[(θ^−Eθ⁡[θ^])2]+2(Eθ⁡[θ^]−θ)(Eθ⁡[θ^]−Eθ⁡[θ^])+(Eθ⁡[θ^]−θ)2Eθ⁡[θ^]=constant=Eθ⁡[(θ^−Eθ⁡[θ^])2]+(Eθ⁡[θ^]−θ)2=Varθ⁡(θ^)+Biasθ⁡(θ^,θ)2

An even shorter proof can be achieved using the well-known formula that for a random variable X, E(X2)=Var⁡(X)+(E(X))2. By substituting X with, θ^−θ, we have MSE⁡(θ^)=E[(θ^−θ)2]=Var⁡(θ^−θ)+(E[θ^−θ])2=Var⁡(θ^)+Bias2⁡(θ^,θ) But in real modeling case, MSE could be described as the addition of model variance, model bias, and irreducible uncertainty (see Bias–variance tradeoff). 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.

Sign in to keep reading

5 more chapters are free with a Lably account.

More in Statistics