SED navigation bar go to SED home page go to Dataplot home page go to NIST home page SED Home Page SED Staff SED Projects SED Products and Publications Search SED Pages
Dataplot Vol 2 Vol 1

LOG ODDS RATIO

Name:
    LOG ODDS RATIO (LET)
Type:
    Let Subcommand
Purpose:
    Compute the bias corrected log odds ratio between two binary variables.
Description:
    Given two variables where each variable has exactly two possible outcomes (typically defined as success and failure), we define the odds ratio as:

      o = (N11/N12)/ (N21/N22)
          = (N11N22)/ (N12N21)

    where

      N11 = number of successes in sample 1
      N21 = number of failures in sample 1
      N12 = number of successes in sample 2
      N22 = number of failures in sample 2

    The first definition shows the meaning of the odds ratio clearly, although it is more commonly given in the literature with the second definition.

    The log odds ratio is the logarithm of the odds ratio:

      l(o) = LOG{(N11/N12)/ (N21/N22)}
             = LOG{(N11N22)/ (N12N21)}

    Alternatively, the log odds ratio can be given in terms of the proportions

      l(o) = LOG{(p11/p12)/ (p21/p22)}
             = LOG{(p11p22)/ (p12p21)}

    where

      p11 = N11/ (N11 + N21)
            = proportion of successes in sample 1
      p21 = N21/ (N11 + N21)
            = proportion of failures in sample 1
      p12 = N12/ (N12 + N22)
            = proportion of successes in sample 2
      p22 = N22/ (N12 + N22)
            = proportion of failures in sample 2

    Success and failure can denote any binary response. Dataplot expects "success" to be coded as "1" and "failure" to be coded as "0".

    Dataplot actually returns the bias corrected version of the statistic:

      l'(o) = LOG[{(N11+0.5) (N22+0.5)}/ {(N12+0.5) (N21+0.5)}]

    In addition to reducing bias, this statistic also has the advantage that the odds ratio is still defined even when N12 or N21 is zero (the uncorrected statistic will be undefined for these cases).

    In practice, the log odds ratio is more often used than the odds ratio.

Syntax:
    LET <par> = LOGODDS RATIO <y1> <y2>
                            <SUBSET/EXCEPT/FOR qualification>
    where <y1> is the first response variable;
                <y2> is the second response variable;
                <par> is a parameter where the computed log odds ratio is stored;
    and where the <SUBSET/EXCEPT/FOR qualification> is optional.
Examples:
    LET A = LOG ODDS RATIO Y1 Y2
    LET A = LOG ODDS RATIO Y1 Y2 SUBSET TAG > 2
Note:
    The two variables need not have the same number of elements.
Note:
    There are two ways you can define the response variables:

    1. Raw data - in this case, the variables contain 0's and 1's.

      If the data is not coded as 0's and 1's, Dataplot will check for the number of distinct values. If there are two distinct values, the minimum value is converted to 0's and the maximum value is converted to 1's. If there is a single distinct value, it is converted to 0's if it is less than 0.5 and to 1's if it is greater than or equal to 0.5. If there are more than two distinct values, an error is returned.

    2. Summary data - if there are two observations, the data is assummed to be the 2x2 summary table. That is,

        Y1(1) = N11
        Y1(2) = N21
        Y2(1) = N12
        Y2(2) = N22
Note:
    Dataplot statistics can be used in a number of commands. For details, enter

    Note that the above commands expect the variables to have the same number of observations. If the two samples are in fact of different sizes, there are two ways to address the issue:

    1. Y1 and Y2 can contain the summary data. That is,

        Y1(1) = N11
        Y1(2) = N21
        Y2(1) = N12
        Y2(2) = N22

      This is a useful option in that the data is sometimes only available in summary form. Note that this will not work for the BOOTSTRAP PLOT and JACKNIFE PLOT commands (these require raw data).

    2. You can specify a missing value for the smaller sample. For example, if Y1 has 100 observations and Y2 has 200 observations, you can do something like

        SET STATISTIC MISSING VALUE -99
        LET Y1 = -99 FOR I = 101 1 200
Default:
    None
Synonyms:
    LOGIT is a synonym for LOG ODDS RATIO
Related Commands: Reference:
    Fleiss, Levin, and Paik (2003), "Statistical Methods for Rates and Proportions," Third Edition, Wiley, chapter 6.
Applications:
    Categorical Data Analysis
Implementation Date:
    2007/04
Program:
     
    let n = 1
    .
    let p = 0.2
    let y1 = binomial rand numb for i = 1 1 100
    let p = 0.1
    let y2 = binomial rand numb for i = 1 1 100
    .
    let p = 0.4
    let y1 = binomial rand numb for i = 101 1 200
    let p = 0.08
    let y2 = binomial rand numb for i = 101 1 200
    .
    let p = 0.15
    let y1 = binomial rand numb for i = 201 1 300
    let p = 0.18
    let y2 = binomial rand numb for i = 201 1 300
    .
    let p = 0.6
    let y1 = binomial rand numb for i = 301 1 400
    let p = 0.45
    let y2 = binomial rand numb for i = 301 1 400
    .
    let p = 0.3
    let y1 = binomial rand numb for i = 401 1 500
    let p = 0.1
    let y2 = binomial rand numb for i = 401 1 500
    .
    let x = sequence 1 100 1 5
    .
    let a = log odds ratio y1 y2 subset x = 1
    tabulate log odds ratio y1 y2 x
    .
    label case asis
    xlimits 1 5
    major xtic mark number 5
    minor xtic mark number 0
    xtic mark offset 0.5 0.5
    y1label Bias Corrected Log Odds Ratio
    x1label Group ID
    character x blank
    line blank solid
    .
    log odds ratio plot y1 y2 x
        
    plot generated by sample program

Privacy Policy/Security Notice
Disclaimer | FOIA

NIST is an agency of the U.S. Commerce Department.

Date created: 07/20/2007
Last updated: 11/16/2015

Please email comments on this WWW page to alan.heckert@nist.gov.