Announcement

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

  • Logistic

    Hello everyone,
    I have a question on logistic for OR.
    I did command: logistic Var1 i.Var2 i.Var3
    The result show me the OR from dependence and independence variables.
    I would need the Stata show me both 0=Negive and 1=Positive from my dependence variable.
    Because when I do the contrast, 0=Positive and 1=Negative then the OR is different.
    Is there any command for both 0 and 1?

    Thanks for your help
    Best,
    Step

  • #2
    Stephan:
    welcome to this forum.
    Your question(s) can be made clearer by posting what you typed and what Stata gave you back (as per FAQ). Thanks.
    When it comes to comment on quantities, codes, outcomes and tables worth much more than words.
    Kind regards,
    Carlo
    (StataNow 18.5)

    Comment


    • #3
      Doc1.docx
      Here is my outcome from the Logistic for OR. This show only the compare for 1 not 0, I need Stata to show me both in the same table.

      Thanks for your suggestion

      Step

      Comment


      • #4
        Stephan:
        the FAQ #12 explains how to share (using CODE delimiters) what you typed and what Stata gave you back. Thanks.
        Please also note that listers are in general reluctant to downloading/opening attachments coming from unknown sources, due to the risk of active contents (and related damages for their own files and desk/laptop).
        All that said:
        - you cannot have the OR of the dependent variable;
        - whenever your predictor is categorical, Stata omits one level of it (see -fvvarlist- help file for more details) to avoid the so called dummy trap (https://en.wikipedia.org/wiki/Dummy_...(statistics)); hence, what you're after is simply unfeasible.

        However, you may want to take a look at -margins- entry in Stata .pdf manual for more suggestions about how to take the matter further.
        Kind regards,
        Carlo
        (StataNow 18.5)

        Comment


        • #5
          I means the OR of the independence variable both from 2 values of the dependence variable.
          It is possible?

          Comment


          • #6
            If the odds of success for men is twice the odds of success for females, i.e. the odds ratio is 2, then by necessity the odds of success for females is half the odds of success for males, i.e. the odds ratio is 0.5. The latter statement contains no additional information, which is why you cannot estimate both numbers simulataneously. This is sometimes refered to as the dummy variable trap.

            So a table showing the odds ratios for men versus women and the odds ratios of women versus men contain the exact same information twice (even though the numbers are different). Creating such a table is a waste of your time, and reading such a table is a waste of the readers time. So, my suspicion is that you don't really want to create that table, but misunderstood something about the nature of odds ratios or indicator (dummy) variables. That is something we need to fix first. Maybe we can get at the problem if you tell us why you think you want that table.
            ---------------------------------
            Maarten L. Buis
            University of Konstanz
            Department of history and sociology
            box 40
            78457 Konstanz
            Germany
            http://www.maartenbuis.nl
            ---------------------------------

            Comment


            • #7
              Hello all,
              I just surprise that R-program can do both 0/1 of the dependence variable to know OR, So I just think that we could do it also in Stata.

              Anyways thank you for your answer, it makes me clear about the Stata.

              Thank you so much

              Step

              Comment


              • #8
                I guess the problem here is communication. Your use of statistical terminology seems all wrong. We all had to learn that, so that is fine, but it makes understanding what you want very hard. Can you tell us exactly what you want Stata to do. Pay special attention to using correct terminology. Maybe you want to change the reference category?
                ---------------------------------
                Maarten L. Buis
                University of Konstanz
                Department of history and sociology
                box 40
                78457 Konstanz
                Germany
                http://www.maartenbuis.nl
                ---------------------------------

                Comment


                • #9
                  To illustrate Maarten post, please look at this:

                  Code:
                  clear
                  sysuse auto
                  tab foreign, nol
                  gen foreign2 = (foreign == 0)
                  tab foreign foreign2, nol //recoding works, when foreign is 1, foreign2 is 0 (and vice versa) - foreign2 label is switched, won't fix it
                  
                  logistic foreign mpg
                  logistic foreign2 mpg
                  The last 2 logistic regressions are the same, except that observations had 0/1 switched in the outcome ("dependent variable"). This is the output:

                  Code:
                  . logistic foreign mpg
                  
                  Logistic regression                             Number of obs     =         74
                                                                  LR chi2(1)        =      11.49
                                                                  Prob > chi2       =     0.0007
                  Log likelihood =  -39.28864                     Pseudo R2         =     0.1276
                  
                  ------------------------------------------------------------------------------
                       foreign | Odds Ratio   Std. Err.      z    P>|z|     [95% Conf. Interval]
                  -------------+----------------------------------------------------------------
                           mpg |   1.173232   .0616975     3.04   0.002      1.05833    1.300608
                         _cons |   .0125396   .0151891    -3.62   0.000     .0011674    .1346911
                  ------------------------------------------------------------------------------
                  Note: _cons estimates baseline odds.
                  
                  
                  
                  . logistic foreign2 mpg
                  
                  Logistic regression                             Number of obs     =         74
                                                                  LR chi2(1)        =      11.49
                                                                  Prob > chi2       =     0.0007
                  Log likelihood =  -39.28864                     Pseudo R2         =     0.1276
                  
                  ------------------------------------------------------------------------------
                      foreign2 | Odds Ratio   Std. Err.      z    P>|z|     [95% Conf. Interval]
                  -------------+----------------------------------------------------------------
                           mpg |   .8523465   .0448229    -3.04   0.002      .768871    .9448848
                         _cons |   79.74755   96.59782     3.62   0.000     7.424394    856.5913
                  ------------------------------------------------------------------------------
                  Note: _cons estimates baseline odds.
                  Since in foreign coding is 1==Foreign and 0==Domestic, it means that every increase in 1 unit in mpg increase the odds of the car being foreign in 17% (or 1.17 times). If we just switch those (using foreign2, which meaning is 1==Domestic and 0==Foreign), it now means that every increase in 1 unit in mpg decrease the odds of the car being domestic in 15% (or 0.85 times). Both information are correct but are redundant.

                  OR is a ratio, note the following:
                  Code:
                  display 1/1.173232
                  1.173232 is the OR in the first model. The display above will show a number very very close to the OR in the second model.

                  If we did the same but using the OR in the second model, we would get a number very very close to the OR found in the first model.
                  Code:
                  display 1/0.8523465

                  Comment

                  Working...
                  X