Tutorials › Exam PA - Predictive Analytics › Polynomial Terms and Local Slopes

Exam PA · Coefficient Interpretation and Diagnostics · Tutorial 339 of 966

Polynomial Terms and Local Slopes

Learn to calculate and interpret the changing local effect of a predictor when its GLM linear predictor includes a quadratic term.

Intermediate 10 min read

What You'll Learn

  • Write a quadratic GLM predictor and derive its slope with respect to the original predictor.
  • Interpret the quadratic coefficient as curvature on the link scale, not as a constant effect.
  • Translate link-scale slopes to response-scale slopes for identity, log, and logit links.
  • Distinguish a local derivative from the exact change over a finite predictor increment.
  • Identify the turning point of a quadratic predictor and interpret it within the observed range.

Why a Quadratic Term Changes the Effect

A straight-line term gives the same change in the linear predictor for each one-unit increase in a continuous predictor. That assumption can be too restrictive: a risk factor might have a strong association at low values and a weaker association at high values, or its direction might eventually reverse. A quadratic term allows the effect to vary smoothly with the predictor while retaining a relatively simple model.

The key interpretation is that a quadratic coefficient is not, by itself, the effect of a one-unit increase in the original predictor. The slope depends on the predictor value. For a generalized linear model, this value-dependent slope is first calculated on the link scale; a response-scale slope then follows by applying the derivative of the inverse link.

Definition: For a continuous predictor \(x\), a GLM with a quadratic term has linear predictor \(\eta(x)=\beta_0+\beta_1x+\beta_2x^2\), where \(\eta=g(\mu)\), \(\mu=E[Y\mid x]\), and \(g\) is the link function. Its local slope on the link scale is \(d\eta/dx=\beta_1+2\beta_2x\). If \(g^{-1}\) is differentiable, the response-scale local slope is \(d\mu/dx=(d g^{-1}(\eta)/d\eta)(\beta_1+2\beta_2x)\).

Here, “local slope” means the instantaneous rate of change at a specified value of \(x\), not necessarily the exact change over a whole unit. The response-scale slope describes the approximate change in the fitted mean per small change in \(x\), holding the model and other predictors fixed.

Deriving the Local Slope

The derivation uses the ordinary derivative of the predictor’s polynomial. The GLM structure then connects that derivative to the fitted mean through the inverse link.

1
Specify the model.
Write \(\eta(x)=\beta_0+\beta_1x+\beta_2x^2\), with \(\mu=g^{-1}(\eta)\).
2
Differentiate the link-scale predictor.
The derivative of the constant \(\beta_0\) is zero, the derivative of \(\beta_1x\) is \(\beta_1\), and the derivative of \(\beta_2x^2\) is \(2\beta_2x\). Thus \(d\eta/dx=\beta_1+2\beta_2x\).
3
Apply the chain rule.
Since \(\mu=g^{-1}(\eta(x))\), differentiating the composition gives \(d\mu/dx=(d g^{-1}(\eta)/d\eta)(d\eta/dx)\).

This chain-rule result explains why a link-scale slope and a response-scale slope are not generally interchangeable. For an identity link, the inverse-link derivative is 1. For a log link, it is \(\exp(\eta)=\mu\). For a logit link, it is \(\mu(1-\mu)\). The formulas assume a differentiable inverse link and a continuous \(x\); they describe the fitted mean under the specified model, not a causal effect.

$$ \frac{d\eta}{dx}=\beta_1+2\beta_2x, \qquad \frac{d\mu}{dx}=\frac{d g^{-1}(\eta)}{d\eta}\left(\beta_1+2\beta_2x\right). $$

A useful check comes from a finite predictor change \(h\). Direct subtraction gives an exact link-scale change:

$$ \eta(x+h)-\eta(x) =h(\beta_1+2\beta_2x)+\beta_2h^2. $$

The first term is \(h\) times the local slope at \(x\); the second is the additional curvature contribution. Therefore, multiplying the local slope by a large increment is generally not the exact finite change. On the response scale, the exact change is \(g^{-1}(\eta(x+h))-g^{-1}(\eta(x))\), not usually the response-scale derivative times \(h\).

Worked Examples Across GLM Links

Worked Example: A Quadratic Mean with an Identity Link

A hypothetical model for mean service time, measured in minutes, uses a Gaussian response and identity link. Its fitted mean is \(\mu(x)=12+3x-0.5x^2\), where \(x\) is a workload index. Find the fitted mean and local slope at \(x=2\), the exact fitted-mean change from \(x=2\) to \(x=3\), and the turning point. State the method and a common mistake to avoid.

