Announcement

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

  • How to predict outcome from different variables?

    Hi guys

    I have a dataset with 3 outcomes (good effect, moderate effect and no effect) after a treatment. I have 4 variables with 3 different values (1A,1B,1C, 2A, 2B etc) measured before treatment. I would like to calculate what the probability of a "no effect" outcome in each of the values (1A,1B etc).

    Do you have a suggestion to what code I should use?

    I'm using Stata MP 18.0

    Regards, Niels

  • #2
    Niels:
    welcome to this forum.
    As per FAQ, please share via -dataex- an excerpt/example of your dataset. Thanks.
    Kind regards,
    Carlo
    (StataNow 18.5)

    Comment


    • #3
      Thank for the advise, Carlo. I have listed the dataex beneath. The first column is the ID and the next four are the variables ( in line one "C1" .87 .87 .87). The last column is outcome (1,2 or 3)

      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input str4 ID str2 tymppre double(TMM30 TMM40 TMM50) str2 Tymppost double(TMM30p TMM40p TMM50p) byte(Subjective K L M)
      "3L"   "C1"  .87  .87   .87 "A"   .13  .13  .13 1 . . .
      "5L"   "A"     0    0   .54 "A"    .2   .2  .56 1 . . .
      "6R"   "B"     0    0     0 "B"     4 1.58 1.74 1 . . .
      "6L"   "B"     0    0     0 "B"   .75  .73 1.67 1 . . .
      "10R"  "C1" 1.12  .86   .98 "A"  1.97 1.57 2.03 1 . . .
      "10L"  "C1"    2 1.02  3.66 "A"   .76  .92 1.43 1 . . .
      "17R"  "A"     0    0     0 "A"   .69  .95  .95 1 . . .
      "19R"  "A"     0    0     0 "A"   .67  .67  .67 1 . . .
      "22L"  "A"     0    0     0 "C1"    0    0 2.18 1 . . .
      "31R"  "B"     0    0     0 "A"     0    0  .42 1 . . .
      "34R"  "B"    .6   .6     0 "A"   .69  .69  .62 1 . . .
      "35R"  "A"     0    0     0 "A"     0 2.13    1 1 . . .
      "35L"  "B"     0    0     0 "B"     0    0    2 1 . . .
      "41L"  "C1"  .86    0     0 "A"    .5  .63  .63 1 . . .
      "46R"  "B"     0 2.29   .14 "A"  3.55  .34 1.56 1 . . .
      "51R"  "A"     0  .42   .42 "A"    .5   .5  .23 1 . . .
      "51L"  "A"    .5   .5    .5 "A"    .5   .5   .5 1 . . .
      "54R"  "A"     0    0     0 "A"     0    0    0 1 . . .
      "56R"  "C1"    0    0     0 "A"     0    0    0 1 . . .
      "58R"  "B"   .59  .59   .59 "B"   .62  .62  .39 1 . . .
      "58L"  "B"   .78  .71  1.03 "B"   .22  .39  .69 1 . . .
      "61R"  "A"   .25  .65   .88 "B"  1.22 1.22  .92 1 . . .
      "62R"  "B"  1.11  .69   .54 "C1"    0  .92  .74 1 . . .
      "62L"  "B"     0  .85   .54 "C1"    0 1.18  .73 1 . . .
      "63R"  "B"   .63  .85   .63 "A"     0    0   .6 1 . . .
      "64L"  "B"   .62  .31     0 "A"   .64  .65  .84 1 . . .
      "67R"  "B"     1 1.12  1.37 "C1"  .39  .89  .89 1 . . .
      "67L"  "B"  1.88 1.18  1.04 "A"   .71  .62   .7 1 . . .
      "68r"  "B"     0    0     0 "A"    .9  .76  .59 1 . . .
      "72R"  "A"   .87  .46   .64 "A"   .55   .7  .55 1 . . .
      "72L"  "B"     0    0   .64 "B"   1.5  1.7 2.83 1 . . .
      "75R"  "B"     0    0     0 "C1" 1.58  .95  .79 1 . . .
      "75L"  "B"     0    0     0 "C1"    0 1.91  .92 1 . . .
      "80R"  "B"     0  .75   .94 "C1" 1.85 1.85 1.85 1 . . .
      "80L"  "B"  1.55  .75   .75 "B"   .73  .73 1.08 1 . . .
      "81R"  "A"  1.35 2.54  1.23 "A"    .6   .6  .95 1 . . .
      "84R"  "B"    .7   .7   .64 "A"   .38  .13  .04 1 . . .
      "84L"  "B"   .62   .4     0 "A"   .66  .64  .84 1 . . .
      "85R"  "B"     0    0     0 "A"  4.23  1.5  .33 1 . . .
      "94R"  "A"     0    0     0 "A"     0    0    0 1 . . .
      "94L"  "A"     0    0     0 "A"     0    0    0 1 . . .
      "95L"  "A"     0    0   .38 "A"     0  2.9 1.03 1 . . .
      "96R"  "C1"  .23  .31  4.17 "A"   .19  .92  .55 1 . . .
      "96L"  "C1"    0    2   .69 "A"   4.8    1  .55 1 . . .
      "98R"  "C1" 1.12  .91   .91 "C1" 1.58  .42  .26 1 . . .
      "98L"  "C1"  .54  .66   .73 "C1"  .95  .26  .26 1 . . .
      "101R" "C2"  .45  .45   .45 "A"   .36  .36  .39 1 . . .
      "103R" "C1"    0    0   1.6 "C2"    0    0    0 1 . . .
      "103L" "C2" 1.11 1.11   .89 "C2" 1.09 1.09  .83 1 . . .
      "107R" "A"     0    0     0 "A"   .04  .09 1.17 1 . . .
      "107L" "B"     0    0     0 "B"   .33 1.17 1.17 1 . . .
      "110L" "B"   .57 1.41    .8 "C1"  .57 1.41   .8 1 . . .
      "111L" "C1"  .22  .22   .22 "B"   .05   .1   .1 1 . . .
      "112L" "B"     0    0     0 "C1"    0 2.48 2.48 1 . . .
      "118R" "B"     0 1.12  1.52 "A"  1.06    1 1.03 1 . . .
      "118L" "C2"  .88  .52   .52 "A"  1.17  1.2  .97 1 . . .
      "119R" "B"     0    0     0 "B"   .52   .4  .68 1 . . .
      "119L" "B"     0  .73    .8 "C2"  .84  .68  .84 1 . . .
      "121R" "C2"  .43 1.21  1.29 "B"   .48  .48  .64 1 . . .
      "122R" "B"     0    0     0 "B"     0    0    0 1 . . .
      "122L" "B"     0    0     0 "B"     0    0    0 1 . . .
      "124L" "B"     0    0     0 "C1"    0 1.18 1.24 1 . . .
      "125R" "A"     0    0     0 "A"  1.21  .91 1.21 1 . . .
      "126R" "B"   .91  .18  1.59 "A"    .1 1.11  .83 1 . . .
      "126L" "C2" 1.71    2  1.72 "A"   .01  .01  .01 1 . . .
      "127R" "C1"    0    0     0 "C1"    0 1.12    0 1 . . .
      "127L" "C1"    0    0     0 "A"     0    0 1.04 1 . . .
      "7R"   "A"     0    0     0 "A"     0    0    0 2 . . .
      "7L"   "C1"    0    0     0 "A"     0    0  .25 2 . . .
      "12R"  "B"     0    0     0 "B"   .42  .42  .42 2 . . .
      "12L"  "B"     0    0     0 "B"   .82  .82  .82 2 . . .
      "13R"  "B"  1.08  .76   .76 "A"   .33  .92  .98 2 . . .
      "13L"  "B"   .68  .68   .68 "A"   .67  .78  .78 2 . . .
      "14L"  "B"     0    0     0 "C1"  .91  .86  .84 2 . . .
      "19L"  "A"     0    0  1.28 "A"     1    1  .67 2 . . .
      "21R"  "C1"    0    0     0 "A"  2.92 3.65 7.77 2 . . .
      "21L"  "A"  1.72 1.32   1.4 "A"  1.42  .46  .46 3 . . .
      "22R"  "B"     0  1.5  1.95 "C1"    0    2 1.36 3 . . .
      "27R"  "A"    .5   .5    .5 "A"  1.12  .55  .29 3 . . .
      "27L"  "A"     0   .5    .5 "A"  1.33 1.33  .29 3 . . .
      "28R"  "B"  1.67 2.95   .44 "C2" 1.94 1.45   .3 3 . . .
      "38R"  "C2"    0 1.08  2.65 "C1" 1.41 1.41 1.78 3 . . .
      "39L"  "A"   .11  .11   .11 "A"   .61 1.55  .64 3 . . .
      "41R"  "C1" 2.25 1.25   .68 "A"     1    1    1 3 . . .
      "43R"  "B"   .76  .76   .76 "C1" 1.62 1.12    0 3 . . .
      "44R"  "B"    .6  .93   .46 "C1" 1.15  .55  .61 3 . . .
      "44L"  "B"   .47  .47   .64 "C1"  .27  .73  .54 3 . . .
      "45R"  "A"   .87  .87   .87 "A"   .93  .82  .97 3 . . .
      "46L"  "B"     0    1   .26 "B"  1.22 1.11  .78 3 . . .
      "47R"  "A"   .68  .54   .91 "A"   .73  .54  .45 3 . . .
      "47L"  "A"   .51 1.84 2.176 "A"  1.11  .33  .55 3 . . .
      "48R"  "B"     0    0   .44 "A"     0    0  .24 3 . . .
      "48L"  "A"     0    0   .44 "A"     0    0  .05 3 . . .
      "49R"  "C2"    0    0     0 "A"   .83  1.1   .8 3 . . .
      "50R"  "A"   .04  .04   .48 "A"     0    0    0 3 . . .
      "50L"  "A"   .31  .28   .21 "A"   .22  .81  .66 3 . . .
      "53R"  "A"  1.36 1.36   .58 "A"   .81  .81  .77 3 . . .
      "53L"  "B"   .95  .76   .58 "A"  1.15 1.05 1.05 3 . . .
      "56L"  "C1"  .79  .46   .37 "C2"   .4   .4    0 3 . . .
      "68L"  "B"     0    0     0 "B"   .35    0  .35 3 . . .
      end
      Last edited by Niels Holm; 21 Mar 2024, 04:55.

      Comment


      • #4
        To elaborate, the numerical data in variables (column 2,3 and 4) will be stratisfied into: 0 = X, 0-1 = Y and >1 = Z.
        So what I need is to define: "what is the risk of outcome 3 in case of variable = C1", what is the risk of outcome 1 in case of variable = X", etc

        Comment


        • #5
          Niels:
          sorry, but I do not understand what you're after.
          Kind regards,
          Carlo
          (StataNow 18.5)

          Comment


          • #6
            Sorry for not being clear. I'll try again.
            We have some measurements before a treatment and want to calculate if any of these measurements can be used to predict an outcome. For example, is B associated with a higher probability of 3 (no effect of treatment) or 1 (good effect of treatment).

            Regards, Niels

            Comment


            • #7
              I think I need to calculate the odds-ratios and use those as a predictive value...

              Comment


              • #8
                Do you have any observations after treatment?
                ---------------------------------
                Maarten L. Buis
                University of Konstanz
                Department of history and sociology
                box 40
                78457 Konstanz
                Germany
                http://www.maartenbuis.nl
                ---------------------------------

                Comment


                • #9
                  #8: Yes. In line 1, these are the observations after surgery: "A" || .13 || .13 || .13 || 1. The last observation (1) indicates "good effect"

                  Comment


                  • #10
                    I have tried to use "tabodds", which looks like it might could be a good option?
                    I have dichotomiously divided the subjective result into: Subjective: 0 = no effect | 1 = good effect. The "tymppre" have been changed from letters to numbers: 0=A | 1=C1 | 2=C2 | 3=B

                    Stata code:
                    tabodds Subjective tymppre, or
                    ---------------------------------------------------------------------------
                    tymppre | Odds ratio chi2 P>chi2 [95% conf. interval]
                    -------------+-------------------------------------------------------------
                    0 | 1.000000 . . . .
                    1 | 2.642857 3.76 0.0525 0.951397 7.341510
                    2 | 1.450980 0.40 0.5291 0.452140 4.656398
                    3 | 1.995098 4.44 0.0352 1.035822 3.842759
                    ---------------------------------------------------------------------------
                    Test of homogeneity (equal odds): chi2(3) = 6.13
                    Pr>chi2 = 0.1054

                    Score test for trend of odds: chi2(1) = 3.54
                    Pr>chi2 = 0.0599

                    Comment

                    Working...
                    X