I have a logistic regression model that contains a continuous independent variable X, a dependent variable Y, a independent, categorical variable Z with 3 categories A, B, and C.

The model is essentially:

$Y = \beta_0 +\beta_1X+\beta_2X^2+\beta_3XZ $.

I understand that if the model didn't have the interaction terms, that a 1 unit increase in X is associated with a $\exp(\beta_1)$ change in the odds of y. In fact, I would often say something like "A 10 unit increase in X is associated with a $\exp(10\beta_1)$ increase in the odds of $Y$. But how would I say this or interpret this now that there is a quadratic term in my model? It wouldn't make sense to say a 10 unit change in $X$ is associated with a $\exp(10\beta_1)$ in the odds of $Y$ now, since it depends on the value of $X$, right? Is it even possible to say something like this now, since the odds change depending on the value of X?

  • 4
    $\begingroup$ First, $\beta_3XZ$? - how can you multiply $X$, representing a number, by $Z$, representing a letter? $\endgroup$ Commented Oct 7, 2015 at 11:09
  • 1
    $\begingroup$ Maybe he is using an R-style factor notation, so he means that there are three different coefficients on X, one for each level (value) of Z $\endgroup$
    – Adrian
    Commented Oct 7, 2015 at 11:46
  • $\begingroup$ @Adrian: There'd be too many coefficients then. Under default settings, in lm(y~x+I(x^2)+x:z) where z's a factor, R would use reference level coding for z - two coefficients. Even then it'd be a strange model, in which the category of $Z$ is constrained to make no difference at all when $X=0$. So perhaps the OP means us to understand something like R's x*z, which in a formula automatically includes the lower order terms as well as the interaction. Mathematical notation & computer code are each pretty clear - anything else, or in between, leaves us guessing. $\endgroup$ Commented Oct 7, 2015 at 13:07
  • 1
    $\begingroup$ Yes, @Adrian is correct. I was using some sloppy notation here. The Z is actually represented in the design matrix as 2 variables, for a full-rank parameterization of the model, with level C of the categorical variables being designated by the setting the first two dummy variables equal to 0. $\endgroup$ Commented Oct 7, 2015 at 16:30
  • $\begingroup$ @3209Cigs: And lower order terms in $Z$? $\endgroup$ Commented Oct 8, 2015 at 8:59

1 Answer 1


The only model that would really make sense is

$$Y = \beta_{0} + \beta_{1}X + \beta_{2}X^{2} + \beta_{3}(Z=b) + \beta_{4}(Z=c) + \beta_{5}X(Z=b) + \beta_{6}X(Z=c) + \beta_{7}X^{2}(Z=b) + \beta_{8}X^{2}(Z=c)$$

where $(Z=k)$ denotes 1 if $Z=k$ and 0 otherwise.

In this model the test for interaction is $H_{0}: \beta_{5}\dots \beta_{8} = 0$.

The $X$-effect depends on $Z$ and on the starting point for $X$ since $X$ is nonlinear. To get the effect of $X$ going from $u$ to $v$ when $Z=k$ write down the special case of the above formula when $X=v, Z=k$ then evaluate it when $X=u, Z=k$ and subtract term by term. What is left is the formula for that $X$ effect at $Z=k$ which you estimate by plugging in the the $\beta$ estimates from the model fit. Anti-log and you have the odds ratio. When $k=a$ the result is $\beta_{2}(v^{2} - u^{2}) + \beta_{1}(v - u)$.

Note that it is not common that $v-u = 1$, i.e., to get a meaningful $X$ effect you might use the quartiles of $X$ and not assume that a 1-unit change is that meaningful for the scale of $X$.

Note also that there is no such thing as the $X$ effect when $Z$ is not set.

Using the R rms package one can get any contrast of interest easily. To get the above use this example for comparing 30 year olds with 20 year olds for the first race group, where race has 3 categories a, b, c:

f <- lrm(y ~ pol(age, 2) * race) # quadratic with interaction
contrast(f, list(age=30, race='a'),
            list(age=20, race='a'))
  • $\begingroup$ Thanks, Frank. This is very helpful. You spotted the fact that I got a little sloppy with my notation. I'm using reference coding of the Z variable so the model you described is exactly what I have. $\endgroup$ Commented Oct 7, 2015 at 16:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.