 #jsDisabledContent { display:none; } My Account | Register | Help Flag as Inappropriate This article will be permanently flagged as inappropriate and made unaccessible to everyone. Are you certain this article is inappropriate?          Excessive Violence          Sexual Content          Political / Social Email this Article Email Address:

# Mean squared error

Article Id: WHEBN0000201816
Reproduction Date:

 Title: Mean squared error Author: World Heritage Encyclopedia Language: English Subject: Collection: Publisher: World Heritage Encyclopedia Publication Date:

### Mean squared error

In statistics, the mean squared error (MSE) of an estimator measures the average of the squares of the "errors", that is, the difference between the estimator and what is estimated. MSE is a risk function, 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.

The MSE is the second moment (about the origin) 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 (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 deviation.

## Contents

• Definition and basic properties 1
• Predictor 1.1
• Estimator 1.2
• Proof of variance and bias relationship 1.2.1
• Regression 2
• Examples 3
• Mean 3.1
• Variance 3.2
• Gaussian distribution 3.3
• Interpretation 4
• Applications 5
• Loss function 6
• Criticism 6.1
• Notes 8
• References 9

## Definition and basic properties

The MSE assesses the quality of an estimator (i.e., a mathematical function mapping a sample of data to a parameter of the population from which the data is sampled) or a predictor (i.e., a function mapping arbitrary inputs to a sample of values of some random variable). Definition of an MSE differs according to whether one is describing an estimator or a predictor.

### Predictor

If \hat{Y} is a vector of n predictions, and Y is the vector of observed values corresponding to the inputs to the function which generated the predictions, then the MSE of the predictor can be estimated by

\operatorname{MSE}=\frac{1}{n}\sum_{i=1}^n(\hat{Y_i} - Y_i)^2

I.e., the MSE is the mean (\frac{1}{n}\sum_{i=1}^n) of the square of the errors ((\hat{Y_i} - Y_i)^2). This is an easily computable quantity for a particular sample (and hence is sample-dependent).

### Estimator

The MSE of an estimator \hat{\theta} with respect to an unknown parameter \theta is defined as

\operatorname{MSE}(\hat{\theta})=\operatorname{E}\big[(\hat{\theta}-\theta)^2\big].

This definition depends on the unknown parameter, and the MSE in this sense is a property of an estimator. Since an MSE is an expectation, it is not technically a random variable. That being said, 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.

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. 

\operatorname{MSE}(\hat{\theta})=\operatorname{Var}(\hat{\theta})+ \left(\operatorname{Bias}(\hat{\theta},\theta)\right)^2.

#### Proof of variance and bias relationship

\begin{align}\operatorname{MSE}(\hat{\theta})\equiv \mathbb{E}((\hat{\theta}-\theta)^2)&= \mathbb{E}\left[\left(\hat{\theta}-\mathbb{E}(\hat\theta)+\mathbb{E}(\hat\theta)-\theta\right)^2\right] \\ & = \mathbb{E}\left[\left(\hat{\theta}-\mathbb{E}(\hat\theta)\right)^2 +2\left((\hat{\theta}-\mathbb{E}(\hat\theta))(\mathbb{E}(\hat\theta)-\theta)\right)+\left( \mathbb{E}(\hat\theta)-\theta \right)^2\right] \\ & = \mathbb{E}\left[\left(\hat{\theta}-\mathbb{E}(\hat\theta)\right)^2\right]+2\mathbb{E}\Big[(\hat{\theta}-\mathbb{E}(\hat\theta))(\overbrace{\mathbb{E}(\hat\theta)-\theta}^{\begin{smallmatrix} \text{This is} \\ \text{a constant,} \\ \text{so it can be} \\ \text{pulled out.} \end{smallmatrix}}) \,\Big] + \mathbb{E}\Big[\,\overbrace{\left(\mathbb{E}(\hat\theta)-\theta\right)^2}^{\begin{smallmatrix} \text{This is a} \\ \text{constant, so its} \\ \text{expected value} \\ \text{is itself.} \end{smallmatrix}}\,\Big] \\ & = \mathbb{E}\left[\left(\hat{\theta}-\mathbb{E}(\hat\theta)\right)^2\right]+2(\overbrace{\mathbb{E}(\hat\theta)-\theta}^{\begin{smallmatrix} \text{That first} \\ \text{constant, now} \\ \text{pulled out.} \end{smallmatrix}})\underbrace{\mathbb{E}(\hat{\theta}-\mathbb{E}(\hat\theta))}_{=\mathbb{E}(\hat\theta)-\mathbb{E}(\hat\theta)=0}+\left(\mathbb{E}(\hat\theta)-\theta\right)^2 \\ & = \mathbb{E}\left[\left(\hat{\theta}-\mathbb{E}(\hat\theta)\right)^2\right]+\left(\mathbb{E}(\hat\theta)-\theta\right)^2 \\ & = \operatorname{Var}(\hat\theta)+ \operatorname{Bias}(\hat\theta,\theta)^2 \end{align}

## Regression

In regression analysis, 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, (n-p) for p regressors or (n-p-1) if an intercept is used. For more details, see errors and residuals in statistics. Note that, although the MSE is not an unbiased estimator of the error variance, it is consistent, given the consistency of the predictor.

Also in regression analysis, "mean squared error", often referred to as mean squared prediction error or "out-of-sample mean squared error", can 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.

## Examples

### Mean

Suppose we have a random sample of size n from a population, X_1,\dots,X_n. Suppose the sample units were chosen with replacement. That is, the n units are selected one at a time, and previously selected units are still eligible for selection for all n draws. The usual estimator for the mean is the sample average

\overline{X}=\frac{1}{n}\sum_{i=1}^n X_i

which has an expected value equal to the true mean μ (so it is unbiased) and a mean square error of

\operatorname{MSE}(\overline{X})=\operatorname{E}((\overline{X}-\mu)^2)=\left(\frac{\sigma}{\sqrt{n}}\right)^2= \frac{\sigma^2}{n}

where \sigma^2 is the population variance.

For a Gaussian distribution this is the best unbiased estimator (that is, it has the lowest MSE among all unbiased estimators), but not, say, for a uniform distribution.

### Variance

The usual estimator for the variance is the corrected sample variance:

S^2_{n-1} = \frac{1}{n-1}\sum_{i=1}^n\left(X_i-\overline{X}\,\right)^2 =\frac{1}{n-1}\left(\sum_{i=1}^n X_i^2-n\overline{X}^2\right).

This is unbiased (its expected value is \sigma^2), hence also called the unbiased sample variance, and its MSE is

\begin{align}\operatorname{MSE}(S^2_{n-1})&= \frac{1}{n} \left(\mu_4-\frac{n-3}{n-1}\sigma^4\right) \\ &=\frac{1}{n} \left(\gamma_2+\frac{2n}{n-1}\right)\sigma^4,\end{align}

where \mu_4 is the fourth central moment of the distribution or population and \gamma_2=\mu_4/\sigma^4-3 is the excess kurtosis.

However, one can use other estimators for \sigma^2 which are proportional to S^2_{n-1}, and an appropriate choice can always give a lower mean square error. If we define

\begin{align}S^2_a &= \frac{n-1}{a}S^2_{n-1}\\ &= \frac{1}{a}\sum_{i=1}^n\left(X_i-\overline{X}\,\right)^2\end{align}

then the MSE is

\begin{align} \operatorname{MSE}(S^2_a)&=\operatorname{E}\left(\left(\frac{n-1}{a} S^2_{n-1}-\sigma^2\right)^2 \right) \\ &=\frac{n-1}{n a^2}[(n-1)\gamma_2+n^2+n]\sigma^4-\frac{2(n-1)}{a}\sigma^4+\sigma^4 \end{align}

This is minimized when

a=\frac{(n-1)\gamma_2+n^2+n}{n} = n+1+\frac{n-1}{n}\gamma_2.

For a Gaussian distribution, where \gamma_2=0, this means the MSE is minimized when dividing the sum by a=n+1. The minimum excess kurtosis is \gamma_2=-2, which is achieved by a Bernoulli distribution with p = 1/2 (a coin flip), and the MSE is minimized for a=n-1+2/n. So no matter what the kurtosis, we get a "better" estimate (in the sense of having a lower MSE) by scaling down the unbiased estimator a little bit; this is a simple example of a shrinkage estimator: one "shrinks" the estimator towards zero (scales down the unbiased estimator).

Further, while the corrected sample variance is the best unbiased estimator (minimum mean square error among unbiased estimators) 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 S^2_{n-1}.

### 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
θ = μ \hat{\theta} = the unbiased estimator of the population mean, \overline{X}=\frac{1}{n}\sum_{i=1}^n(X_i) \operatorname{MSE}(\overline{X})=\operatorname{E}((\overline{X}-\mu)^2)=\left(\frac{\sigma}{\sqrt{n}}\right)^2
θ = σ2 \hat{\theta} = the unbiased estimator of the population variance, S^2_{n-1} = \frac{1}{n-1}\sum_{i=1}^n\left(X_i-\overline{X}\,\right)^2 \operatorname{MSE}(S^2_{n-1})=\operatorname{E}((S^2_{n-1}-\sigma^2)^2)=\frac{2}{n - 1}\sigma^4
θ = σ2 \hat{\theta} = the biased estimator of the population variance, S^2_{n} = \frac{1}{n}\sum_{i=1}^n\left(X_i-\overline{X}\,\right)^2 \operatorname{MSE}(S^2_{n})=\operatorname{E}((S^2_{n}-\sigma^2)^2)=\frac{2n - 1}{n^2}\sigma^4
θ = σ2 \hat{\theta} = the biased estimator of the population variance, S^2_{n+1} = \frac{1}{n+1}\sum_{i=1}^n\left(X_i-\overline{X}\,\right)^2 \operatorname{MSE}(S^2_{n+1})=\operatorname{E}((S^2_{n+1}-\sigma^2)^2)=\frac{2}{n + 1}\sigma^4

Note that:

1. The MSEs shown for the variance estimators assume X_i \sim \operatorname{N}(\mu,\sigma^2) i.i.d. so that \frac{(n-1)S^2_{n-1}}{\sigma^2}\sim \chi^2_{n-1}. The result for S^2_{n-1} follows easily from the \chi^2_{n-1} variance that is 2n-2.
2. Unbiased estimators may not produce estimates with the smallest total variation (as measured by MSE): the MSE of S^2_{n-1} is larger than that of S^2_{n+1} or S^2_n.
3. Estimators with the smallest total variation may produce biased estimates: S^2_{n+1} typically underestimates σ2 by \frac{2}{n}\sigma^2

## Interpretation

An MSE of zero, meaning that the estimator \hat{\theta} predicts observations of the parameter \theta with perfect accuracy, is the ideal, but is practically never possible.

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 (estimated from a statistical model) with the smallest variance among all unbiased estimators is the best prediction in the sense that it minimises the variance and is called the best unbiased estimator or MVUE (Minimum Variance Unbiased Estimator).

Both linear regression techniques such as analysis of variance 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.

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

• In statistical modelling the MSE, representing the difference between the actual observations and the observation values predicted by the model, is used to determine the extent to which the model fits the data and whether the removal or some explanatory variables, simplifying the model, is possible without significantly harming the model's predictive ability.

## Loss function

Squared error loss is one of the most widely used loss functions in statistics, though its widespread use stems more from mathematical convenience than considerations of actual loss in applications. Carl Friedrich Gauss, who introduced the use of mean squared error, was aware of its arbitrariness and was in agreement with objections to it on these grounds. The mathematical benefits of mean squared error are particularly evident in its use at analyzing the performance of linear regression, as it allows one to partition the variation in a dataset into variation explained by the model and variation explained by randomness.

### Criticism

The use of mean squared error without question has been criticized by the decision theorist James Berger. Mean squared error is the negative of the expected value of one specific utility function, the quadratic utility function, which may not be the appropriate utility function to use under a given set of circumstances. There are, however, some scenarios where mean squared error can serve as a good approximation to a loss function occurring naturally in an application.

Like variance, mean squared error has the disadvantage of heavily weighting outliers. This is a result of the squaring of each term, which effectively weights large errors more heavily than small ones. This property, undesirable in many applications, has led researchers to use alternatives such as the mean absolute error, or those based on the median.