Announcement

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

  • Randomization test

    Dear statalist,
    I really need your help with this.
    I want to compare treatment1 (categorical) and treatment2 (categorical) and see their odds for cancer (yes/no). I have been told to use randomization test.
    I have read somewhere to use -permute-, but I don't understand the code and I don't think this command can be use, because I have a binary outcome? Can someone please help me?

  • #2
    No, there is no restriction that prevents using -permute- on binary outcomes, so you'd want to get someone to help you understand whatever confused you in Stata's documentation in this respect. All that -permute- needs for a two-sided test is some test statistic for which comparisons of the absolute value of that statistic are meaningful. Here's an illustration.
    Code:
    clear
    // simulate data
    set seed 4754
    set obs 1000
    gen byte tx = (runiform() < 0.2)
    gen byte cancer = cond(tx == 1, runiform() < 0.1, runiform() < 0.2)
    //
    // Fisher test is an exact randomization test on the odds ratio so you don't
    // actually need to use -permute-.
    cc cancer tx, exact
    //
    //  For -permute-, the OR won't work nicely as a test stat "T" for a
    //  two-sided test because -permute- uses a comparision of  #{|T| >= |T(obs)|}
    //  so I use chi-squared.  OR would work as a test-stat for a one-sided test.
    permute tx r(chi2), reps(10000): cc cancer tx

    Comment


    • #3
      Mike Lacy, thank you for this code. My stata is still rusty, so I have to ask. I see you have cancer and tx (treatment1, I assume), what about treatment2, where can I put treatment2?

      Comment


      • #4
        I presume there was just one variable, treatment (named tx for illustration, sorry for any confusion), and a person could have either treatment 1 or treatment 2, but not both. Further, you didn't mention any control group, so I presumed there is just one variable, coded as 0 and 1 (which Stata generally wants for the coding of a binary variable). This is how a two-valued binary variable would be represented in any data analysis program: one variable, two values. So, if I described your data situation correctly, treatment 1 and treatment 2 are fully represented in your data set. If I've misunderstood, feel free to explain otherwise here.

        Comment


        • #5
          My question was unclear, sorry. I have two different variables treatment1 and treatment2 and I want to test if the odds for getting cancer is different or the same when you get either treatment1 or treatment2. I have been told to use randomization test, this is why I'm confused and don't know how to do it. Hope this was more clear.

          Comment


          • #6
            your question, data and situation are not completely clear to me but why not use exact logistic regression (followed, if wanted, by test or lincom); see
            Code:
            help exlogistic
            help test
            help lincom

            Comment


            • #7
              (glitch during post, deleted)
              Last edited by Mike Lacy; 14 Feb 2022, 14:57.

              Comment


              • #8
                (glitch during post, deleted)

                Comment


                • #9
                  While I was making a minor mess when the processing of my posting froze during the upload <grin>, I was suggesting that despite the seemingly simple data situation here, knowing the nature of the data and its organization would help clear up any confusion we have. My answer above was premised on there being no control groups, and just one treatment variable with two values ("1" or "2"), with each observation pertaining to an individual who received one or the other treatment. I'm thinking that might not be right. Seeing some example data prepared with -dataex-, per the FAQ for StataList, would be a good way to clarify. Whatever simulated or exact permutation procedure is to be used, knowing the nature of the study being analyzed is key to a helpful answer.

                  Comment

                  Working...
                  X