Tutorials › Regression Analysis (Undergraduate) › Zero and Negative Outcomes When Logs Are Inappropriate

Transforming Predictors and Outcomes · Tutorial 414 of 991

Zero and Negative Outcomes When Logs Are Inappropriate

Choose an outcome scale that respects the response values and the regression question, rather than forcing zeros or negatives into a logarithm.

Intermediate 11 min read

What You'll Learn

  • Identify when a logarithm is undefined or changes the meaning of a zero or signed outcome.
  • Use a square-root transformation for suitable nonnegative outcomes, including zeros.
  • Apply the Yeo-Johnson transformation to outcomes that may be positive, zero, or negative.
  • Recognize when an untransformed outcome is a reasonable choice.
  • Explain how adding a constant before logging changes the interpretation.
  • Check whether a proposed transformed-response regression is appropriate for the data and question.

Choosing a Scale for Zero and Negative Outcomes

A logarithm is useful for some outcomes, but it is not automatically the right response scale. It is undefined at zero and for negative values. Adding a constant can make the calculation possible, but it also changes what the model describes: its interpretation depends on the chosen constant as well as on the outcome values. When outcomes include zeros or negatives, a square-root transformation, a transformation designed for signed values, or no transformation may be more suitable.

The choice is not just a mathematical workaround. It depends on what the outcome measures, what differences are meaningful, and whether the proposed regression model gives a reasonable description of the data. Transforming an outcome can change the shape of the fitted relationship and the units in which its coefficients are expressed. It does not, by itself, correct a poor model or make an association causal.

Definition: An outcome transformation replaces an observed response \(Y\) with a function \(g(Y)\) and models the transformed response. For example, a square-root outcome model uses \(g(Y)=\sqrt{Y}\), while a Yeo-Johnson outcome model applies a parameterized function that is defined for positive, zero, and negative values. An untransformed-outcome model models \(Y\) itself.

Start With the Outcome and the Regression Assumptions

Before choosing a transformation, identify the outcome’s possible values and substantive meaning. A zero may mean a genuine absence, such as no events during a period, or it may be a measurement code. A negative value may represent a meaningful net loss, change, or difference. These distinctions matter: a transformation should preserve the relevant ordering and allow the values under study, but it cannot decide what the outcome means.

The usual transformed-response regression model can be written as \(g(Y_i)=\beta_0+\beta_1x_i+\varepsilon_i\), where \(x_i\) is a predictor and \(\varepsilon_i\) is the error for observation \(i\). For standard linear-model inference, the errors are assumed to have mean zero at each predictor value, to be independent across observations, and to have approximately constant variance; normal errors are additionally used for exact small-sample \(t\)- and \(F\)-inference. The relationship between the transformed response and predictor is assumed to be adequately represented by the stated mean function. These assumptions concern the model errors, not a requirement that the raw outcomes themselves look normal.

A transformation is worth considering when it gives a more plausible transformed-scale mean relationship or error pattern while remaining compatible with the outcome’s meaning. It is not mandatory just because values are skewed, and it cannot repair dependence caused by the study design, an omitted predictor, or an unsuitable mean function. The residual behavior and the data-collection structure still need attention.

Square Roots for Nonnegative Outcomes

The square-root transformation \(g(y)=\sqrt{y}\) is defined for \(y\geq 0\), including zero. It preserves order, maps zero to zero, and compresses large values relative to small ones. It is therefore a possible choice for nonnegative outcomes such as counts when a square-root scale makes the relationship or spread more suitable for regression. It is not defined for negative outcomes, and it does not have a universal claim to be the best scale for counts.

Worked Example: Transforming a Nonnegative Count

Suppose a hypothetical service records the number of equipment failures at each of six sites during a fixed period. The observed counts are \(0, 1, 4, 9, 16,\) and \(25\). A predictor \(x\), measured in operating hours, is recorded for each site. The analyst considers a square-root outcome model.

Check the outcome’s domain. All six counts are nonnegative, so the square root is defined, including for the site with zero failures. Transforming the values gives \(\sqrt{0}=0\), \(\sqrt{1}=1\), \(\sqrt{4}=2\), \(\sqrt{9}=3\), \(\sqrt{16}=4\), and \(\sqrt{25}=5\). The transformed responses are \(0,1,2,3,4,5\), in square-root-count units.

This calculation shows how the scale changes, not that a regression model has already been justified. The analyst would fit the transformed-response model only if its mean relationship with operating hours and its error behavior were reasonable for the data. In particular, the fact that the transformed observations look evenly spaced in this small list does not establish independence, constant error variance, or an appropriate mean function. Those require evidence from the study structure and the fitted model.

