Why a Logarithm Needs a Reference Scale
A length of 4 metres is not the same numerical measurement as 400 centimetres, even though both describe the same physical quantity. Taking the logarithm of the bare number “4” would therefore make the result depend on the unit chosen. The remedy is to take the logarithm of a ratio: compare the measurement with a positive reference quantity expressed in the same units. The ratio is dimensionless, and it does not change when both quantities are converted together.
This distinction matters when a regression model contains a log predictor. A change of units can leave the log predictor unchanged if the reference quantity is converted along with it. Alternatively, changing the reference scale shifts the log predictor by a constant. That shift changes some coefficient values, but it need not change any fitted values or comparisons between predictor values.
A Log-Predictor Regression Model
To study the effect of a log predictor without changing the outcome scale, consider the conditional-mean model
Here \(Y_i\) is the outcome for observation \(i\), \(x_i\) is a positive predictor, \(x_0\) is a fixed positive reference quantity in the same units as \(x_i\), and \(\mathbf{w}_i\) denotes any other predictors in the model. The coefficients describe this particular parameterization; their numerical values can depend on the reference scale.
For the algebra below, assume the same observations and the same values of all predictors are used before and after a unit or reference change, and that every \(x_i\) is positive. The model includes an intercept. If the coefficients are estimated by ordinary least squares, assume the design matrix has full column rank so the coefficients are uniquely determined. The equality of fitted values shown below is an algebraic property of the model; it does not require normally distributed errors. Usual assumptions for inferential procedures concern uncertainty estimates, not whether the reparameterized model can reproduce the same fitted values.
Worked Example: Converting Both the Measurement and Its Reference
Suppose a hypothetical model predicts an outcome \(Y\), measured in points, using a concentration \(x\) in milligrams:
For a concentration of \(20\text{ mg}\), the ratio to the reference is \(20\text{ mg}/10\text{ mg}=2\). Thus
Now express the same concentration and reference in grams: \(20\text{ mg}=0.020\text{ g}\) and \(10\text{ mg}=0.010\text{ g}\). The ratio is still \(0.020\text{ g}/0.010\text{ g}=2\), so the prediction remains \(12+3\ln(2)\), or approximately \(14.0794\) points. No coefficient needs to change because the physical reference quantity was converted along with the measurement.
This example also illustrates why the units cancel inside the ratio. Writing \(\ln(20\text{ mg})\) alone would not be a unit-invariant mathematical expression; writing \(\ln(20\text{ mg}/10\text{ mg})\) is.
Changing the Reference Scale Shifts the Log Predictor
Converting a measurement and its reference together is different from changing the reference scale used to express the log predictor. Suppose a new reference \(x_0^*\) is \(k\) times the old reference, so \(x_0^*=kx_0\) for a positive constant \(k\). The new log predictor is
Consequently, \(L=L^*+\ln(k)\). Substituting this into the model shows how the coefficients must change to preserve the same fitted value:
The slope on the log predictor stays the same in this simple model, while the intercept changes by \(\beta_1\ln(k)\). This is not a change in the model’s predictions. It is a change in the coordinates used to describe the same fitted relationship.
Worked Example: Rewriting a Log Predictor From Milligrams to Grams
Suppose a hypothetical outcome \(Y\), in points, is modeled by
The same physical quantity can be described in grams, with a reference of \(1\text{ g}=1000\text{ mg}\). Let \(x_{\text{mg}}\) be the numerical value in milligrams and \(x_{\text{g}}\) the numerical value in grams. Then \(x_{\text{mg}}=1000x_{\text{g}}\), and
Therefore, the equivalent model using grams and a \(1\text{ g}\) reference is
For \(x=2500\text{ mg}=2.5\text{ g}\), the original expression gives
The rewritten expression gives the same result:
The displayed intercept is \(18.8155\) when rounded to four decimal places. The unrounded value was retained in the prediction calculation to avoid changing the final rounding.
Why Fitted Values and Contrasts Are Preserved
The calculation above is a special case of a general reparameterization principle. In a model with an intercept, replacing \(L\) by \(L^*=L-c\) replaces one predictor column by that column minus a constant multiple of the intercept column. The new column is therefore a combination of columns already in the model. Conversely, \(L=L^*+c\), so the old column can be recovered from the new one and the intercept. The two sets of columns span the same space.
Ordinary least squares chooses fitted values from the space spanned by the predictor columns to minimize the sum of squared residuals. Since the space is unchanged by this one-to-one reparameterization, the minimum and the fitted values are unchanged. Coefficient labels and values may change, but the model’s fitted response for every observation does not.
A useful consequence is that contrasts between two predictor values depend on their ratio, not on the units used to record them. Holding other predictors fixed in the simple model,
The reference \(x_0\) cancels. If both \(x_1\) and \(x_2\) are converted to another compatible unit, their ratio remains unchanged too. This is why the fitted difference for a comparison such as “twice as large” does not depend on whether the predictor was recorded in grams or milligrams.
Worked Example: A Group-by-Log-Predictor Model
Consider a hypothetical model for an outcome in points, where \(q\) is a group indicator coded 0 or 1 and \(L_{\text{mg}}=\ln(x/(1\text{ mg}))\):
Because the model contains an interaction, changing the reference scale shifts the intercept and the coefficient of \(q\). Since \(1\text{ g}=1000\text{ mg}\), define \(L_{\text{g}}=\ln(x/(1\text{ g}))\). Then \(L_{\text{mg}}=L_{\text{g}}+\ln(1000)\). Substitution gives
For \(x=2000\text{ mg}=2\text{ g}\) and \(q=1\), the original model predicts
In grams, \(L_{\text{g}}=\ln(2)=0.693147181\ldots\), and the rewritten model gives
The interaction coefficient remains \(0.5\); the constant shift in the log predictor is absorbed into the coefficients of the terms that do not contain that log predictor. The fitted value for this observation is preserved.
Common Mistakes and Practical Checks
- Taking the logarithm of a dimensional number. Writing \(\ln(20\text{ mg})\) treats the result as if it were independent of units. Instead, specify a positive reference and use a ratio, such as \(\ln(20\text{ mg}/10\text{ mg})\).
- Changing units but not converting the reference. If the predictor changes from milligrams to grams, convert the reference quantity as well when the goal is to keep the same log predictor. Otherwise, you have changed the reference scale and must adjust the model coefficients.
- Assuming every coefficient is unchanged. In a model without interactions, changing the reference shifts the intercept but leaves the log-predictor slope unchanged. With interactions, lower-order coefficients associated with interacting predictors may shift too.
- Interpreting a shifted intercept as changed predictions. A coefficient can change because the model is expressed relative to a new reference. Check the complete fitted equation or a relevant contrast, rather than comparing one coefficient in isolation.
- Rounding intermediate logarithms too early. Keep additional digits during calculations, then round the final prediction or coefficient. For instance, use \(\ln(1000)=6.907755278\ldots\) when calculating \(10+2\ln(1000)\), which rounds to \(23.8155\), not a value obtained by first rounding the logarithm.
A practical check is to calculate a prediction at one or more positive predictor values using both parameterizations. If the unit conversion and coefficient shifts have been handled correctly, the predictions agree apart from any small difference caused by displayed rounding. For comparisons, write the contrast explicitly; in a simple log-predictor model it uses \(\ln(x_2/x_1)\), which makes its unit invariance visible.
Check Your Understanding
Use the definitions and algebra in this tutorial to answer the following questions.
- Why is \(\ln(x/x_0)\) more appropriate than \(\ln(x)\) when \(x\) is a measured physical quantity?
- A predictor and its reference are both converted from milligrams to grams. What happens to their ratio and to the log predictor?
- If a new reference equals \(k\) times the old reference, write the new log predictor in terms of the old one.
- In a model with an intercept and one log predictor, which coefficient changes when the reference scale changes, and which stays the same?
- For a model containing an interaction between a log predictor and a group indicator, explain why changing the reference scale can shift the group coefficient while leaving fitted values unchanged.