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 --- DESCRIPTION | 4 ++-- R/drfit.R | 19 ++++++++++++++----- man/drfit.Rd | 5 +++-- tests/01drfit.R | 4 ---- tests/01drfit.Rout.save | 33 --------------------------------- 5 files changed, 19 insertions(+), 46 deletions(-) delete mode 100644 tests/01drfit.R delete mode 100644 tests/01drfit.Rout.save diff --git a/DESCRIPTION b/DESCRIPTION index 07bf47a..2ff9517 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: drfit -Version: 0.04-51 -Date: 2005-12-21 +Version: 0.04-52 +Date: 2005-12-22 Title: Dose-response data evaluation Author: Johannes Ranke Maintainer: Johannes Ranke 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 } diff --git a/man/drfit.Rd b/man/drfit.Rd index abb135a..ee477b5 100644 --- a/man/drfit.Rd +++ b/man/drfit.Rd @@ -70,8 +70,9 @@ Every successful fit is reported in one line. Parameters of the fitted curves are only reported if the fitted ED50 is not higher than the highest dose. - \code{n} is the number of dose-response curves in the raw data (repetitions - in each point), \code{lld} is the decadic logarithm of the lowest dose and + \code{ndl} is the number of dose levels in the raw data, \code{n} is the + rounded mean of the number of replicates at each dose level in the raw + data, \code{lld} is the decadic logarithm of the lowest dose and \code{lhd} is the decadic logarithm of the highest dose. For the "linlogit", "logit" and "probit" models, the parameter \code{a} that is reported coincides with the logED50, i.e the logED50 is diff --git a/tests/01drfit.R b/tests/01drfit.R deleted file mode 100644 index 7e775fe..0000000 --- a/tests/01drfit.R +++ /dev/null @@ -1,4 +0,0 @@ -library(drfit) -data(antifoul) -r <- drfit(antifoul) -r diff --git a/tests/01drfit.Rout.save b/tests/01drfit.Rout.save deleted file mode 100644 index c04e428..0000000 --- a/tests/01drfit.Rout.save +++ /dev/null @@ -1,33 +0,0 @@ - -R : Copyright 2005, The R Foundation for Statistical Computing -Version 2.2.1 (2005-12-20 r36812) -ISBN 3-900051-07-0 - -R ist freie Software und kommt OHNE JEGLICHE GARANTIE. -Sie sind eingeladen, es unter bestimmten Bedingungen weiter zu verbreiten. -Tippen Sie 'license()' or 'licence()' für Details dazu. - -R ist ein Gemeinschaftsprojekt mit vielen Beitragenden. -Tippen Sie 'contributors()' für mehr Information und 'citation()', -um zu erfahren, wie R oder R packages in Publikationen zitiert werden können. - -Tippen Sie 'demo()' für einige Demos, 'help()' für on-line Hilfe, oder -'help.start()' für eine HTML Browserschnittstelle zur Hilfe. -Tippen Sie 'q()', um R zu verlassen. - -> library(drfit) -Lade nötiges Paket: RODBC -> data(antifoul) -> r <- drfit(antifoul) - -TBT: Fitting data... - -Zn Pyrithion: Fitting data... -> r - Substance n lld lhd mtype logEC50 std unit sigma -1 TBT 15 -2.709271 2.39794 probit -0.1643560 0.05349217 µM 0.1928611 -2 Zn Pyrithion 9 -2.107210 2.00000 probit -0.3979222 0.05393693 µM 0.2286560 - a b -1 -0.1643560 0.6763882 -2 -0.3979222 0.4169632 -> -- cgit v1.2.1