I don't know what is the appropriate term for my question. The scenario is described as following.

In the analysis there one dependent variable Y and two independent variable X1 and X2.

All three variables are continuous.

I converted X1 into a categorical variable which has three levels A, B, and C. It was found that Y and X2 are positively correlated in group A and B, but negatively correlated in group C.

I was told that convert a continuous variable into categorical was generally a bad idea and I understand this. My question is, how can I demonstrate the above pattern without break X1 into categories? I was suggested to go with multiple regression, but I still don't know how to demonstrate this kind of relationship in the three variables with multiple regression.



Converting a continuous variable into categorical may be a bad idea, but may be a good idea as well, this depends on the problem. When the relationships of the variable can be best described using thresholds, categorisation may be one of the best options.

You wrote that in different categories of X1 the correlation between Y and X2 is very different. This is a clear indication of a non-linear relationship between Y, X1 and X2. Thus multiple linear regression is probably not the best method to use here.

In any case I suggest you to visualize your data (maybe using a circles plot, or coloured scatterplot). You may continue with machine learning, or modelling methods that suit what you know about your data.

  • $\begingroup$ Thanks for your response. Though, I found neither circles plot nor colored scatterplot was easy to interpret. However, I suddenly realize that my question is about the interaction between the two continuous variable X1 and X2. So I Googled and found this link seemed to be helpful to me. $\endgroup$ – Jfly Apr 10 '11 at 3:19

You could fit a Generalized Additive Model (GAM) which could uncover nonlinear covariate effects quite easily.

In R you can use the gam or mgcv packages.

Here is the canonical reference


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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