If the outcome had included a negative count, the square root would not be defined and this choice would not be available without changing the problem’s meaning. Counts also have a special support: a fitted value on a transformed scale need not automatically correspond to a sensible model for count probabilities. The square-root approach is a possible regression scale, not a substitute for considering what the outcome represents.

Yeo-Johnson for Outcomes That May Be Signed

The Yeo-Johnson transformation is defined for positive, zero, and negative real values. It includes a parameter \(\lambda\) that determines the shape of the transformation. With the convention used here,

$$ g_\lambda(y)= \begin{cases} \frac{(y+1)^\lambda-1}{\lambda}, & y\geq 0,\ \lambda\neq 0,\\ \log(y+1), & y\geq 0,\ \lambda=0,\\ -\frac{(1-y)^{2-\lambda}-1}{2-\lambda}, & y<0,\ \lambda\neq 2,\\ -\log(1-y), & y<0,\ \lambda=2. \end{cases} $$

The separate formulas for negative and nonnegative values, including the special cases, are part of the definition. At zero, the nonnegative formula gives \(g_\lambda(0)=0\). Unlike a log transformation, the function can therefore accommodate an outcome whose observed values cross zero. The parameter is chosen for the data and modeling purpose; using the transformation does not guarantee that the resulting regression assumptions hold.

Worked Example: Applying Yeo-Johnson to Signed Outcomes

A hypothetical monitoring system records the change in a process measure, in units, from the start to the end of a shift. Some shifts show decreases, some no change, and others increases. Consider the Yeo-Johnson transformation with \(\lambda=1.5\) purely to illustrate its arithmetic for three recorded changes: \(-3\), \(0\), and \(8\) units.

For \(y=-3\), use the negative-value branch. Since \(2-\lambda=0.5\), \[ g_{1.5}(-3)=-\frac{(1-(-3))^{0.5}-1}{0.5} =-\frac{\sqrt{4}-1}{0.5} =-\frac{2-1}{0.5}=-2. \]

For \(y=0\), the nonnegative branch gives \[ g_{1.5}(0)=\frac{(0+1)^{1.5}-1}{1.5} =\frac{1-1}{1.5}=0. \] For \(y=8\), the same branch gives \[ g_{1.5}(8)=\frac{(8+1)^{1.5}-1}{1.5} =\frac{27-1}{1.5} =17.33. \] Here \(9^{1.5}=27\), so the transformed values are \(-2\), \(0\), and approximately \(17.33\).

The chosen \(\lambda\) is illustrative, not a recommendation for these hypothetical data. In an actual analysis, the transformation parameter would be selected using an appropriate method and the resulting regression would still need assessment. One should also ask whether changing from units of process change to transformed units preserves a useful interpretation for the scientific question.

When the Untransformed Outcome Is the Better Choice

A response does not need to be transformed merely because it includes zero or negative values. If the outcome is meaningful on its original scale and a linear mean function with suitable error behavior is plausible, modeling \(Y\) directly may be the clearest option. The coefficient then describes change in the original outcome units per predictor unit, subject to the model and the observed range. An untransformed model is not automatically appropriate either: its assumptions and fit must be assessed just as for a transformed model.

Worked Example: Keeping a Signed Outcome Untransformed

Consider hypothetical net changes, measured in points, observed at four predictor values \(x=0,1,2,3\). The recorded outcomes are \(-2,-1,1,2\). Suppose the scientific question concerns the average change in points as \(x\) increases. A direct linear fit can be calculated from these values.

The sample means are \(\bar{x}=1.5\) and \(\bar{y}=0\). The least-squares slope is \[ b_1=\frac{\sum (x_i-\bar{x})(y_i-\bar{y})}{\sum (x_i-\bar{x})^2} =\frac{3+0.5+0.5+3}{2.25+0.25+0.25+2.25} =\frac{7}{5}=1.4 \] points per predictor unit. The intercept is \[ b_0=\bar{y}-b_1\bar{x}=0-(1.4)(1.5)=-2.1 \] points, giving \(\hat{y}=-2.1+1.4x\).

