# Mean Bias Correction¶

## Mean and median may differ on original scale¶

When a predicted mean response on a transformed scale is converted back to its original scale, the predicted mean becomes the predicted median. A correction is applied to the back-transformed prediction so it correctly predicts the mean, rather than the median. This correction may be toggled on/off by clicking Edit > Preferences > Math Analysis > Correct biased predictions of mean.

Use the predicted mean for making inferences and prediction about your process.

## Mathematical Detail¶

Consider the case where we transform the response data, $$y_i$$, using some transformation $$f$$ to ensure the normality of the residuals,

$z_i = f(y_i)$

We fit this new, transformed data to a model, resulting in transformed scale, least squares estimates for the variance, $$\sigma_z^2$$, and response mean function, $$z(A,B,...)$$, as a function of the factors in the model, $$A, B,...$$,

$\begin{split}\begin{eqnarray} \hat{\sigma}_{z}^2 &=&~\text{transformed scale mean square error}~=~\text{constant},\\ \hat{z} &=& \hat{z}(A,B,...) = \hat{\beta}_0+\hat{\beta}_A A + \hat{\beta}_B B + \hat{\beta}_{AB} A B+...\\ \end{eqnarray}\end{split}$

Because the normal distribution is a symmetric distribution, the response mean function is also the median function – the mean and median are the same on the transformed scale.

Note

It is important to verify that the model assumptions – normality of residuals, constant variance, and independence – have been achieved after transformation, and perhaps even more so when relying on original scale mean bias correction.

To obtain the median on the original scale, apply the inverse transformation $$f^{-1}$$ to the mean function on the transformed scale,

$\hat{m}_y(A,B,...) =~\text{original scale median}~= f^{-1}(\hat{z})$

On the original scale, the mean and median are not the same. To obtain an estimate of the mean on the original scale, we can use an approximation involving the second derivative (curvature) of the inverse transformation and the mean squared error from the regression. To first order in the mean square error, $$\hat{\sigma}_{z}^2$$,

$\hat{y}(A,B,...) =~\text{original scale mean}~\approx f^{-1}(\hat{z}) + \frac{1}{2} \left(\left. \frac{d^2 f^{-1}}{d z^2}\right\rvert_{\hat{z}}\right) \hat{\sigma}^2_z$

### Example¶

Consider the transformation,

$z = f(y) = \frac{1}{y}, y > 0$

In that case, the inverse transformation and its derivatives are,

$\begin{split}\begin{eqnarray} f^{-1}(z) &=& +\frac{1}{z}, z > 0, \\ \frac{d f^{-1}}{d z} &=& -\frac{1}{z^2},\\ \frac{d^2f^{-1}}{d z^2} &=& +\frac{2}{z^3} \end{eqnarray}\end{split}$

Therefore, on the original scale,

$\begin{split}\begin{eqnarray} \hat{m}_y &=& f^{1}(z) = \frac{1}{\hat{z}},\\ \hat{y} &\approx& \frac{1}{\hat{z}}+ \frac{1}{2} \left(\frac{2}{\hat{z}^3}\right)\hat{\sigma}^2_z = \frac{1}{\hat{z}}\left(1+ \frac{1}{\hat{z}^2} \hat{\sigma}^2_z\right) \end{eqnarray}\end{split}$

Note

Remember that $$\hat{z} = \hat{z}(A,B,...)$$, $$\hat{m}_y =\hat{m}_y(A,B,...)$$, and $$\hat{y} = \hat{y}(A,B,...)$$ are functions of the factor settings and change with the different values for A, B,…

### Special Case: Log Transforms for Log Normal Data¶

Logarithmic tranformations for log normal data are a special case where the mean function on the original scale can be computed exactly (Finney 1941). For these transformations,

$\hat{y} = \exp{\left[a \left(\hat{z}+ a \frac{1}{2} \hat{\sigma}^2_z \right)\right]}$

Here, $$a$$ controls the base of the logarithm. For the natural log transformation, $$a = \log_e(e) = \ln{e} = 1$$. For the log base-10 transformation, $$a = \ln{10}$$. This gives two sets of equations, depending on the type of logarithm transformation used,

For natural logarithm transformation the median and mean are,

$\begin{split}\begin{eqnarray} \hat{m}_y &=& e^\hat{z},\\ \hat{y} &=& e^\hat{z} e^{\frac{1}{2} \hat{\sigma}^2_z} = \hat{m}_y e^{\frac{1}{2} \hat{\sigma}^2_z}\\ \end{eqnarray}\end{split}$

For log base 10 logarithm transformations,

$\begin{split}\begin{eqnarray} \hat{m}_y &=& 10^\hat{z},\\ \hat{y} &=& 10^\hat{z} 10^{\frac{1}{2} \ln{(10)} \hat{\sigma}^2_z} = \hat{m}_y 10^{\frac{1}{2} \ln{(10)} \hat{\sigma}^2_z} \end{eqnarray}\end{split}$

### Example¶

Suppose that the transformation is the base-10 logarithm, $$z = f(y) = log_{10}(y)$$, as in the image displayed at the top of this help entry. We wish to calculate the mean on the original scale at the point (B=1,C=1,D=1) in the design (the factor A was not in the model for this example).The least square estimates for the mean square error and mean function on the transformed scale are,

$\begin{split}\begin{eqnarray} \hat{\sigma}_z^2 &=& (0.45)^2 = 0.002025,\\ \hat{z}(B,C,D) &=& 0.683549 + 0.126689 B+0.239201 C+ 0.072841 D \\ \end{eqnarray}\end{split}$

So the mean (and median) on the transformed scale at the desired point is,

\begin{split}\begin{align} \hat{z}(B=1,C=1,D=1)~=~& 0.683549~+\\ & 0.126689(1)~+\\ & 0.239201(1)~+\\ & 0.072841(1) = 1.122279 \end{align}\end{split}

The original transformation is the base-10 logarithm so we use,

$\begin{split}\begin{eqnarray} \hat{m}_y(B=1,C=1,D=1) &=& 10^\hat{z} = 10^{1.122279} \approx 13.25,\\ \hat{y}(B=1,C=1,D=1) &=& \hat{m}_y 10^{\frac{1}{2} \ln(10)\hat{\sigma}^2_z} = (13.25)[10^{0.5 (2.302585) (0.002025)}] \approx 13.32 \end{eqnarray}\end{split}$

The mean bias correction is approximately $$13.32-13.25 = 0.07$$ in this case.

References

• D. J. Finney. On the distribution of a variate whose logarithm is normally distributed. Journal of the Royal Statistical Society Supplement, 7:155–161, 1941.

• D. Miller. Reducing transformation bias in curve fitting. The American Statistician, 38(2):124–126, 1984.

• G.W. Oehlert. A note on the delta method. American Statistician, 46:27–29, 1992.