srd: Draws scaled rectangle diagrams to represent categorical...

Description Usage Arguments Details Value Author(s) References Examples

Description

Draws scaled rectangle diagrams to represent categorical data.

Usage

1
2
3
4
srd(data = stop("'data' must be specified"), weight = NA,
  labelcell = "frequency", new = TRUE, criterion = "logl",
  colour = "earthy", labelrectangle = "inside", y = NA, w = NA,
  cells = FALSE, motion = "none", thin = NA)

Arguments

data

A binary data matrix of ones and zeroes (or TRUE and FALSE) with k columns, with 1 or TRUE representing presence of an attribute that represents a rectangle.

weight

A frequency count vector attaches a frequency weight to each row of d.

labelcell

Attaches labels to cells. One of "none", "frequency", "area", "error", or "residual". Use "frequency" for cell frequencies (default), "area" for areas, "error" for percentage error, "residual" for Pearson residuals

new

TRUE or FALSE. Fits a new configuration, new=FALSE assumes an existing configuration already exists

criterion

Criterion to determine fitting optimisation. One of "lsqs", "labs", "logl", or "chi2". Use "lsqs" for least squares (default), "labs" for least absolute difference, "logl" for minus log-likelihood, "chi2" for chi-square

colour

Determines colour of configuration. One of "earthy", "bright", or "mono". Use "earthy" for muted colours, "bright" for rainbow colours (default), "mono" is monochrome (shades of grey). If cells=TRUE, "earthy" and "bright" are interpreted as shades of yellow and blue respectively.

labelrectangle

To attach labels to each of the k rectangles. One of "none", "inside", or "arrow". Use "none" for no labels, "inside" (default) for inside rectangle, "arrow" is an arrow pointer from outside of the unit square.

y

A vector of data (with same number of rows as d) for the third axis in a 3D projection . Default NA is equivalent to a vector of zeroes. Projected values are mean values of y, or ∑ y / ∑ w if w is specified. Projected values are of each rectangle, or if cells=TRUE of each cell (see cells parameter)

w

A numeric vector associated with y. Statistics of y for cells/rectangles (see cells argument) represented by ∑ y / ∑ w. Default NA gives 3D projection as mean values of y (equivalent to w=1). w can be used, for example, to obtain 3D projection axis as a "incidence rate" if y is a binary indicator of an outcome and w is person-time.

cells

TRUE or FALSE. True for a diagram shaded by mean of y in each cell of intersecting rectangles and 3D projection showing each cell. Default (FALSE) is transparent represention of each of k rectangles, and 3D projection the mean of y of each rectangle.

motion

Determines whether and how configuration is put into 3D mode. One of values "none", "frames", "movie". "none" for a flat single image, "frames" for broken series of rotated images, "movie" for an animated rotating movie.

thin

Parameter to attempt to avoid thin and elongated rectangles. The criterion is penalised by multiplying by x^thin where is x is maximal thinness (length/breadth) of the q rectangles. Recommended value <=1. Default NA is no penalising, equivalent to thin=0.

Details

A function to visualise k attributes as a Venn-like diagram with areas scaled, as best as possible, to be proportional to frequency. It is a representation is of a 2^q contingency table. Up to six attributes (rectangles) can be displayed. Fitting is done by optimising the congruence between cell area and cell frequency by the chosen criterion. A flat diagram can be thrown into an animated 3D projection, showing mean/rate values of the associated y with motion equal to "frames" or "movie".

Value

Error message, or indication of successful completion.

Author(s)

Roger Marshall, <rj.marshall@auckland.ac.nz>, The University of Auckland, New Zealand

References

Marshall, RJ. Displaying categorical data relationships by scaled rectangle diagrams. Statistics in Medicine 20, 1077-1088, 2001. Marshall, RJ. Scaled rectangle diagrams can be used to visualise clinical and epidemiological data. Journal of Clinical Epidemiology 58, 974-981, 2005. Marshall, RJ. Determining and visualising at-risk groups in case-control data. Journal of Epidemiology and Biostatistics 6, 343-348, 2001

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
library(datasets)
data(Titanic)
x <- data.frame(Titanic)
x$women<-  ifelse(x$Sex=="Female",1,0)
x$child <- ifelse(x$Age=="Child",1,0)
x$first <- ifelse(x$Class=="1st",1,0)
x$survived <- ifelse(x$Survived=="yes",1,0)
d <- x[c("women","child","first")]
srd(data=d,y=x$survived,weight=x$Freq,motion="frames")


library(survival)
data(pbc)
## create srd and show projection axis as incidence rate (by specifying w as time)
pbc$male <- ifelse(pbc$sex=="m",1,0)
d  <- with(pbc,cbind(ascites,hepato,spiders,male))
pbc$event <- ifelse(pbc$status==2,1,0)
srd(d, y=pbc$event, w=pbc$time, colour="earthy",
   labelrectangle="arrow",cells=FALSE,motion="frames", criterion="chi2", thin=0.5)

srd documentation built on April 14, 2017, 1:03 p.m.

Related to srd in srd...