File:Odds ratio minsig.svg

Summary

Description
English: Graph showing the minimum value of the log odds ratio statistic that must be observed to be deemed significant at the 0.05 level, using the standard asymptotic hypothesis test. The three lines correspond to different values of the marginal probabilities in the 2x2 contingency table. The row and column marginal probabilities are held equal in this graph.
Date
Source Own work
Author Skbkekas
Permission
(Reusing this file)
I, the copyright holder of this work, hereby publish it under the following licenses:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
Category:CC-BY-SA-3.0#Odds%20ratio%20minsig.svg
GNU head Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled GNU Free Documentation License.
Category:License migration redundant#Odds%20ratio%20minsig.svgCategory:GFDL#Odds%20ratio%20minsig.svg
You may select the license of your choice.
Category:Self-published work
SVG development
InfoField
 The SVG code is valid.
 This plot was created with Matplotlib.
Category:Valid SVG created with Matplotlib code#Odds%20ratio%20minsig.svg
 The file size of this SVG plot may be irrationally large because its text has been converted to paths inhibiting translations.
Category:Path text SVG
Source code
InfoField

Python code

import numpy as np
import matplotlib.pyplot as plt

## Sample sizes.
N = np.arange(10,201)

## Grid of log odds ratio and odds ratio values.
LOR = np.linspace(0.01,20,2000)
R = np.exp(LOR)

## Where to position the line labels.
x = {0.1: 20, 0.2: 40, 0.5: 60}

plt.clf()
for p in 0.1,0.2,0.5:

    ## Get the cell probabilities corresponding to each odds ratio R.
    S = np.sqrt((1+2*p*(R-1))**2 + 4*R*(1-R)*p**2)
    P11 = (1 + 2*p*(R-1) - S) / (2*(R-1))
    P10 = p-P11
    P01 = P10
    P00 = 1 - (P11+2*P10)

    ## The standard errors.
    SE = np.sqrt(1/P11 + 1/P10 + 1/P01 + 1/P00)

    ## Figure out which odds ratio gives a significant result.
    Q = []
    for n in N:
        ii = np.flatnonzero(LOR > 2*SE/np.sqrt(n))
        if len(ii)>0:
            Q.append([n,np.min(LOR[ii])])
    Q = np.array(Q)

    plt.plot(Q[:,0], Q[:,1], '-', color='orange', lw=3)

    jj = np.argmin(np.abs(Q[:,0]-x[p]))
    plt.text(x[p], Q[jj,1], "%.1f" % p, ha='center', va='center',\
            backgroundcolor='white')

plt.ylabel("Log odds ratio", size=18)
plt.xlabel("Sample size", size=18)
plt.grid(True)
plt.savefig("odds_ratio_minsig.pdf")
plt.savefig("odds_ratio_minsig.svg")
Category:Statistical charts Category:Asymptotics
Category:Asymptotics Category:CC-BY-SA-3.0 Category:GFDL Category:License migration redundant Category:Path text SVG Category:Self-published work Category:Statistical charts Category:Valid SVG created with Matplotlib code