# Finding interaction

How do you find the interaction between a continuous and a categorical variable? I have tried using ggPredict but it doesn't seem to work if there are more levels.

I have a categorical variable as reputation which has 7 levels also I have multiple variables to predict the marks of a student in the next exam of masters eg age, pref_hand, height, exam 1, exam 2, exam 3. How can I find the interaction of the reputation with the best model which I found using forward step regression for predicting the marks in the next exam and make changes to my model if I find interaction?

I have tried using scatterPlotMatrix but the colors are getting recycled and it's hard to find any pattern plus I don't even know if the interaction is statistically significant Pr(>|t|)

• Why do you exactly mean by interaction? Well, you can perform some clustering technique as k-means with 7 clusters... Or you may want to try a classification model with 7 classes... – ignatius Nov 13 '18 at 8:54
• I am using multiple linear regression so interaction means that the value of Y depends on Xi and Xi and Xj interact means that the value of Xj will somehow affect the way Xi produces changes on Y, where Xj is categorical variable and Xi is continuous – Liger Nov 13 '18 at 12:50
• u r thinking of correlation ? – sai saran Nov 14 '18 at 5:10

You can test the relationship between categorical and continuous variables by performing an ANOVA F-test.

If you're trying to include interactions in your GLM, you usually have to specify the interaction explicitly - e.g. mod <- glm(y ~ x1 + x2 + x1*x2, data = df,...other args).

All of the R stepwise regression techniques I'm aware of (e.g. stepAIC and bestglm) need the interaction terms to be specified explicitly.

How do you find the interaction between a continuous and a categorical variable?

What I would do in a first step is to calculate a point biserial correlation coefficient.

$$\to$$ In your case, this would probably imply :

1. Compute a binary variable for each of your seven categories
2. Compute the coefficient between each of binary variable and each of your continuous variable of interest.

Wiki ref