Announcement

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

  • Graphs after margins with interaction and covariates

    Hi,

    I am hopeful that someone can help me.

    I am having trouble understanding how to plot a significant interaction while controlling for several covariates.

    For example, I run the model:

    regress y i.A##i.sex c.control1 i.control2 c.control3

    I get a significant interaction between A and sex.

    I then plot this graph via:

    margins sex#A
    marginsplot, x(A)

    and all looks good (both lines match coefficient direction).

    But then, I perform a sex stratified analysis and find that A is not associated with Y in either males or females. Simple effects however do show m/f differ in one condition.

    My question is, what would be the best way to represent this result?

    I then do:

    regress y i.A##i.sex i.sex(c.control1 i.control2 c.control3)

    and try:
    margins child_sex, dydx(A)
    margins sex#A
    marginsplot, x(A)

    and the coefficients match the sex-stratified analysis - but now there looks like there is no effect at all in one of the groups (the 95% CI are very wide) and the lines are parallel.

    Any help would be much appreciated.

    All the best,
    Lucy

  • #2
    Essentially the issue is related to model specification rather than graphing. The second regression allows the effects of control variables vary by gender, which is preferred to the first regression, but may give up some efficiency. I would suggest starting with the first regression unless your sample size is sufficiently large.
    Last edited by Fei Wang; 25 Nov 2021, 06:43.

    Comment


    • #3
      Thank you for your reply.

      The sample size is approx 150 split into two groups, and there are about 7 control variables (as well an interaction between two predictors).

      Do you think it would "correct" to:

      regress y i.A##i.sex c.control1 i.control2 c.control3
      (report interaction term)

      margins sex, dydx(A)
      (say these are "sex-stratified", even though this model doesn't allow the covariates to vary by sex)

      contrast sex@A
      to look at simple effects between sexes

      margins sex#A
      marginsplot, x(A)
      - obtain and plot the means (are these least squared means?) Also, would it be appropriate to add "asbalanced" here, because the sample sizes are not equal?

      Thanks for your help,
      Lucy

      Comment


      • #4
        contrast sex@A
        to look at simple effects between sexes
        This is the joint tests of the effects of sex within each level of A -- Not sure if it's what you want as you focus on the effects of A and how they vary by sex. You may try the other way round: contrast A@sex.

        margins sex#A
        marginsplot, x(A)
        - obtain and plot the means (are these least squared means?) Also, would it be appropriate to add "asbalanced" here, because the sample sizes are not equal?
        The y axis represents the predicted mean of y for a specific combination of values of sex and A, based on your OLS estimates. Again, as you mainly focus on how the effects of A vary by gender, I'd suggest plotting marginsplot, x(sex).

        Comment


        • #5
          Thank you.

          My main effect of interest is A and sex is the moderator, so I think how I had it is fine?

          (i.e. in the graph the main variable of interest (A) is on the x axis, and the legend shows the effect of sex).

          But my main question is:

          Is it ok to say this is "sex-stratified", even though this model doesn't allow the covariates to vary by sex?

          margins sex, dydx(A)

          Comment


          • #6
            Is it ok to say this is "sex-stratified", even though this model doesn't allow the covariates to vary by sex?
            I think it's ok to say so, as long as you would explain how this is done in details.

            Comment

            Working...
            X