Method. With an identity link, \(\eta=\mu\), so the response-scale and link-scale slopes are the same. Here \(\beta_1=3\) and \(\beta_2=-0.5\), giving \(d\mu/dx=3+2(-0.5)x=3-x\).

At \(x=2\). The fitted mean is \(12+3(2)-0.5(2^2)=12+6-2=16\) minutes. The local slope is \(3-2=1\) minute per workload-index unit.

Exact change from 2 to 3. At \(x=3\), the fitted mean is \(12+3(3)-0.5(3^2)=12+9-4.5=16.5\) minutes. The exact change is \(16.5-16=0.5\) minute. The finite-change formula checks this: with \(h=1\), the change is \(1(1)+(-0.5)(1^2)=0.5\).

Turning point. Set the local slope to zero: \(3-x=0\), so \(x=3\). Because the quadratic coefficient is negative, the curve reaches a maximum there. Its fitted mean is \(16.5\) minutes, as calculated above.

Check and trap. The fitted mean rises between \(x=2\) and \(x=3\), but by only 0.5 minute, not the 1 minute suggested by multiplying the slope at \(x=2\) by one. That multiplication treats the initial local slope as constant over the interval and misses the curvature term.

Worked Example: A Quadratic Effect Under the Log Link

A hypothetical Poisson GLM models event counts with a log link and includes the log of exposure \(t\) as an offset: \(\log(E[Y\mid x,t])=\log(t)-2+0.8x-0.1x^2\). At \(x=2\), find the fitted event rate per unit of exposure, its response-scale local slope, and the exact rate ratio for increasing \(x\) from 2 to 2.5. Name the method and the trap avoided.

Separate the rate from exposure. The offset means the expected count is exposure multiplied by the modeled rate. Thus the log rate is \(-2+0.8x-0.1x^2\); the rate is \(\lambda(x)=\exp(-2+0.8x-0.1x^2)\). The offset does not change the derivative with respect to \(x\).

Rate at \(x=2\). The log rate is \(-2+0.8(2)-0.1(2^2)=-2+1.6-0.4=-0.8\). Therefore, \(\lambda(2)=\exp(-0.8)\approx0.4493\) events per exposure unit. For exposure \(t=10\), the corresponding expected count is \(10(0.4493)\approx4.493\).

Local slope. The log-rate slope is \(0.8+2(-0.1)x=0.8-0.2x\), which equals \(0.4\) at \(x=2\). Under the log link, the derivative of the rate is the rate multiplied by the log-rate slope. Hence \(d\lambda/dx=0.4493(0.4)\approx0.1797\) events per exposure unit per predictor unit.

Exact finite rate ratio. For \(h=0.5\), the change in log rate is \(0.5(0.4)+(-0.1)(0.5^2)=0.2-0.025=0.175\). The rate ratio is therefore \(\exp(0.175)\approx1.1912\). The rate at \(x=2.5\) is approximately \(0.4493(1.1912)=0.5352\), consistent with direct calculation: its log rate is \(-2+0.8(2.5)-0.1(2.5^2)=-0.625\), and \(\exp(-0.625)\approx0.5353\). The small difference in the displayed products is due to rounding; using unrounded values gives the same rate.

Check and trap. The log-rate slope \(0.4\) is not the rate’s change in events per unit of \(x\); the response-scale derivative is about \(0.1797\). Also, a finite increase of \(0.5\) does not have rate ratio \(\exp(0.5(0.4))\): that calculation omits the quadratic contribution \(-0.025\).

Worked Example: Logistic Probability and a Local Slope

A hypothetical logistic GLM for a claim indicator has \(\eta(x)=-1+0.6x-0.1x^2\), with fitted probability \(p(x)=1/(1+\exp(-\eta(x)))\). At \(x=2\), calculate the fitted probability and the response-scale local slope to four decimals. Then identify where the link-scale slope is zero and explain what that means. Use differentiation followed by the inverse-logit derivative; avoid treating \(0.6\) as the slope at every \(x\).

Linear predictor and probability. At \(x=2\), \(\eta=-1+0.6(2)-0.1(2^2)=-1+1.2-0.4=-0.2\). Thus \(p=1/(1+\exp(0.2))\approx0.4502\).

Link-scale slope. Differentiating gives \(d\eta/dx=0.6+2(-0.1)x=0.6-0.2x\). At \(x=2\), this is \(0.6-0.4=0.2\).

Response-scale slope. The derivative of the inverse-logit function is \(p(1-p)\). Therefore, \(dp/dx=0.4502(1-0.4502)(0.2)\approx0.0495\) probability units per predictor unit, to four decimals. Using unrounded \(p\), the product is approximately \(0.0495\).

