Mean squared error: Difference between revisions

Content deleted Content added
Rebbj (talk | contribs)
Link suggestions feature: 3 links added.
 
(29 intermediate revisions by 18 users not shown)
Line 1:
{{Short description|Measure of the error of an estimator}}
{{distinguish-redirect|Mean squared deviation|Mean squared displacement}}
In [[statistics]], the '''mean squared error''' ('''MSE''')<ref name=":1">{{Cite web|title=Mean Squared Error (MSE)|url=https://www.probabilitycourse.com/chapter9/9_1_5_mean_squared_error_MSE.php|access-date=2020-09-12|website=www.probabilitycourse.com}}</ref> or '''mean squared deviation''' ('''MSD''') of an [[estimator]] (of a procedure for estimating an unobserved quantity) measures the [[expected value|average]] of the squares of the [[Error (statistics)|errors]]—that is, the average squared difference between the estimated values and the actual[[true value]]. MSE is a [[risk function]], corresponding to the [[expected value]] of the [[squared error loss]].<ref>{{cite book |title=Mathematical Statistics: Basic Ideas and Selected Topics |volume=I |edition=Second |last1=Bickel |first1=Peter J. |authorlink1=Peter J. Bickel |last2=Doksum |first2=Kjell A. |year=2015 |page=20 |quotation="If we use quadratic loss, our risk function is called the ''mean squared error'' (MSE) ..."}}</ref> The fact that MSE is almost always strictly positive (and not zero) is because of [[randomness]] or because the estimator [[Omitted-variable bias|does not account for information]] that could produce a more accurate estimate.<ref name="pointEstimation">{{cite book |first1=E. L. |last1=Lehmann |first2=George |last2=Casella |title=Theory of Point Estimation |publisher=Springer |___location=New York |year=1998 |edition=2nd |isbn=978-0-387-98502-2 |mr=1639875}}</ref> In [[machine learning]], specifically [[empirical risk minimization]], MSE may refer to the ''empirical'' risk (the average loss on an observed data set), as an estimate of the true MSE (the true risk: the average loss on the actual population distribution).
 
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.
Line 9:
==Definition and basic properties==
 
The MSE either assesses the quality of a ''[[predictor (statistics)|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 (statistics)|sample]] of data to an estimate of a [[Statistical parameter|parameter]] of the [[Statistical population|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===
Line 15:
If a vector of <math>n</math> predictions is generated from a sample of <math>n</math> data points on all variables, and <math>Y</math> is the vector of observed values of the variable being predicted, with <math>\hat{Y}</math> being the predicted values (e.g. as from a [[least-squares fit]]), then the within-sample MSE of the predictor is computed as
 
:<math>\operatorname{MSE}=\frac{1}{n} \sum_{i=1}^n \left(Y_i-\hat{Y_i}\right)^2.</math>
 
In other words, the MSE is the ''mean'' <math display="inline">\left(\frac{1}{n} \sum_{i=1}^n \right)</math> of the ''squares of the errors'' <math display="inline">\left(Y_i-\hat{Y_i}\right)^2</math>. This is an easily computable quantity for a particular sample (and hence is sample-dependent).
Line 21:
In [[Matrix_multiplication|matrix]] notation,
:<math>\operatorname{MSE}=\frac{1}{n}\sum_{i=1}^n(e_i)^2=\frac{1}{n}\mathbf e^\mathsf T \mathbf e</math>
where <math>e_i</math> is <math> (Y_i-\hat{Y_i}) </math> and <math>\mathbf e</math> is thea <math> n \times 1 </math> 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 [[StatisticalCross-validation learning theory(statistics)|statistical learningcross-validation]], the MSE is often called the [[test MSE]],<ref>{{cite book
|first1=James
|last1=Gareth
Line 39:
}}</ref> and is computed as
 
:<math>\operatorname{MSE} = \frac{1}{q} \sum_{i=n+1}^{n+q} \left(Y_i-\hat{Y_i}\right)^2.</math>
 
===Estimator===
Line 47:
:<math>\operatorname{MSE}(\hat{\theta})=\operatorname{E}_{\theta}\left[(\hat{\theta}-\theta)^2\right].</math>
 
This definition depends on the unknown parameter, buttherefore the MSE is ''a priori'' apriori 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 <math>\hat{\theta}</math> 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_an_estimator|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.<ref name="wackerly">{{cite book |first1=Dennis |last1=Wackerly |first2=William|last2=Mendenhall |first3=Richard L.|last3=Scheaffer |title=Mathematical Statistics with Applications |publisher=Thomson Higher Education|___location=Belmont, CA, USA |year=2008 |edition=7 |isbn=978-0-495-38508-0}}</ref>
Line 55:
====Proof of variance and bias relationship====
 
:<math>\begin{align}
\operatorname{MSE}(\hat{\theta})
&= \operatorname{E}_{\theta} \left [(\hat{\theta}-\theta)^2 \right ] \\
&= \operatorname{E}_{\theta}\left[\left(\hat{\theta}-\operatorname{E}_{\theta} [\hat\theta]+\operatorname{E}_{\theta}[\hat\theta]-\theta\right)^2\right]\\
&= \operatorname{E}_{\theta}\left[\left(\hat{\theta}-\operatorname{E}_{\theta}[\hat\theta]\right)^2 +2\left (\hat{\theta}-\operatorname{E}_{\theta}[\hat\theta] \right ) \left (\operatorname{E}_{\theta}[\hat\theta]-\theta \right )+\left( \operatorname{E}_{\theta}[\hat\theta]-\theta \right)^2\right] \\
&= \operatorname{E}_{\theta}\left[\left(\hat{\theta}-\operatorname{E}_{\theta}[\hat\theta]\right)^2\right]+\operatorname{E}_{\theta}\left[2 \left (\hat{\theta}-\operatorname{E}_{\theta}[\hat\theta] \right ) \left (\operatorname{E}_{\theta}[\hat\theta]-\theta \right ) \right] + \operatorname{E}_{\theta}\left [ \left(\operatorname{E}_{\theta}[\hat\theta]-\theta\right)^2 \right] \\
&= \operatorname{E}_{\theta}\left[\left(\hat{\theta}-\operatorname{E}_{\theta}[\hat\theta]\right)^2\right]+ 2 \left(\operatorname{E}_{\theta}[\hat\theta]-\theta\right) \operatorname{E}_{\theta}\left[\hat{\theta}-\operatorname{E}_{\theta}[\hat\theta] \right] + \left(\operatorname{E}_{\theta}[\hat\theta]-\theta\right)^2 && \operatorname{E}_{\theta}[\hat\theta]-\theta = \text{const.constant} \\
&= \operatorname{E}_{\theta}\left[\left(\hat{\theta}-\operatorname{E}_{\theta}[\hat\theta]\right)^2\right]+ 2 \left(\operatorname{E}_{\theta} [\hat\theta]-\theta\right) \left ( \operatorname{E}_{\theta}[\hat{\theta}]-\operatorname{E}_{\theta}[\hat\theta] \right )+ \left(\operatorname{E}_{\theta}[\hat\theta]-\theta\right)^2 && \operatorname{E}_{\theta}[\hat\theta] = \text{const.constant} \\
&= \operatorname{E}_{\theta}\left[\left(\hat{\theta}-\operatorname{E}_{\theta}[\hat\theta]\right)^2\right]+\left(\operatorname{E}_{\theta} [\hat\theta]-\theta\right)^2\\
&= \operatorname{Var}_{\theta}(\hat\theta)+ \operatorname{Bias}_{\theta}(\hat\theta,\theta)^2
\end{align}</math>
 
An even shorter proof can be achieved using the well-known formula that for a random variable <math display="inline">X</math>, <math display="inline">\mathbb{E}(X^2) = \operatorname{Var}(X) + (\mathbb{E}(X))^2</math>. By substituting <math display="inline">X</math> with, <math display="inline">\hat\theta-\theta</math>, we have
:<math display="block">\begin{aligned}
\operatorname{MSE}(\hat{\theta}) &= \mathbb{E}[(\hat\theta-\theta)^2] \\
&= \operatorname{Var}(\hat{\theta} - \theta) + (\mathbb{E}[\hat\theta - \theta])^2 \\
&= \operatorname{Var}(\hat\theta) + \operatorname{Bias}^2(\hat\theta,\theta)
\end{aligned}</math>
\end{aligned}</math>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 (statistics)|efficiency]] comparison, which includes the information of estimator variance and bias. This is called MSE criterion.
 
==In regression==
Line 81 ⟶ 83:
 
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 set|test space]], generated by a model estimated over a [[training set|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 <math>1/2</math> 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 <math>n</math> from a population, <math>X_1,\dots,X_n</math>. Suppose the sample units were chosen [[Sampling with replacement|with replacement]]. That is, the <math>n</math> units are selected one at a time, and previously selected units are still eligible for selection for all <math>n</math> draws. The usual estimator for the population mean <math>\mu</math> is the sample average
 
:<math>\overline{X}=\frac{1}{n}\sum_{i=1}^n X_i </math>
Line 91 ⟶ 95:
which has an expected value equal to the true mean <math>\mu</math> (so it is unbiased) and a mean squared error of
 
:<math>\operatorname{MSE}\left(\overline{X}\right)=\operatorname{E}\left[\left(\overline{X}-\mu\right)^2\right]=\left(\frac{\sigma}{\sqrt{ n}}\right)^2= \frac{\sigma^2}{n}</math>
 
where <math>\sigma^2</math> is the [[Sample variance#Population variance|population variance]].
 
For a [[Gaussian distribution]], this is the [[best unbiased estimator]] (i.e.of the population mean, that is the one with the lowest MSE (and hence variance) among all unbiased estimators. One can check that the MSE above equals the inverse of the [[Fisher information]] (see [[Cramér–Rao bound]]),. butBut the same sample mean is not the best estimator of the population mean, say, for a [[Uniform distribution (continuous)|uniform distribution]].
 
===Variance===
Line 161 ⟶ 165:
 
==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]].
{{Prose|date=April 2021}}
 
*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.
 
==Loss function==
 
Squared error loss is one of the most widely used [[loss function]]s in statistics{{Citation needed|date=July 2019}}, 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.<ref name="pointEstimation" /> 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===
Line 191 ⟶ 196:
*[[Mean percentage error]]
*[[Mean square quantization error]]
*[[Reduced chi-squared statistic]]
*[[Mean square weighted deviation]]
*[[Mean squared displacement]]
*[[Mean squared prediction error]]
*[[Minimum mean square error]]
*[[Minimum mean squared error|Minimum mean squared error estimator]]
*[[Overfitting]]
*[[Peak signal-to-noise ratio]]