-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.r
42 lines (31 loc) · 1.18 KB
/
main.r
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
# code for the statistical analysis of dose respose bottle assay
# [email protected] 25th nov, 2014
source("logistic_regression_and_gof_functions.r")
bioAssay <- read.csv(file="bioassayIrma.txt", header=TRUE)
dfBioAssay <- MakeBinomialPairs(bioAssay)
glmModel <- glm(dead~logDose, data=dfBioAssay, family=binomial)
summary(glmModel)
intercept=glmModel$coef[[1]]
slope=glmModel$coef[[2]]
ld50 <- PredictX(.5,intercept, slope)
ld90 <- PredictX(.9,intercept, slope)
ld99 <- PredictX(.99,intercept, slope)
# Doing the Hosmer-Lemeshow test
Hosmerlem(dfBioAssay$dead, fitted(glmModel),9)
#le Cessie – van Houwelingen – Copas – Hosmer unweighted sum of squares test
#for global goodness of fit
lrmModel <- lrm(dead ~ logDose, data=dfBioAssay, linear.predictors=TRUE,
method="lrm.fit", x=TRUE, y=TRUE, model = TRUE)
residuals(lrmModel, type = "gof")
# lets do Confidence intervals for ld50
p <- 0.5
ci <- ConfInt(ld50, p, glmModel)
c(estimatedx = ld50, ci=ci)
# lets do Confidence intervals for ld90
p <- 0.9
ci <- ConfInt(ld90, p, glmModel)
c(estimatedx = ld90, ci=ci)
# lets do Confidence intervals for ld99
p <- 0.99
ci <- ConfInt(ld99, p, glmModel)
c(estimatedx = ld99, ci=ci)