From 19cf20f2f0cadb16df89e9585b5bf22902fc5cc5 Mon Sep 17 00:00:00 2001 From: ranke Date: Thu, 22 Dec 2005 15:57:03 +0000 Subject: The calculation of dose-response curves in drfit was wrong if the number of dose levels was different from 9. Now, n is calculated as the rounded mean number of response data per dose level. The number of dose levels ndl is additionally reported. The test was removed because it didn't work properly. git-svn-id: http://kriemhild.uft.uni-bremen.de/svn/drfit@52 d1b72e20-2ee0-0310-a1c4-ad5adbbefcdc --- R/drfit.R | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'R') 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 } -- cgit v1.2.1