Announcement

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

  • Three way interaction marginsplot?

    Hi all
    I am running a threeway interaction model using mixed and was wondering how best to go about plotting this in a graph?
    the original model is

    mixed wlb_factorc flexi1##c.z_chcov03##female empflex flexi1 autohrs telework tmoff || Country:flexi1, mle variance

    based on this: https://www.statalist.org/forums/for...-by-continuous
    I've tried

    margins flexi1, at (z_chcov03=(-1.80 (0.2) 2.80) female=(0 1))
    marginsplot, by (flexi1)


    but keep getting the error message "female ambiguous abbreviation"

    and if I were to do this

    margins flexi1 female flexi1#female, at (z_chcov03=(-1.80 (0.2) 2.80))
    marginsplot, by (flexi1)


    I get the error message "invalid at() dimension information; using variable flexi1 as a factor variable and a regular variable is not supported"

    I've tried using i.flexi1 and that doesn't work.
    In general I would like to get two graphs like https://www.statalist.org/forums/fil...4&d=1512146046
    but where x=chcov03 and y=wlb_factorc, separately for male and female (like domestic vs foreign in the above link graph) and within the graph for those who flexi1==0 and flexi1==1 (like weight in the link graph)

    Many thanks for your help!!!!





  • #2
    Okay have spoken to sme people and there was a bit that I didn't specify the other covariates...
    and thus so having done this

    mixed wlb_factorc flexi1##c.z_chcov03##female empflex flexi1 autohrs telework tmoff || Country:flexi1, mle variance
    margins flexi1 , at ((mean)empflex autohrs telework tmoff z_chcov03=(-1.80 (0.2) 2.80) female=(0 1))
    marginsplot, by (female) noci


    I still get
    using variable flexi1 as a factor variable and a regular variable is not supported

    Having said that, this works..(i.e. no covariates other than the interaction terms)



    mixed wlb_factorc flexi1##c.z_chcov03##female || Country:flexi1, mle variance
    margins flexi1 , at (z_chcov03=(-1.80 (0.2) 2.80) female=(0 1))
    marginsplot, by (female) noci


    HELP!!
    Last edited by Heejung Chung; 17 Feb 2020, 10:14.

    Comment


    • #3
      The problem arises from your -mixed- command and your misuse of factor-variable notation. By default, any variable mentioned in an interaction term is treated as discrete (i.e. as if it were i.variable), whereas any variable mentioned not in an interaction term is by default treated as continuous (i.e. as if it were c.variable). So flexi1, which appears both in the three-way interaction, and appears separately between empflex and autohrs, has been implicitly specified as both continuous and discrete--which is not allowed.

      So the first question is, which is it? Is it continuous or discrete. If it is discrete, is it dichotomous or does it have more than 2 levels? The solution to your problem depends on the answers to these questions. It is made much more complicated by the fact that your model includes a random slope for flexi1, by the way.

      Comment


      • #4
        Thank you Clyde.
        The answer to that question is that flexi1 is dichotomous!
        As you seem to suggest, I have removed the additional (why was that in there! doch!) flexi1 and made specified the i.flexi1 and actually i.female for that matter, the model seems to work!
        Hurrah.
        Thank you again!!

        Comment

        Working...
        X