Skip to content

Bias of an Estimator Explained With Sample Variance

The bias of an estimator is how far its average value sits from the thing it is trying to estimate: Bias[θ̂] = E[θ̂] − θ. It describes the whole procedure repeated over many possible datasets, and not one fitted number. In Section 7.3, Hastie, Tibshirani, and Friedman call the squared bias term "the amount by which the average of our estimate differs from the true mean," and for a fit f̂ at a point x₀ they write it as [f(x₀) − E f̂(x₀)]². A single fit can land far from the truth and the method can still be unbiased, because the misses cancel on average.

Try it by hand. Estimate a variance. Let a population have two values, 0 and 2, each equally likely. Its mean is 1 and its variance is ((0 − 1)² + (2 − 1)²)/2 = 1. Draw 2 values with replacement. There are four equally likely samples: (0, 0), (0, 2), (2, 0), and (2, 2). Estimate the variance by dividing the sum of squared deviations from the sample mean by n = 2. The four samples give 0, 1, 1, and 0, so the average estimate is 2/4 = 1/2, and the bias is 1/2 − 1 = −1/2. This estimator guesses low on average. Now divide by n − 1 = 1 instead. The four samples give 0, 2, 2, and 0, an average of 1, and the bias is 0. Look at single samples and the picture is odd: the divisor-n estimator equals the true variance, 1, on two of the four samples, while the unbiased divisor-(n − 1) estimator is never exactly 1 on any sample, since it gives 0 or 2. Bias is about the average over all the samples, and one sample's hit or miss says little about it. With samples of three the same enumeration gives 2/3 for the divisor n, which is (n − 1)/n times the true variance, and exactly 1 for the divisor n − 1. I did these enumerations in exact fractions. The toy population is invented, and the divisor result is the standard one.

The same section separates two kinds of bias. For a linear family such as ridge regression, the authors split the average squared bias into model bias, the gap between the best-fitting linear approximation and the true function, and estimation bias, the gap between the average estimate and that best linear approximation. They note that for linear models fit by ordinary least squares the estimation bias is zero, while restricted fits such as ridge regression have an estimation bias above zero in exchange for lower variance.

A warning about the word. In statistics, bias is this average displacement. It is not the same as unfairness toward a group, and it is not the intercept term b in a linear model, which some books also call the bias. (This last paragraph is my addition, not from the section I read.)

The trap: calling one bad fit "bias". A single estimate that misses is error, and bias only appears when you average over repeats.

Prof Rod's rule: ask what the estimator would do on average over many datasets, and write down the exact thing you are comparing it to.

Hastie, Tibshirani, and Friedman, The Elements of Statistical Learning, 2nd ed., Section 7.3, Equations 7.9 to 7.14 (pp. 223–224)