Learn R Programming

riskyr (version 0.1.0)

plot_icons: Plot an icon array of a population.

Description

plot_icons plots a population of which individual's condition has been classified correctly or incorrectly as icons from a sufficient and valid set of 3 essential probabilities (prev, and sens or its complement mirt, and spec or its complement fart) or existing frequency information freq and a population size of N individuals.

Usage

plot_icons(prev = num$prev, sens = num$sens, mirt = NA, spec = num$spec,
  fart = NA, N = freq$N, type = "array", ident.order = c("hi", "mi",
  "fa", "cr"), icon.colors = pal[c("hi", "mi", "fa", "cr")],
  icon.types = 22, icon.border.col = grey(0.1, 0.5),
  icon.border.lwd = 1.5, transparency = 0.5, icon.size = NULL,
  block.d = NULL, border.d = 0.1, block.size.row = 10,
  block.size.col = 10, nblocks.row = NULL, nblocks.col = NULL,
  fill.array = "left", fill.blocks = "rowwise", show.accu = TRUE,
  w.acc = 0.5, title.lbl = txt$scen.lbl, type.lbls = txt[c("hi.lbl",
  "mi.lbl", "fa.lbl", "cr.lbl")], cex.lbl = 0.85)

Arguments

prev

The condition's prevalence prev (i.e., the probability of condition being TRUE).

sens

The decision's sensitivity sens (i.e., the conditional probability of a positive decision provided that the condition is TRUE). sens is optional when its complement mirt is provided.

mirt

The decision's miss rate mirt (i.e., the conditional probability of a negative decision provided that the condition is TRUE). mirt is optional when its complement sens is provided.

spec

The decision's specificity value spec (i.e., the conditional probability of a negative decision provided that the condition is FALSE). spec is optional when its complement fart is provided.

fart

The decision's false alarm rate fart (i.e., the conditional probability of a positive decision provided that the condition is FALSE). fart is optional when its complement spec is provided.

N

The number of individuals in the population. A suitable value of N is computed, if not provided. If N is 100,000 or greater it is reduced to 10,000 for the array types if the frequencies allow it.

type

The icons can be arranged in different ways resulting in different types of displays:

  1. type = "array": Icons are plotted in a classical icon array (default). Icons can be arranged in blocks using block.d. The order of filling the array can be customized using fill.array and fill.blocks.

  2. type = "shuffledarray": Icons are plotted in an icon array, but positions are shuffled (randomized). Icons can be arranged in blocks using block.d. The order of filling the array can be customized using fill.array and fill.blocks.

  3. type = "mosaic": Icons are ordered like in a mosaic plot. The area size displays the relative proportions of their frequencies.

  4. type = "fillequal": Icons are positioned into equally sized blocks. Thus, their density reflects the relative proportions of their frequencies.

  5. type = "fillleft": Icons are randomly filled from the left.

  6. type = "filltop": Icons are randomly filled from the top.

  7. type = "scatter": Icons are randomly scattered into the plot.

ident.order

The order in which icon identities (i.e, hi, mi, fa, and cr) are plotted. Default: ident.order = c("hi", "mi", "fa", "cr")

icon.colors

Specifies the icon colors as a vector.

icon.types

Specifies the appearance of the icons as a vector. Accepts values from 1 to 25 (see ?points).

icon.border.col

Specifies the border color of icons (if applicable).

icon.border.lwd

Specifies the border width of icons (if applicable).

transparency

Specifies the transparency for overlapping icons (not type "array" and "shuffledarray").

icon.size

Manually specifies the size of the icons via cex (calculated dynamically by default.)

block.d

The distance between blocks (does not apply to "filleft", "filltop", and "scatter")

border.d

The distance of icons to the border.

Additional options allow to control the arrangement of the arrays (type "array" and "shuffledarray"):

block.size.row

specifies how many icons should be in each block row.

block.size.col

specifies how many icons should be in each block column.

nblocks.row

specifies how many blocks there are in each row. Is calculated by default.

nblocks.col

specifies how many blocks are there in each column. Is calculated by default.

fill.array

specifies how the blocks are filled into the array (Options "left" (default) and "top").

fill.blocks

specifies how icons within blocks are filled (Options: fill.blocks = "rowwise" (default) and fill.blocks = "colwise")

show.accu

Option for showing current accuracy metrics accu in the plot. Default: show.accu = TRUE.

w.acc

Weigthing parameter w used to compute weighted accuracy w.acc in comp_accu. Default: w.acc = .50.

Various other options allow the customization of text labels and colors:

title.lbl

Text label to set plot title.

type.lbls

Text labels for icon types to be displayed in legend.

cex.lbl

Scaling factor for the size of text labels (e.g., on axes, legend, margin text). Default: cex.lbl = .85.

Details

If probabilities are provided, a new list of natural frequencies freq is computed by comp_freq. By contrast, if no probabilities are provided, the values currently contained in freq are used. By default, comp_freq rounds frequencies to nearest integers to avoid decimal values in freq.

See Also

Other visualization functions: plot.riskyr, plot_curve, plot_fnet, plot_mosaic, plot_plane, plot_tree

Examples

Run this code
# NOT RUN {
# ways to work:
plot_icons()  # => plots icon array for default population (with default type = "array")
plot_icons(type = "shuffledarray")  # => icon array with shuffled IDs

plot_icons(type = "mosaic",    N = 1000)  # => areas as in mosaic plot
plot_icons(type = "fillequal", N = 1000)  # => areas of equal size (density reflects probability)
plot_icons(type = "fillleft",  N = 1000)  # => icons filled from left to right (in columns)
plot_icons(type = "filltop",   N = 1000)  # => icons filled from top to bottom (in rows)

plot_icons(icon.types = c(21,23,24,23),
               block.size.row = 5, block.size.col = 5, #nblocks.row = 2, nblocks.col = 2,
               block.d = 0.5, border.d = 0.9)
plot_icons(type = "scatter",   N = 1000)  # => icons randomly scattered.

# some variants:
plot_icons(N = 800, type = "array", icon.types = c(21,22,23,24),
           block.d = 0.5, border.d = 0.5)

plot_icons(N = 1250, sens = 0.9, spec = 0.9, prev = 0.9,
               icon.types = c(21,23,24,23),
               block.size.row = 10, block.size.col = 5,
               nblocks.row = 5, nblocks.col = 5,
               block.d = 0.8,
               border.d = 0.2,
               fill.array = "top")
plot_icons(N = 800, type = "shuffledarray", icon.types = c(21,23,24,22),
           block.d = 0.5, border.d = 0.5)

plot_icons(N = 800, type = "shuffledarray", icon.types = c(21,23,24,22),
           icon.border.col = grey(.33, .99), icon.border.lwd = 3)

plot_icons(N = 800, type = "fillequal", icon.types = c(21,22,22,21),
           icon.border.lwd = .5, cex = 3)


# }

Run the code above in your browser using DataLab