File: bootpar.R

package info (click to toggle)
r-cran-foreach 1.3.0-2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 628 kB
  • ctags: 4
  • sloc: sh: 76; makefile: 1
file content (20 lines) | stat: -rw-r--r-- 548 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# foreach version based on for-loop version from Wikipedia
# http://en.wikipedia.org/wiki/Bootstrapping_(statistics)
library(foreach)
data(iris)
x <- iris[which(iris[,5] != "setosa"), c(1,5)]
trials <- 10000
opts <- list(chunkSize=150)

print(system.time(
r <- foreach(icount(trials), .combine=cbind,
             .options.nws=opts, .options.smp=opts) %dopar% {
  ind <- sample(100, 100, replace=TRUE)
  result1 <- glm(x[ind,2]~x[ind,1], family=binomial(logit))
  coefficients(result1)
}
))

hist(r[1,], breaks=40)
dev.new()
hist(r[2,], breaks=40)