paik: Paik diagrams

View source: R/paik.r

paikR Documentation

Paik diagrams

Description

Paik diagrams for the representation of Simpsons Paradox in three way tables.

Usage


paik(formula, counts, resp.lvl = 2, data, circle.mult = 0.4, xlab = NULL, 
ylab = NULL, leg.title = NULL, leg.loc = NULL, show.mname = FALSE,...)

Arguments

formula

A two sided formula, e.g. Y ~ X1 + X2, with cross-classified categorical variables. The second explanatory variable, i.e. X2, is used as the trace variable whose levels are distinguished in the graph with different colors. Interactions and nested terms are not allowed.

counts

A vector of counts for the associated categorical variables in formula.

resp.lvl

The level in Y of primary interest. See example below.

data

Dataframe containing variables in formula.

circle.mult

Multiplier for circle radii in the diagram.

xlab

X-axis label. By default this is defined as the categories in the first explanatory variable, X1.

ylab

Y-axis label. By default these will be proportions with respect to the specified level of interest in the response.

leg.title

Legend title. By default the conditioning variable name.

leg.loc

Legend location. A legend location keyword; "bottomright", "bottom", "bottomleft", "left", "topleft", "top", "topright", "right" or "center".

show.mname

Logical, indicating whether or not the words "Marginal prop" should printed in the graph above the dotted line indicating marginal proportions.

...

Additional arguments from plot.

Author(s)

Ken Aho

References

Agresti, A. (2012) Categorical Data Analysis, 3rd edition. New York. Wiley.

Paik M. (1985) A graphical representation of a three-way contingency table: Simpson's paradox and correlation. American Statistician 39:53-54.

Examples

require(tcltk)

data(death.penalty)# from Agresti 2012 

op <- par(mfrow=c(1,2), mar=c(4,4,0,0))
paik(verdict ~ d.race + v.race, counts = count, data = death.penalty, 
leg.title = "Victims race", xlab = "Defendants race", 
ylab = "Proportion receiving death penalty")
par(mar=c(4,2,0,2))
paik(verdict ~ v.race + d.race, counts = count, data = death.penalty, 
xlab = "Victims race", leg.title = "Defendants race",leg.loc="topleft", 
ylab = "", yaxt = "n")
par(op)

if(interactive()){
if(any(names(sessionInfo()$otherPkgs)=="asbio")) vignette(package = "asbio", "simpson")
}

asbio documentation built on May 29, 2024, 5:57 a.m.