Turning point and interpretation. The link-scale slope is zero when \(0.6-0.2x=0\), or \(x=3\). Since the quadratic coefficient is negative, \(\eta(x)\) has a maximum at \(x=3\). The inverse-logit is increasing, so the fitted probability also reaches its maximum there. This statement concerns the fitted curve; it does not imply a causal relationship.

Check and trap. The probability at \(x=2\) is based on \(\eta=-0.2\), not \(-0.4\). The slope is not the coefficient \(0.6\), nor is it just the link-scale slope \(0.2\): the response-scale derivative also includes the factor \(p(1-p)\). The resulting values, \(p\approx0.4502\) and \(dp/dx\approx0.0495\), are consistent with the stated model.

Interpreting Curvature and Turning Points

The coefficient \(\beta_2\) determines the curvature of the linear predictor: its second derivative is \(d^2\eta/dx^2=2\beta_2\). A positive \(\beta_2\) curves upward on the link scale, while a negative \(\beta_2\) curves downward. If \(\beta_2\ne0\), setting the first derivative to zero gives the link-scale turning point:

$$ x^*=-\frac{\beta_1}{2\beta_2}. $$

When \(\beta_2>0\), this is a minimum of \(\eta\); when \(\beta_2<0\), it is a maximum. For identity, log, and logit links, the inverse link is increasing, so an interior minimum or maximum of \(\eta\) is also a minimum or maximum of the fitted mean. This conclusion depends on the inverse link being increasing. More generally, the response-scale derivative must be interpreted using the particular inverse link.

A turning point is useful only in context. If \(x^*\) lies outside the observed range, it should not be described as an observed reversal in the relationship. Even when it is inside the range, the model’s shape is a fitted association, and the available data may not support precise interpretation near the extremes. The model’s assumed mean and link must also be appropriate: the derivative formulas describe that specified GLM, not every possible relationship.

The coefficient \(\beta_1\) is the link-scale slope at \(x=0\), because \(d\eta/dx=\beta_1+2\beta_2x\). If zero is far from the predictor values of interest, this may not be a useful summary of the effect. Centering \(x\) can change the numerical meanings of the intercept and linear coefficient while leaving fitted values unchanged when the corresponding polynomial terms are represented consistently. Regardless of coding, calculate the slope at the actual predictor value being interpreted.

Common Interpretation Traps

  • Reading \(\beta_1\) as a constant effect. It is the link-scale slope at \(x=0\); elsewhere the slope includes \(2\beta_2x\).
  • Forgetting the factor of 2. The derivative of \(\beta_2x^2\) is \(2\beta_2x\), not \(\beta_2x\).
  • Calling a link-scale slope a response-scale change. Apply the inverse-link derivative before describing the local change in the fitted mean.
  • Using a local slope as an exact finite change. For a nonzero increment, the exact link-scale change includes \(\beta_2h^2\); the exact response-scale change requires applying the inverse link at both endpoints.
  • Overinterpreting a turning point. Check that it falls in the observed predictor range, and describe it as a feature of the fitted curve rather than proof of a causal threshold.
Key takeaway: In a GLM with \(\eta(x)=\beta_0+\beta_1x+\beta_2x^2\), the link-scale local slope at \(x\) is \(\beta_1+2\beta_2x\). To describe the change in the fitted mean, multiply by the derivative of the inverse link. For finite changes, calculate the two fitted values rather than treating a local slope as constant.

Check Your Understanding

For each problem, calculate the requested slope or fitted quantity using the specified model and link.

  1. A Gaussian GLM with identity link has \(\mu(x)=5+2x-0.25x^2\). Find the fitted mean and local slope at \(x=3\). (Answer: fitted mean \(8.75\); local slope \(0.5\) response units per predictor unit.)
  2. A Poisson GLM with log link models a rate as \(\lambda(x)=\exp(-1+0.5x-0.05x^2)\). At \(x=2\), find the rate and its response-scale local slope, rounding to four decimals. (Answer: rate \(0.8187\); local slope \(0.2456\) rate units per predictor unit.)
  3. A logistic GLM has \(\eta(x)=-2+1.2x-0.2x^2\). At \(x=2\), calculate the fitted probability and response-scale local slope, rounding both to four decimals. (Answer: probability \(0.4013\); local slope \(0.0961\) probability units per predictor unit.)
  4. On the observed range \(0\le x\le6\), a logistic GLM has \(\eta(x)=-1-0.3x+0.05x^2\). Find the predictor value where the fitted probability is minimized and calculate that minimum probability to four decimals. (Answer: minimum at \(x=3\); \(\eta(3)=-1.45\), so the minimum probability is \(0.1900\).)
Clinical Biostats