File:Simpson's paradox.svg

Original file(SVG file, nominally 500 × 346 pixels, file size: 9 KB)

Captions

Captions

Add a one-line explanation of what this file represents
 
W3C-validity not checked.

Summary edit

Description An illustration of w:en:Simpson's paradox
Date
Source Own work
Author Schutz

The graphic was created by User:Schutz for Wikipedia on 15 August 2007, using the R statistical project. The program that generated and exported the graphic is given below; the postscript file was converted to SVG with the pstoedit command and the layout was slightly modified using Inkscape before upload.

The example is taken from w:en:Simpson's paradox#Description of the paradox.

 success1 <- c( 60,  1)
 total1   <- c(100, 10)
 success2 <- c(  9, 30)
 total2   <- c( 10,100)
 
 ratios1 <- success1/total1
 ratios2 <- success2/total2
 
 postscript("simpson.eps", paper="special", height=4, width=6, horizontal=F)
 
 par(mfrow=c(2,1))
 par(las=1)
 par(yaxs="i")
 par(xpd=NA)
 par(cex=1.3)
 
 par(mar=c(2.1, 2.6, 0.7, 0.6))
 plot.new()
 plot.window(xlim=range(ratios1, ratios2)+c(-1,1)*0.05*diff(range(ratios1,ratios2)),
            ylim=c(0,max(total1, total2)))
 
 width  <- (par("usr")[2]-par("usr")[1])/15
 height <- (par("usr")[4]-par("usr")[3])/5
 
 rect( ratios1[1]-width/2, 0, ratios1[1]+width/2, total1[1], col="red")
 rect( ratios1[2]-width/2, 0, ratios1[2]+width/2, total1[2], col="blue")
 segments ( min(ratios1)-width/2, 0, max(ratios1)+width/2, 0, lwd=2)
 ratiototal1 <- sum(success1)/sum(total1)
 
 polygon(c(ratiototal1, ratiototal1-width/2, ratiototal1+width/2),
         c(0, -height, -height), col="black")
 
 axis(2)
 axis(1, at=c(ratios1))
 
 plot.new()
 plot.window(xlim=range(ratios1, ratios2)+c(-1,1)*0.05*diff(range(ratios1,ratios2)),
             ylim=c(0,max(total1, total2)))
 
 rect( ratios2[1]-width/2, 0, ratios2[1]+width/2, total2[1], col="red")
 rect( ratios2[2]-width/2, 0, ratios2[2]+width/2, total2[2], col="blue")
 segments ( min(ratios2)-width/2, 0, max(ratios2)+width/2, 0, lwd=2)
 
 ratiototal2 <- sum(success2)/sum(total2)
 
 polygon(c(ratiototal2, ratiototal2-width/2, ratiototal2+width/2),
         c(0, -height, -height), col="black")
 
 axis(2)
 axis(1, at=c(ratios2))
 
 dev.off()

Licensing edit

I, the copyright holder of this work, hereby publish it under the following licenses:
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.
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported, 2.5 Generic, 2.0 Generic and 1.0 Generic 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.
You may select the license of your choice.
 
This W3C-unspecified chart was created with R.

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current18:43, 15 August 2007Thumbnail for version as of 18:43, 15 August 2007500 × 346 (9 KB)Schutz (talk | contribs){{Information |Description=An illustration of w:en:Simpson's paradox |Source=self-made |Date=15 August 2007 |Author= Schutz }}

The following page uses this file: