aboutsummaryrefslogtreecommitdiff
path: root/R
diff options
context:
space:
mode:
Diffstat (limited to 'R')
-rw-r--r--R/drfit.R19
1 files changed, 14 insertions, 5 deletions
diff --git a/R/drfit.R b/R/drfit.R
index e74667d..9184dc9 100644
--- a/R/drfit.R
+++ b/R/drfit.R
@@ -57,7 +57,8 @@ drfit <- function(data, startlogED50 = NA, chooseone=TRUE,
# rix is used later to check if any
# model result was appended
rsubstance <- array() # the substance names in the results
- rn <- vector() # number of dose-response curves
+ rndl <- vector() # number of dose levels
+ rn <- vector() # mean number of replicates in each dose level
runit <- vector() # vector of units for each result row
rlhd <- rlld <- vector() # highest and lowest doses tested
mtype <- array() # the modeltypes
@@ -81,14 +82,17 @@ drfit <- function(data, startlogED50 = NA, chooseone=TRUE,
cat("More than one unit for substance ",i,", halting\n\n",sep="")
break
}
- n <- round(length(tmp$response)/9)
if (length(tmp$response) == 0) {
nodata = TRUE
} else {
nodata = FALSE
}
rix <- ri
- if (!nodata) {
+ if (nodata) {
+ n <- ndl <- 0
+ } else {
+ ndl <- length(levels(factor(tmp$dose)))
+ n <- round(length(tmp$response)/ndl)
if (is.na(startlogED50[i])){
w <- 1/abs(tmp$response - 0.3)
startlogED50[[i]] <- sum(w * log10(tmp$dose))/sum(w)
@@ -113,6 +117,7 @@ drfit <- function(data, startlogED50 = NA, chooseone=TRUE,
s <- summary(m)
sigma[[ri]] <- s$sigma
rsubstance[[ri]] <- i
+ rndl[[ri]] <- ndl
rn[[ri]] <- n
runit[[ri]] <- unit
rlld[[ri]] <- log10(lowestdose)
@@ -147,6 +152,7 @@ drfit <- function(data, startlogED50 = NA, chooseone=TRUE,
s <- summary(m)
sigma[[ri]] <- s$sigma
rsubstance[[ri]] <- i
+ rndl[[ri]] <- ndl
rn[[ri]] <- n
runit[[ri]] <- unit
rlld[[ri]] <- log10(lowestdose)
@@ -181,6 +187,7 @@ drfit <- function(data, startlogED50 = NA, chooseone=TRUE,
s <- summary(m)
sigma[[ri]] <- s$sigma
rsubstance[[ri]] <- i
+ rndl[[ri]] <- ndl
rn[[ri]] <- n
runit[[ri]] <- unit
rlld[[ri]] <- log10(lowestdose)
@@ -214,6 +221,7 @@ drfit <- function(data, startlogED50 = NA, chooseone=TRUE,
s <- summary(m)
sigma[[ri]] <- s$sigma
rsubstance[[ri]] <- i
+ rndl[[ri]] <- ndl
rn[[ri]] <- n
runit[[ri]] <- unit
rlld[[ri]] <- log10(lowestdose)
@@ -247,6 +255,7 @@ drfit <- function(data, startlogED50 = NA, chooseone=TRUE,
if (ri == rix) { # if no entry was appended for this substance
ri <- ri + 1
rsubstance[[ri]] <- i
+ rndl[[ri]] <- ndl
rn[[ri]] <- n
if (nodata) {
rlld[[ri]] <- rlhd[[i]] <- NA
@@ -270,8 +279,8 @@ drfit <- function(data, startlogED50 = NA, chooseone=TRUE,
c[[ri]] <- NA
}
}
- results <- data.frame(rsubstance, rn, rlld, rlhd, mtype, logED50, stderrlogED50, runit, sigma, a, b)
- names(results) <- c("Substance","n","lld","lhd","mtype","logED50","std","unit","sigma","a","b")
+ results <- data.frame(rsubstance, rndl, rn, rlld, rlhd, mtype, logED50, stderrlogED50, runit, sigma, a, b)
+ names(results) <- c("Substance","ndl","n","lld","lhd","mtype","logED50","std","unit","sigma","a","b")
if (linlogit) {
results$c <- c
}

Contact - Imprint