Announcement

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

  • Generation of a random dc

    Hi,

    For a class exercise to show an association between the exposure and the outcome, I want to create a random dichotomous variable (0,1) in a real dataset based on another real dichotomous variable. Is there a way to create such a variable?

    Many thanks!





  • #2
    Maybe something like the following.
    Code:
    set seed 43736551
    assert inlist(real_dichotomous, 0, 1) | mi(real_dichotomous)
    generate byte random_dichotomous = ///
        binomial(1, cond(real_dichotomous == 1, 0.75, 0.25)) if !mi(real_dichotomous)
    You can adjust the conditional probabilities in order to strengthen or lessen the degree of association.

    Comment


    • #3
      Hi, thanks. I tried running this syntax but it doesn't run. Stata says it is invalid.

      Comment


      • #4
        Missed an important letter. Sorry about that.

        Try this instead.
        Code:
        set seed 43736551
        assert inlist(real_dichotomous, 0, 1) | mi(real_dichotomous)
        generate byte random_dichotomous = ///
            rbinomial(1, cond(real_dichotomous == 1, 0.75, 0.25)) if !mi(real_dichotomous)

        Comment


        • #5
          Thanks Joseph. Could you kindly let me know how can I lessen the association? Right now, it shows an OR of 10.9.

          Also, I want to see if some other real covariates such as age, and education are confounders or not in this association. Can you tell me how I can look at that?

          Comment

          Working...
          X