Announcement

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

  • McNemar and a correct 2 x 2 table

    Hello,

    I'm a masters student looking into aircrew helmets versus neck pain. I wanted to compare the prevalence or ORs of the 2 helmets to communicate the difference better (Each pilot uses both helmets and indicated if they had neck pain frequently=1, occasionally=2, rarely=3 or never=4) for each helmet. For prevalence I grouped 1,2 and 3 together (Neck pain positive = 1, Neck pain negative = 0) as I'm interested in having neck pain. As all pilots answered for both helmets I think I need McNemar's test to determine the relationship.

    What I struggling with is something basic: I can't make a correct 2 x 2 table to do it and run the McNemar. I thought that I would need one like this:
    Neck Pain Helmet 1 Helmet 2
    NP Positive 68 72
    NP Negative 26 21
    my data looks like this at the moment:
    Helmet 1 Helmet 2
    1 1
    0 0
    1 1
    0 1
    1 1
    1 1
    1 1
    etc.

    I presume I then use mcc command in STATA (IC/15) to get the answer.

    I'm missing something obvious but struggling to figure it out.

    Thank you in advance.
    Last edited by CATHERINE WILKINSON; 29 Jun 2018, 06:46.

  • #2
    Welcome to the Stata Forum / Statalist.

    Please read the FAQ. There you will find advice about sharing data/command/output. This is the best approach to reach a helpful reply.

    That said, coping with the preparation of the data is part and parcel of the process.

    Please take some time to read the examples in the Stata Manual. That being said, you're supposed to have 3 variables: cases, controls and frequency.
    Best regards,

    Marcos

    Comment


    • #3
      Hello Catherine. Here's an example with the data set up as you showed in #1. I added some more cases to have enough data.

      Code:
      clear *
      input byte(h1 h2)
      1   1
      1   1
      1   1
      0   0
      0   0
      0   0
      0   0
      0   0
      0   0
      0   1
      0   1
      0   1
      0   1
      0   1
      0   1
      0   1
      0   1
      1   0
      1   0
      1   0
      1   0
      1   0
      1   0
      1   0
      1   0
      1   0
      1   0
      1   0
      1   0
      1   0
      end
      label variable h1 "Helmet 1"
      label variable h2 "Helmet 2"
      tab h1 h2
      * Use -mcc-, treating h1 as case and h2 as control
      mcc h1 h2
      
      * McNemar's Chi-square is equivalent to Pearson's Chi-square
      * on the two discordant cells, with H0 stating equal expected counts.
      * Let's verify that.
      
      generate d = h1-h2 if h1!=h2 // d for discordant
      replace d=0 if d == -1 // Some subsequent commands want 0/1 coding
      chitest d, count // Pearson Chi-square on discordant cells
      
      * The exact test shown in the -mcc- output is a binomial test
      * on the two discordant cells, with H0 stating each occurs
      * with the same frequency (i.e., 50%). Let's verify that.
      bitest d == 0.5 // Binomial test on discordant cells
      HTH.

      --
      Bruce Weaver
      Email: [email protected]
      Version: Stata/MP 18.5 (Windows)

      Comment


      • #4
        I'd encourage you to retain the ordinal character of your pain ratings, and not collapse them to 0/1. If you believed the ratings enough to collect them, why not believe them enough to use them?

        Under that approach, you can tabulate the ordinal pain ratings against one another, and examine the discordant pairs only, using what I once saw called a "quasi-McNemar" test comparing the pairs "worse under h2" vs. "worse under h1." Here's an example of that, in the same spirit as Bruce's approach:
        Code:
        // simulate data
        clear
        set seed 47656
        set obs 100
        gen byte h1= ceil(4*runiform() + 0.7)
        gen byte h2 = ceil(4*runiform())
        // end data
        //
        // Above/below diagonal cells are of interest
        tab2 h1 h2
        // Among persons discordant, are they worse under h2?
        gen h2worse = (h2 < h1) if (h2 != h1)
        bitest h2worse == 0.5





        Comment


        • #5
          Perfect. Thank you for your help. I really appreciate it.

          Comment

          Working...
          X