smcorcom:

Usage Arguments Examples

Usage

1
smcorcom(x1, y1, x2, y2, nboot = 200, pts = NA, plotit = TRUE, SEED = TRUE, varfun = pbvar, xout = TRUE, outfun = out, ...)

Arguments

x1
y1
x2
y2
nboot
pts
plotit
SEED
varfun
xout
outfun
...

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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
##---- 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 (x1, y1, x2, y2, nboot = 200, pts = NA, plotit = TRUE, 
    SEED = TRUE, varfun = pbvar, xout = TRUE, outfun = out, ...) 
{
    if (xout) {
        flag <- outfun(x1, ...)$keep
        x1 <- x1[flag]
        y1 <- y1[flag]
    }
    m <- elimna(cbind(x2, y2))
    x2 <- m[, 1]
    y2 <- m[, 2]
    if (xout) {
        flag <- outfun(x2, ...)$keep
        x2 <- x2[flag]
        y2 <- y2[flag]
    }
    if (SEED) 
        set.seed(2)
    estmat1 = NA
    estmat2 = NA
    data1 <- matrix(sample(length(y1), size = length(y1) * nboot, 
        replace = TRUE), nrow = nboot)
    data2 <- matrix(sample(length(y2), size = length(y2) * nboot, 
        replace = TRUE), nrow = nboot)
    for (ib in 1:nboot) {
        estmat1[ib] = lplot(x1[data1[ib, ]], y1[data1[ib, ]], 
            plotit = FALSE, varfun = varfun)$Explanatory.power
        estmat2[ib] = lplot(x2[data2[ib, ]], y2[data2[ib, ]], 
            varfun = varfun, plotit = FALSE)$Explanatory.power
    }
    dif <- (estmat1 < estmat2)
    dif0 <- (estmat1 == estmat2)
    p.value = mean(dif) + 0.5 * mean(dif0)
    p.value = 2 * min(c(p.value, 1 - p.value))
    n1 = length(y1)
    n2 = length(y2)
    p1 = 0.05
    p2 = 0.05
    temp1 = tsreg(c(100, 200), c(0.08, 0.05))$coef
    temp2 = tsreg(c(50, 100), c(0.21, 0.08))$coef
    temp3 = tsreg(c(30, 50), c(0.3, 0.21))$coef
    if (n1 < 200) 
        p1 = temp1[1] + temp1[2] * n1
    if (n1 < 100) 
        p1 = temp2[1] + temp2[2] * n1
    if (n1 < 50) 
        p1 = temp3[1] + temp3[2] * n1
    if (n1 < 30) 
        p1 = 0.3
    if (n2 < 200) 
        p2 = temp1[1] + temp1[2] * n2
    if (n2 < 100) 
        p2 = temp2[1] + temp2[2] * n2
    if (n2 < 50) 
        p2 = temp3[1] + temp3[2] * n2
    if (n2 < 30) 
        p2 = 0.3
    pcrit = (n2 * p1 + n1 * p2)/(n1 + n2)
    names(pcrit) = NULL
    if (plotit) 
        lplot2g(x1, y1, x2, y2)
    list(p.value = p.value, pcrit.05 = pcrit)
  }

musto101/wilcox_R documentation built on May 23, 2019, 10:52 a.m.