Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Plotting logistic regression with triple interaction

    Dear all,

    I ran a logistic regression with a triple interaction for three independent and dichotomous variables. For simplicity, let's name them x1 (0,1); x2 (0,1) and x3 (0,1).
    As it becomes quite challenging to process and easly interpret the regression output I'd like to create a visual representation of it. I guess plotting the predicted probabilities?

    In a similar post, I found this solution:

    Code:
    logit y x1##x2, or
    margins x2#x1
    marginsplot
    However, this does not seem to work when the third variable is added to the interaction.

    I tried the follwoing:
    Code:
    logit y x1##x2##x3, or
    margins x2#x1, by (x3)
    marginsplot, by(x3)
    But I am not sure if that is correct.

    Any clues on how could I represent it?

    Thank you very much for your help,
    Last edited by Marc Asensio; 07 Feb 2023, 01:57.

  • #2
    Code:
    margins x1#x2#x3
    marginsplot, xdimension(x1)
    will calculated the predictive margins in all 8 combinations of x1, x2, and x3. Then it depends on how you want to plot it. One of the variables, say X1, can be on the horizontal axis. The probability of y will be on the vertical axis, and you will get four lines corresponding to the four combinations of x2 and x3. If you want a different X on the horizontal axis, just change the -xdimension()- option accordingly.

    Or, if you want, say, two separate graphs (with two lines in each) corresponding to the values of x2, with x1 on the horizontal axis, you could do
    Code:
    marginsplot, xdimension(x1) by(x2)
    Again, adjust the choice of variables for -xdimension()- and -by()- according to your preferences.

    Comment

    Working...
    X