Announcement

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

  • How to do pairwise comparisons within groups after mixed

    Hi all.
    I am trying to do contrasts after the following mixed model in Stata 18:
    Code:
    mixed y group##time || id:
    There are six groups and three time points.

    I want to do all pairwise comparisons of group only within each time point, and all pairwise comparisons of time points only within each group.

    Code:
    contrast r.time@group
    and
    Code:
    contrast r.group@time
    only do comparisons vs the reference level in each case.

    Code:
    pwcompare time#group
    does all pairwise comparisons for all combinations of group and time. How do I restrict the pairwise comparisons between time points to only within the same group, and comparisons between groups to only within the same time points?

    Thanks, and apologies for what must be an elementary question.

  • #2
    There may be a way to do it in a single command that I'm not thinking of. But you can do this:

    Code:
    forvalues g = 1/6 {
        margins time, at(group = `g') pwcompare
    }
    Note: Assumes the group variable takes on the values 1 through 6. Modify the -forvalues- command accordingly if this is not the case.

    Comment


    • #3
      Thank you so much Clyde, that works perfectly!

      Comment

      Working...
      X