# Interaction terms and BUGS

It occurred to me that how one writes an interaction term in BUGS depends on the types of predictors that are "interacting". Suppose data that are long (rather than wide). Then, a model with an interaction between two factors, A and B, as in two-way ANOVA, may look something like

y[i] ~ dnorm(mu[i], tau)
mu[i] <- A[a_level[i]] + B[b_level[i]] + A.B[a_level[i],b_level[i]]
A.B[,] ~ dnorm(0, ab.tau)


However, a model with an interaction between a factor A and a continuous predictor C may look something like

y[i] ~ dnorm(mu[i], tau)
mu[i] <- A[a_level[i]] + betaC*C[i] + betaX[a_level[i]]*C[i]
betaX ~ dnorm(0, betaX.tau)


So, a few questions:

1. Are these interactions written correctly?
2. What other important interactions are there? Obviously, two continuous predictors is another case.
3. Are there differences for how one would write this for linear regression vs. logistic regression?
4. Are there differences in the priors that should be specified for different types of interactions?

This may need to be a community wiki, not sure.

-
Hi. The Gaussian linear model with a factor and a continuous predictor is commonly termed as "ANCOVA - a helpful keyword to search on the web –  Stéphane Laurent Jan 15 '12 at 18:40
good point; tags added –  Jack Tanner Jan 15 '12 at 19:24
In your second code block, you have A[a_level[i]] twice; I suspect you want the second usage to be different, e.g., betaX[a_level[i]]. –  jbowman Jan 15 '12 at 19:31
@jbowman, thanks, i think you're right –  Jack Tanner Jan 15 '12 at 21:23