Announcement

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

  • Two way anova with interactions

    Hallo
    My Problem: I want to perform a two way Anova with interations
    Let's say
    Group sex (male; female coded as 1 or 0)
    Group size (small, medium, large coded as 0, 1 or 2)

    I want to compare:

    male-small vs male medium
    male-small vs male large
    male-large vs male medium

    female-small vs female medium
    female-small vs female large
    female-large vs female medium

    is there an easy way to do a two-way ANOVA with interactions in Stata using the GUI? The "easiest" way I found is to use the contrast command (from the post-estimation command) and to write a custom contrast on each field.

    The command looked lilke that:
    contrast {sex 1 -1}#{size 0 1 -1} {sex 1 -1}#{size 1 0 -1} {sex 1 -1}#{size 1 -1 0}, mcompare(sidak) pveffects

    Can I define the post hock test using a drop down menu or something else from stata GUI?

    Thanks
    John

  • #2
    You can use factor notation to change the reference category of the model, e.g.,

    Code:
    clear
    use https://www.stata-press.com/data/r16/systolic
    tabulate drug 
    tabulate disease 
    drop if inlist(drug, 3, 4)
    tabulate drug disease
    regress systolic disease##drug
    contrast disease@drug, pveffect nowald
    contrast b2.3.disease@drug, pveffect nowald
    contrast (b1.2.disease@drug) /// 
        (b1.3.disease@drug) /// 
        (b2.3.disease@drug), /// 
        pveffect nowald mcompare(sidak)

    Comment


    • #3
      ok thanks I understand,

      Is there from a mathematical / computational perspective any difference between the above mentioned code and following code?

      Code:
      use https://www.stata-press.com/data/r16/systolic
      drop if inlist(drug, 3, 4)
      label define disease 1 "di1" 2 "di2" 3 "di3"
      label values disease disease
      label define drug 1 "dr1" 2 "dr2"
      label values drug drug
      tabulate drug disease
      egen float drug_dis = group(drug disease)
      label define drug_dis 1 "dr1_di1" 2 "dr1_di2" 3 "dr1_di3" 4 "dr2_di1" 5 "dr2_di2" 6 "dr2_di3"
      label values drug_dis drug_dis
      oneway systolic drug_dis, sidak tabulate
      Or let me please summarize my problem in other words: Is it from a statistical / mathematical / computational perspective wrong or incorect to perform a two way anova by summarizing the groups like I did in the example above and perform a one way anova?
      To check if my assumption is correct, I performed a two way anova in Graphpad Prism, R and in Jamovi (not real different from R - it uses the same R-engine, I used it more due to its easy GUI) and the found exactly the same p values in Stata, Graphpad Prism, Jamovi and R.
      It seems that rearranging the groups like described and performing a one-way ANOVA gives exactly the same p-values compared to a traditional 2-way Anova. Do I make any obvious errors?
      Thanks
      John
      Last edited by Ioannis Stratos; 06 Jan 2021, 08:41.

      Comment

      Working...
      X