The fitted values at \(x=0,1,2,3\) are \(-2.1,-0.7,0.7,2.1\) points. The residuals, observed minus fitted, are \(0.1,-0.3,0.3,-0.1\) points. These residuals are small and show no obvious curvature in this four-point illustration, so the untransformed line is a plausible simple description of these values. Four observations cannot establish the error assumptions or justify broad inference; independence depends on how the observations were collected, and the residual pattern is only limited evidence about the mean form and spread. Retaining the original scale is a reasonable choice here because negative and positive changes are meaningful and the question is about changes in points.

Why Adding a Constant Before Logging Is Not a General Fix

If \(Y\) can be zero or negative, an analyst may choose a constant \(c\) so that \(Y+c>0\) and then model \(\log(Y+c)\). This makes the logarithm computable for the observed values, but the resulting model is about \(Y+c\), not simply about \(Y\). The choice of \(c\) is consequential: it must place every included outcome in the logarithm’s domain, and its numerical value depends on the units used to measure the outcome.

For example, suppose a one-unit increase in \(x\) is associated with a fitted increase of \(\beta_1\) in \(\log(Y+c)\). Exponentiating the change gives a multiplicative factor \(e^{\beta_1}\) for \(Y+c\). For a change of \(\Delta x\), the model implies

$$ Y_{\mathrm{new}}+c=e^{\beta_1\Delta x}(Y_{\mathrm{old}}+c), \qquad Y_{\mathrm{new}}=e^{\beta_1\Delta x}(Y_{\mathrm{old}}+c)-c. $$

Thus the implied change in \(Y\) depends on its starting value and on \(c\). It is not generally a constant percentage change in \(Y\), especially when \(Y\) is zero or negative.

Worked Example: How an Offset Changes the Meaning

Suppose, hypothetically, that a fitted model uses \(\log(Y+c)\), and a one-unit increase in \(x\) has coefficient \(\beta_1=\log(1.2)\). The model therefore multiplies \(Y+c\) by \(1.2\) for that predictor increase. First take \(c=3\) outcome units.

If the starting outcome is \(Y_{\mathrm{old}}=0\), then \[ Y_{\mathrm{new}}=1.2(0+3)-3=3.6-3=0.6. \] The predicted increase is \(0.6\) units. If instead \(Y_{\mathrm{old}}=6\), then \[ Y_{\mathrm{new}}=1.2(6+3)-3=10.8-3=7.8, \] an increase of \(1.8\) units. The same coefficient does not imply the same absolute increase in the original outcome.

Now retain \(Y_{\mathrm{old}}=0\) and the same coefficient but choose \(c=10\). The implied outcome is \[ Y_{\mathrm{new}}=1.2(0+10)-10=12-10=2 \] units, rather than \(0.6\). This calculation shows why an offset is not a neutral device: it changes the response being modeled and the original-scale implication. A shift may be defensible in a particular application, but its rationale and interpretation must be explicit; it does not generally solve the problem of choosing a meaningful outcome scale.

A Practical Choice and a Common Pitfall

A useful decision sequence is to check the outcome’s domain and meaning first, then select a candidate scale only if it serves the modeling question. A square root is available for nonnegative outcomes, including zeros. Yeo-Johnson is available for outcomes that can be negative, zero, or positive. An untransformed outcome remains an option whenever the original scale supports a plausible regression model. In every case, assess the model assumptions and explain coefficient units on the scale actually modeled.

  • Common mistake: “The outcome includes zeros, so I will add one and take logs; the slope is then a percentage change in the outcome.”
  • Correction: The slope describes a multiplicative change in \(Y+1\), not necessarily in \(Y\). Its original-scale implication depends on the starting outcome, and using a different offset changes that implication. Consider the outcome’s meaning and whether a square root, Yeo-Johnson, or untransformed model is more appropriate.

A transformation should be justified by the outcome’s support, the question, and the behavior of the fitted model—not by a desire to make every outcome positive. In particular, do not interpret a transformed-scale coefficient as though it were automatically an additive or percentage effect in the original units.

Check Your Understanding

Answer each question by identifying the relevant outcome scale and explaining your reasoning.

  1. A response is a nonnegative event count and includes several zeros. Is the square-root transformation defined for every observation? What should still be checked before using a regression model?
  2. A measured change can be negative, zero, or positive. Which of the square-root and Yeo-Johnson transformations is defined across that full range?
  3. Why does modeling \(\log(Y+c)\) generally not make the coefficient a percentage change in \(Y\)?
  4. Give one reason an untransformed model could be preferable to a transformed model for a signed outcome.
  5. For a log-offset model with \(c=4\) and a one-unit predictor increase that multiplies \(Y+c\) by \(1.1\), calculate the implied new outcome when the starting outcome is \(Y=6\).