OddOneOut: OddOneOut

Description Usage Arguments Details Value Author(s) References Examples

Description

Gives a series of plot matrices and waits for the user to select the figure in the matrix that is off.

Usage

1
2
3
OddOneOut(goodplot = function(n, ...){plot(rnorm(n))}, 
badplot = function(n, ...){plot(runif(n))}, 
n = 100, runs = 10, nrows = 4, ncols = 4, training = TRUE, ...)

Arguments

goodplot

A function that shows n random variates from a “good” distribution. This is shown in all but one panels of the plot matrix.

badplot

A function that shows n random variates from a “good” distribution. This is shown in a random panel of the plot matrix.

n

Sample size.

runs

Number of plot matrices to generate.

nrows

Number of rows in the plot matrix.

ncols

Number of columns in the plot matrix.

training

Flag. if set to FALSE, the axis and labels are not shown in the panels.

...

Additional parameters, passed to the panel functions.

Details

This is the wrapper for the running exercises in Chapter 1 of (Sawitzki, 1989). In short, the task is to find the empirical power of some diagnostic plot, and later to estimate the empirical relative efficiency.

Value

A matrix with columns "oddrow", "oddcol", "selrow", "selcol" with the location of the odd sample, and the location of the user response.

Author(s)

G. Sawitzki <gsawitzki@users.r-forge.r-project.org>

References

Sawitzki, G.: Computational Statistics/Introduction to R. Chapman & Hall/CRC Press, Boca Raton (FL), 2009. ISBN: 978-1-4200-8678-2. http://sintro.r-forge.r-project.org/

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
## Not run: 




OddOneOut(runs=5, ncols=3)
OddOneOut(runs=5, ncols=3, training=FALSE)


## End(Not run)
## The function is currently defined as
function (goodplot = function(n, ...){plot(rnorm(n))}, 
	badplot = function(n, ...){plot(runif(n))}, 
	n = 100,  runs = 10, 
	nrows = 4, ncols = 4, training = TRUE, ...) 
{
cat("One plot is out. Please click on the odd panel in the plot. Abort with <esc>.\n")
cat("There are ",runs, "runs.\n")
    restab <- matrix(nrow = runs, ncol = 4)
    colnames(restab) <- c("oddrow", "oddcol", "selrow", "selcol")
    nrplots <- nrows * ncols
    for (i in 1:runs) {
        if (training) {
            oldpar <- par(mfrow = c(nrows, ncols))
        }
        else {
            oldpar <- par(mfrow = c(nrows, ncols), ann = FALSE, 
                xaxt = "n", yaxt = "n")
        }
        oddone <- sample(nrplots, 1) - 1
        for (j in 1:nrplots - 1) {
            row <- (j%/%ncols) + 1
            col <- (j%%ncols) + 1
            if (j == oddone) {
                badplot(n)
                badrow <- row
                badcol <- col
            }
            else goodplot(n)
        }
        par(mfrow = c(1, 1))
        plot.window(c(1, ncols), c(nrows, 1))
        locres <- locator(1)
        restab[i, ] <- c(badrow, badcol, round(locres$y), round(locres$x))
    }
    restab
  }

sintro documentation built on May 2, 2019, 5:26 p.m.