The R Project SVN R

Rev

Rev 57296 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 57296 Rev 67806
Line 1... Line 1...
1
## reproducible examples.
1
## reproducible examples.
2
 
2
 
3
library(parallel)
3
library(parallel)
4
 
4
 
5
library(boot)
5
if(require(boot)) {
6
run1 <- function(...) {
6
    run1 <- function(...) {
7
   library(boot)
7
        library(boot)
8
   cd4.rg <- function(data, mle) MASS::mvrnorm(nrow(data), mle$m, mle$v)
8
        cd4.rg <- function(data, mle) MASS::mvrnorm(nrow(data), mle$m, mle$v)
9
   cd4.mle <- list(m = colMeans(cd4), v = var(cd4))
9
        cd4.mle <- list(m = colMeans(cd4), v = var(cd4))
10
   boot(cd4, corr, R = 500, sim = "parametric",
10
        boot(cd4, corr, R = 500, sim = "parametric",
11
        ran.gen = cd4.rg, mle = cd4.mle)
11
             ran.gen = cd4.rg, mle = cd4.mle)
-
 
12
    }
-
 
13
    cl <- makeCluster(mc <- 2)
-
 
14
    clusterSetRNGStream(cl, 123)
-
 
15
    cd4.boot <- do.call(c, parLapply(cl, seq_len(mc), run1))
-
 
16
    print(boot.ci(cd4.boot,  type = c("norm", "basic", "perc"),
-
 
17
                  conf = 0.9, h = atanh, hinv = tanh))
-
 
18
    stopCluster(cl)
12
}
19
}
13
cl <- makeCluster(mc <- 2)
-
 
14
clusterSetRNGStream(cl, 123)
-
 
15
cd4.boot <- do.call(c, parLapply(cl, seq_len(mc), run1))
-
 
16
boot.ci(cd4.boot,  type = c("norm", "basic", "perc"),
-
 
17
        conf = 0.9, h = atanh, hinv = tanh)
-
 
18
stopCluster(cl)
-
 
19
 
20