# Significance and credibility intervals for interaction term in logistic regression

I fitted a Bayesian logistic regression in WinBugs and it has an interaction term. Something like this: $$\mathrm{Prob}(y_{i}=1) = \mathrm{logit}^{-1} (a + b_{1}*x_{i} + b_{2}*w_{i} + b_{3}*x_{i}*w_{i})$$

where $x$ is a standardized continuous variable, and $w$ is a dummy variable. In reality the model is more complicated, but I wanna keep things simple.

It happens that the interaction term is "significant", but not the single predictors. For instance,

$\mathrm{mean}(b_{1}) = -.2$ and $95%$ quantile: $(-1.3$ and $.7)$

$\mathrm{mean}(b_{2}) = -.4$ and $95%$ quantile: $(-1.3$ and $.5)$

$\mathrm{mean}(b_{3}) = 1.4$ and $95%$ quantile: $(.4$ and $2.5)$

Do you guys have any advice on how to react to this finding? I thought that I could compute 95% credibility intervals for the whole effect of $x$ when $w=1$. This would be: 95% quantile for total effect of x, conditional on $w=1$: $(-1.3+.4$ and $.7+2.5) = (-.9 + 3.2)$

Is this correct? If not, what should I do? Any references on the subject?

No, your calculation isn't correct, because:

a) $b_1$ and $b_3$ are probably correlated in the posterior distribution, and

b) even if they weren't, that isn't how you would calculate it (think of the law of large numbers).

But never fear, there is a really easy way to do this in WinBUGS. Just define a new variable:

b1b3 <- b1 + b3

and monitor its values.

EDIT:

For a better explanation of my first point, suppose the posterior has a joint multivariate normal distribution (it won't in this case, but it serves as a useful illustration). Then the parameter $b_i$ has distribution $N(\mu_i,\sigma_i^2)$, and so the 95% credible interval is $(\mu_i - 1.96 \sigma_i,\mu_i + 1.96 \sigma_i)$ - note that this only depends on the mean and variance.

Now $b_1+b_3$ will have distribution $N(\mu_1 + \mu_3,\sigma_1^2 + 2 \rho_{13}\sigma_1\sigma_3 + \sigma_3^2)$. Note that the variance term (and hence the 95% credible interval) involves the correlation term $\rho_{13}$ which cannot be found from the intervals for $b_1$ or $b_3$.

(My point about the law of large numbers was just that the standard deviations of the sum of 2 independent random variables is less than the sum of the standard deviations.)

As for how to implement it in WinBUGS, something like this is what I had in mind:

model {
a ~ dXXXX
b1 ~ dXXXX
b2 ~ dXXXX
b3 ~ dXXXX
b1b3 <- b1 + b3

for (i in 1:N) {
logit(p[i]) <- a + b1*x[i] + b2*w[i] + b3*x[i]*w[i]
y[i] ~ dbern(p[i])
}
}


At each step of the sampler, the node b1b3 will be updated from b1 and b3. It doesn't need a prior as it is just a deterministic function of two other nodes.

• I'm not sure I understand your commnet. If b1 and b3 are correlated, why does it matter? I mean, their joint distribution has to characterized with some correlation parameter, but so what? I do have their marginal distributions. 2. I didn't understand you mention about the the law of large numbers. Could you expand on it? Finally, are you sugesting that I should add b1 + b3 in the main loop? And I just need to use a vague prior to this new parameter? Thank you! – Manoel Galdino Jun 30 '11 at 23:23

A few thoughts: 1) I'm not sure whether the fact that this is Bayesian matters. 2) I think your approach is correct 3) Interactions in logistic regression are tricky. I wrote about this in a paper that is about SAS PROC LOGISTIC, but the general idea holds. That paper is on my blog and is available here

• I agree that it's likely that bayesian or not doesn't matter. I just said it was Bayesian just in case it matters. – Manoel Galdino Jun 26 '11 at 14:15

I'm currently having a similar problem. I also believe that the approach to calculate the total effect of w is correct. I believe this can be tested via

h0: b2 + b3 * mean(x) = 0; ha: b2 + b3 * mean(x) != 0

However, I stumbled upon a paper by Ai/Norton, who claim that "the magnitude of the interaction effet in nonlinear models does not equal the marginal effect of the interaction term, can be of opposite sign, and its statistical significance is not calculated by standard software." (2003, p. 123)

So perhaps you should try to apply their formulas. (And if you understand how to do that, please tell me.)

PS. This seems to resemble the chow-test for logistic regressions. Alfred DeMaris (2004, p. 283) describes a test for this.

References:

Ai, Chunrong / Norton, Edward (2003): Interaction terms in logit and probit models, Economic Letters 80, p. 123–129

DeMaris, Alfred (2004): Regression with social data: modeling continuous and limited response variables. John Wiley & Sons, Inc., Hoboken NJ

• Thanks for the reference. I'll take a look at it and will report here if I make any progress on the matter. Regarding your suggested test, I don't think it will do the job. Remember first that the interaction is two-way, from x with w and w with x. By this I mean that even if h0 is true, it's still possible that say h2: b1 + b2*mean(w) is not zero. Moreover, In general I know ahead of time that the null hipothesis is false, i.e., in general there is no such a thing as a zero effect. With a sufficient big sample I can find any effect to be significant. – Manoel Galdino Jun 27 '11 at 22:09
• And another point. Even if h0 and h2 are true, it's still possible that say h3: b2 + b3*(mean(x)+sd(x)) != 0. In other words, we should teste not only for the mean of x (or w), but for the whole distribution of values, since an interaction terma is a way to say that predictive effect vary by subgroups of predictors. – Manoel Galdino Jun 27 '11 at 22:13
• I don’t fully understand what you mean. When testing whether or not b2 + b3 * mean (x) == 0, you always compare to some test statistic to determine whether the result is significantly different from zero, standard deviation of x is not the only relevant factor. – mzuba Jun 28 '11 at 8:39
• About what you said... I'm not sure if I fully understand you either. In any case, one of my points was: even if we fail to reject the null hypothesis that b2 + b3 * mean (x) == 0, it means only that we can't say that the average effect of W, conditional on average values of x, isn't zero. However, the whole point of an interaction term is because we want to condition the effect of W not only on the average x, but on the whole distritubion of x! – Manoel Galdino Jun 28 '11 at 17:44
• Alright. I see what you mean. (English isn’t my first language either.) I believe what you wrote is true and it is also why Ai/Norton plot the interaction effect against the whole distribution of prob(x) – for some values of x, the interaction effect is positive, for some others it is not. However, I believe that the fact that you calculate the effect of W, which is a dummy, might(?) make things easier, because it can be interpreted as chow-test, structural break, subpopulation etc. (Do you want to calculate the step-effect of w 0→1, or are you interested in the interaction effect?) – mzuba Jun 30 '11 at 10:33