# NOT RUN {
x <- matrix(rnorm(10000 * 100), ncol = 100)
y <- 1 * (0.25 * x[,1] - 0.25 * x[,3] > rnorm(10000))
system.time(gl1 <- glm.fit(x, y, family = binomial()))
system.time(gf1 <- fastglm(x, y, family = binomial()))
system.time(gf2 <- fastglm(x, y, family = binomial(), method = 1))
system.time(gf3 <- fastglm(x, y, family = binomial(), method = 2))
system.time(gf4 <- fastglm(x, y, family = binomial(), method = 3))
max(abs(coef(gl1) - gf1$coef))
max(abs(coef(gl1) - gf2$coef))
max(abs(coef(gl1) - gf3$coef))
max(abs(coef(gl1) - gf4$coef))
# }
# NOT RUN {
nrows <- 50000
ncols <- 50
bkFile <- "bigmat2.bk"
descFile <- "bigmatk2.desc"
bigmat <- filebacked.big.matrix(nrow=nrows, ncol=ncols, type="double",
backingfile=bkFile, backingpath=".",
descriptorfile=descFile,
dimnames=c(NULL,NULL))
for (i in 1:ncols) bigmat[,i] = rnorm(nrows)*i
y <- 1*(rnorm(nrows) + bigmat[,1] > 0)
system.time(gfb1 <- fastglm(bigmat, y, family = binomial(), method = 3))
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab