Point prediction using transformed variables

If a transformation of Y follows a normal linear model with an explanatory variable that is a transformation of X, a least squares line that is fitted to the transformed data is used for predictions.

To obtain a prediction of Y at any value x,

  1. Transform x
  2. Put this transformed x-value into the least squares equation to obtain a prediction of the transformed Y.
  3. Apply the inverse transformation to the one that was used on Y to obtain the prediction of Y itself

For example, if the square root of Y is linearly related to X, we use the least squares line to obtain a prediction of sqrt(Y), then square this to get a prediction of Y itself.

House prices in Palmerston North

The scatterplot below shows the sale prices ($thousand) and floor areas (square metres) from a sample of 143 houses that were sold in two suburbs of Palmerston North, New Zealand in 1999. All houses had been built in the previous 30 years.

The prices of large houses are more variable than these of small houses, suggesting that a transformed sale price might satisfy a normal linear model better.

Although the error variance now seems reasonably constant, there is an indication of nonlinearity at high house areas. A log transformation of the house areas fixes this problem too.

A normal linear model for the transformed variables implies that

log (price)   ≈  a +  b × log (area)

and this can be re-expressed in the form

price   ≈   ea  ×  areab

so the model implies that prices are proportional to area raised to a power. (If b = 1, there is a constant price per m2, on average — a hypothesis test can assess this.)

The transformed variables are shown on the diagram below with the least squares line, both on the transformed scatterplot and on a scatterplot of the original data.

Click on the scatterplot at any house area (or log-area) to see how log(price) is predicted using the least squares slope and intercept. From this, the price is predicted by raising 10 to this power — the inverse transformation to log10.

Prediction intervals

Prediction intervals can be obtained in a similar way.

  1. Transform x
  2. Use the ordinary linear model methods to find a prediction interval for the transformed Y.
  3. Apply the inverse transformation to both ends of the prediction interval to get a prediction interval for Y itself.

For example, if the square root of Y is linearly related to X, we find a prediction interval for sqrt(Y), then square both ends of this interval to get a prediction interval for Y itself.

Although the prediction interval for the transformed Y has a similar width over the range of x-values in the data, the resulting prediction interval for Y itself may vary much more in width.

House prices in Palmerston North

The red band on the scatterplot of log(price) against log(area) on the left below shows 95% prediction intervals. Use the slider under the diagram to display the prediction interval for the price of a house of any area.

The scatterplot on the right shows the corresponding data and prediction intervals on a plot of the untransformed variables. Observe that the prediction interval for the price of a large house is much wider than that for a small house.