quickApproxPlan: quickApproxPlan

Description Usage Arguments Author(s) Examples

View source: R/ExLiebeRes.R

Description

an approximation for the looked after plan is generated without calculating the complete OC function. Instead only one point of the OC for the maximum value of sigma is evalutated and used as a surprisingly not so crude approximation. Obviously this gains great benefits in computing time. The result is used as an intermediate before searchin in detail using the complete OC

Usage

1
quickApproxPlan(p1, p2, alpha, beta, type = "LR", verbosity.level = 0)

Arguments

p1
p2
alpha
beta
type

is either "LR" (Leibermann/Reshnikov) or "BSK" (Bruhn-suhr/Krumbholz) indicating the type of plan that shall be generated.

verbosity.level

level verboseness: 0 no output only a plan structure returned, 1 generetad plan gets printed, 2 detailed information about the search process

Author(s)

Detlef Steuer, steuer@hsu-hh.de, http://fawn.hsu-hh.de/~steuer

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
69
70
71
72
73
74
75
##---- 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 (p1, p2, alpha, beta, type = "LR", verbosity.level = 0) 
{
    if (!((type == "LR") | (type == "BSK"))) 
        stop("Type must be either \"LR\" or \"BSK\"!")
    startplan <- singleSidedLRPlan(p1, p2, alpha, beta, verbosity.level = verbosity.level)
    nmin <- startplan$ntilde
    if (type == "LR") {
        kopt <- startplan$ktilde
    }
    if (type == "BSK") {
        kopt <- pnorm(startplan$ltilde/sqrt(startplan$ntilde))
    }
    kdiff <- 0.02 * kopt
    PlanGefunden <- FALSE
    direction <- "unknown"
    while (!PlanGefunden) {
        if (verbosity.level >= 2) 
            cat("Testing plan p1=", p1, " p2 = ", p2, " n = ", 
                nmin, " k =", kopt, "\n")
        Lminp1 <- quickOCIsop(p1, nmin, kopt, type = type)
        if (verbosity.level >= 2) 
            cat("L_min(p1) =", Lminp1)
        Lmaxp2 <- quickOCIsop(p2, nmin, kopt, type = type)
        if (verbosity.level >= 2) 
            cat(" L_max(p2) =", Lmaxp2, "\n")
        if ((Lminp1 >= 1 - alpha) & (Lmaxp2 <= beta)) {
            PlanGefunden <- TRUE
            plan <- list(ntilde = nmin, ltilde = NA, ktilde = kopt)
        }
        else if (!(Lminp1 >= 1 - alpha) & !(Lmaxp2 < beta)) {
            nmin <- nmin + 1
            direction <- "unknown"
            if (verbosity.level >= 2) 
                cat("increase n now: ", nmin, "\n")
        }
        else {
            if (Lminp1 < 1 - alpha) {
                if (direction == "unknown") 
                  direction <- "up"
                if (direction == "up") 
                  kopt <- kopt + kdiff
                else {
                  direction <- "up"
                  kdiff <- kdiff/2
                  kopt <- kopt + kdiff
                }
                if (verbosity.level >= 2) 
                  cat("new k_opt: ", kopt, "\n")
            }
            else {
                if (direction == "unknown") 
                  direction <- "down"
                if (direction == "down") 
                  kopt <- kopt - kdiff
                else {
                  direction <- "down"
                  kdiff <- kdiff/2
                  kopt <- kopt - kdiff
                }
                if (verbosity.level >= 2) 
                  cat("new k_opt: ", kopt, "\n")
            }
        }
    }
    if (verbosity.level >= 1) 
        cat("Fast approximative plan for p_1 = ", p1, " p_2 = ", 
            p2, " alpha = ", alpha, " beta = ", beta, ": n = ", 
            plan$ntilde, " k = ", plan$ktilde, "\n")
    return(plan)
  }

ExLiebeRes documentation built on May 2, 2019, 5:22 p.m.