aboutsummaryrefslogtreecommitdiff
path: root/R/drcfit.R
diff options
context:
space:
mode:
Diffstat (limited to 'R/drcfit.R')
-rw-r--r--R/drcfit.R34
1 files changed, 18 insertions, 16 deletions
diff --git a/R/drcfit.R b/R/drcfit.R
index ff9e6bb..8c52f6d 100644
--- a/R/drcfit.R
+++ b/R/drcfit.R
@@ -37,6 +37,9 @@ drcfit <- function(data, chooseone=TRUE,
unit <- ""
message("\n",i,": No data\n")
}
+ if (length(unit) == 0) {
+ unit <- NA
+ }
if (length(unit) > 1) {
message("More than one unit for substance ",i,", halting\n\n")
break
@@ -81,23 +84,24 @@ drcfit <- function(data, chooseone=TRUE,
runit[[ri]] <- unit
rlld[[ri]] <- log10(lowestdose)
rlhd[[ri]] <- log10(highestdose)
- ED50 <- try(ED(m, 50, interval = "delta", display = FALSE))
+ logED50[[ri]] <- NA
+ logED50low[[ri]] <- NA
+ logED50high[[ri]] <- NA
+ a[[ri]] <- coef(m)[[2]]
+ b[[ri]] <- coef(m)[[1]]
+ c[[ri]] <- coef(m)[[3]]
+ ED50 <- try(ED(m, 50, interval = "delta",
+ lower = lowestdose / 10,
+ upper = highestdose * 10,
+ display = FALSE))
if (!inherits(ED50, "try-error")) {
logED50[[ri]] <- log10(ED50["1:50", "Estimate"])
logED50low[[ri]] <- log10(ED50["1:50", "Lower"])
logED50high[[ri]] <- log10(ED50["1:50", "Upper"])
if (logED50[[ri]] > rlhd[[ri]]) {
mtype[[ri]] <- "no fit"
- logED50[[ri]] <- NA
- logED50low[[ri]] <- NA
- logED50high[[ri]] <- NA
}
- } else {
- mtype[[ri]] <- "no ED50"
- }
- a[[ri]] <- coef(m)[[2]]
- b[[ri]] <- coef(m)[[1]]
- c[[ri]] <- coef(m)[[3]]
+ }
}
}
}
@@ -119,21 +123,19 @@ drcfit <- function(data, chooseone=TRUE,
rlld[[ri]] <- log10(lowestdose)
rlhd[[ri]] <- log10(highestdose)
logED50[[ri]] <- log10(coef(m)[[2]])
+ a[[ri]] <- coef(m)[[2]]
+ b[[ri]] <- coef(m)[[1]]
c[[ri]] <- NA
if (logED50[[ri]] > rlhd[[ri]]) {
mtype[[ri]] <- "no fit"
logED50[[ri]] <- NA
logED50low[[ri]] <- NA
logED50high[[ri]] <- NA
- a[[ri]] <- NA
- b[[ri]] <- NA
} else {
mtype[[ri]] <- "probit"
ED50 <- ED(m, 50, interval = "delta", display = FALSE)
logED50low[[ri]] <- log10(ED50["1:50", "Lower"])
logED50high[[ri]] <- log10(ED50["1:50", "Upper"])
- a[[ri]] <- coef(m)[[2]]
- b[[ri]] <- coef(m)[[1]]
}
}
}
@@ -155,6 +157,8 @@ drcfit <- function(data, chooseone=TRUE,
rlld[[ri]] <- log10(lowestdose)
rlhd[[ri]] <- log10(highestdose)
logED50[[ri]] <- log10(coef(m)[[2]])
+ a[[ri]] <- coef(m)[[2]]
+ b[[ri]] <- coef(m)[[1]]
c[[ri]] <- NA
if (logED50[[ri]] > rlhd[[ri]]) {
mtype[[ri]] <- "no fit"
@@ -168,8 +172,6 @@ drcfit <- function(data, chooseone=TRUE,
ED50 <- ED(m, 50, interval = "delta", display = FALSE)
logED50low[[ri]] <- log10(ED50["1:50", "Lower"])
logED50high[[ri]] <- log10(ED50["1:50", "Upper"])
- a[[ri]] <- coef(m)[[2]]
- b[[ri]] <- coef(m)[[1]]
}
}
}

Contact - Imprint