Announcement

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

  • prtest for paired proportions

    Hi
    I want to test the difference between two paired proportions. I need the Confidence Interval for the difference between proportions. I have a paired design wherein each individual with known disease status d is administered two tests (t) with the test results in y. I need to test the hypothesis that the (proportion y = 1 with test 1) - (proportion y =1 with test 0) = 0 in people with d == 1. Part of the data is shown below.

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float id byte(test d y)
     1 1 0 1
     1 2 0 0
     2 1 0 1
     2 2 0 1
     3 1 0 0
     3 2 0 0
     4 1 0 0
     4 2 0 0
     5 1 0 0
     5 2 0 1
     6 1 0 0
     6 2 0 0
     7 1 0 0
     7 2 0 0
     8 1 0 0
     8 2 0 1
     9 1 0 0
     9 2 0 1
    10 1 0 0
    10 2 0 0
    end
    label values d ynlbl
    label def ynlbl 0 "no", modify
    label values y negposlb
    label def negposlb 0 "-", modify
    label def negposlb 1 "+", modify
    When I read the prtest help, I understand that the difference between paired sample proportions needs the cluster() and rho() to be specified. I realize the cluster() in my case is cluster(id) but I am not sure about the rho(). How do I calculate the rho() for my data?

    Is it
    Code:
    corr y test if d == 1
    Please provide guidance.
    Last edited by Inaamul Haq; 17 Jan 2022, 08:18.

  • #2
    The description of your problem does not fit to the data you are showing: There is no case with d == 1 and the values of "test" are 1 and 2, not 1 and 0.

    If I would assume that you want to compare the proportions of 1 in y across the measurements test == 1 and test == 2 if d == 0 (sic!), you could reshape your data from long to wide and use -prtest- for two variables (paired test):
    Code:
    reshape wide y, i(id) j(test)
    prtest y1=y2 if d==0

    Comment


    • #3
      Thank you Dirk Enzmann . Sorry to have pasted the wrong data.
      I am pasting the correct data here again.
      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input float id byte(d y) float test
       1 0 1 0
       1 0 0 1
       2 0 1 0
       2 0 1 1
       3 0 0 0
       3 0 0 1
       4 0 0 0
       4 0 0 1
       5 0 0 0
       5 0 1 1
       6 0 0 0
       6 0 0 1
       7 0 0 0
       7 0 0 1
       8 0 0 0
       8 0 1 1
       9 0 0 0
       9 0 1 1
      10 0 0 0
      10 0 0 1
      end
      label values d ynlbl
      label def ynlbl 0 "no", modify
      label values y negposlb
      label def negposlb 0 "-", modify
      label def negposlb 1 "+", modify
      But I don't think reshaping the data to wide would solve my problem. I am not sure but
      Code:
      prtest y1 = y0 if d == 0
      in wide data and
      Code:
      prtest y if d == 0, by(test)
      in long data would essentially be the same.

      Comment


      • #4
        You are correct, you need no -reshape-. Note that in your example d is still 0 for all cases.

        Comment


        • #5
          Well I realised mcc reports the MCNemar's test as well as the 95% CI for the difference in proportions
          Code:
          mcc casevar controlvar

          Comment

          Working...
          X