plot.minmax: plot.minmax

Usage Arguments Examples

Usage

1
plot.minmax(My, X, Y)

Arguments

My
X
Y

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
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (My, X, Y) 
{
    mymat <- My$M
    my.y <- My$y
    my.y.val <- as.numeric(strsplit(trim(my.y), " ")[[1]][3])
    my.y.pct <- ecdf(Y)(my.y.val)
    var.nms <- rownames(mymat)
    act.vars <- apply(mymat, 1, function(x) {
        !all(abs(x) == Inf)
    })
    max.y <- sum(act.vars) + 1
    rbw <- rainbow(n = nrow(mymat))
    node.index <- 1:length(Y)
    for (i in 1:nrow(mymat)) {
        node.index <- intersect(node.index, which(X[, i] > mymat[i, 
            1] & X[, i] <= mymat[i, 2]))
    }
    H <- hist(ecdf(Y)(Y[node.index]), breaks = seq(0, 1, by = 0.1), 
        plot = FALSE)
    scale.factor <- max.y/max(H$density)
    plot(NA, xlim = c(0, 1), ylim = c(0, max.y), ylab = "", xlab = "Percentile", 
        main = paste("Mean =", signif(my.y.val, 2), ", n =", 
            length(node.index)), bty = "n", yaxt = "n")
    barplot(scale.factor * H$density, width = 0.1, col = rgb(0, 
        0, 0, 0.05), border = rgb(0, 0, 0, 0.1), add = TRUE, 
        space = 0, yaxt = "n")
    mu.Y <- mean(Y[node.index])
    print(mean(Y[node.index]))
    segments(ecdf(Y)(mu.Y), 0, ecdf(Y)(mu.Y), max.y, col = rgb(0, 
        0, 0, 0.5), lwd = 2)
    j <- 1
    for (i in which(act.vars)) {
        F.x <- ecdf(X[, var.nms[i]])
        lo <- ifelse(mymat[i, 1] == -Inf, 0, F.x(mymat[i, 1]))
        hi <- ifelse(mymat[i, 2] == Inf, 1, F.x(mymat[i, 2]))
        polygon(c(lo, lo, hi, hi), c(j - 0.5, j + 0.5, j + 0.5, 
            j - 0.5), col = makeTransparent(rbw[i], 0.5), border = NA)
        text(mean(c(lo, hi)), j, rownames(mymat)[i])
        j <- j + 1
    }
  }

jwolfson/visparty documentation built on May 20, 2019, 6:27 a.m.