## example adpted from Venables and Ripley (2002, pp. 190-2.):
# In R:
ldose <- rep(0:5, 2)
numdead <- c(1, 4, 9, 13, 18, 20, 0, 2, 6, 10, 12, 16)
sex <- factor(rep(c("M", "F"), c(6, 6)))
data <- data.frame(sex, ldose)
data <- Reduce(rbind,
lapply(1:length(numdead),
function(j) rbind(cbind(alive=1,data[j,])[rep(1,numdead[j]),],
cbind(alive=0,data[j,])[rep(1,20-numdead[j]),])))
rownames(data) <- NULL
r_model <- glm( alive ~ sex + ldose - 1, family=binomial(), data=data)
# Now in SciDB:
data_scidb <- as.scidb(data)
str(data_scidb)
scidb_model <- glm_scidb( alive ~ sex + ldose - 1, family=binomial(), data=data_scidb)
# New data for prediction:
ld <- seq(0,5,0.1)
newdata <- as.scidb(data.frame(ldose=ld, sex=rep("M",length(ld))))
head(newdata)
pred_scidb = predict(scidb_model, newdata=newdata, type="response")
head(pred_scidb)
require("graphics")
plot(c(1,32), c(0,1), type = "n", xlab = "dose",
ylab = "prob", log = "x")
text(2^ldose, numdead/20, as.character(sex))
lines(2^ld, pred_scidb[],lwd=2,col=4)
Run the code above in your browser using DataLab