From d89badab8c65995b6381418989ffed965fa9d626 Mon Sep 17 00:00:00 2001 From: ranke Date: Fri, 25 Nov 2005 16:45:01 +0000 Subject: Fixed the check for dose == 0 in drplot() and improved the model naming in the result table given by drfit() git-svn-id: http://kriemhild.uft.uni-bremen.de/svn/drfit@47 d1b72e20-2ee0-0310-a1c4-ad5adbbefcdc --- R/drfit.R | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'R') diff --git a/R/drfit.R b/R/drfit.R index 9c99b1a..d8631e6 100644 --- a/R/drfit.R +++ b/R/drfit.R @@ -117,15 +117,16 @@ drfit <- function(data, startlogEC50 = NA, chooseone=TRUE, runit[[ri]] <- unit rlld[[ri]] <- log10(lowestdose) rlhd[[ri]] <- log10(highestdose) - mtype[[ri]] <- "linlogit" logEC50[[ri]] <- coef(m)[["logEC50"]] if (logEC50[[ri]] > rlhd[[ri]]) { + mtype[[ri]] <- "no fit" logEC50[[ri]] <- NA stderrlogEC50[[ri]] <- NA a[[ri]] <- NA b[[ri]] <- NA c[[ri]] <- NA } else { + mtype[[ri]] <- "linlogit" stderrlogEC50[[ri]] <- s$parameters["logEC50","Std. Error"] a[[ri]] <- coef(m)[["logEC50"]] b[[ri]] <- coef(m)[["b"]] @@ -150,15 +151,16 @@ drfit <- function(data, startlogEC50 = NA, chooseone=TRUE, runit[[ri]] <- unit rlld[[ri]] <- log10(lowestdose) rlhd[[ri]] <- log10(highestdose) - mtype[[ri]] <- "probit" logEC50[[ri]] <- coef(m)[["logEC50"]] c[[ri]] <- NA if (logEC50[[ri]] > rlhd[[ri]]) { + mtype[[ri]] <- "no fit" logEC50[[ri]] <- NA stderrlogEC50[[ri]] <- NA a[[ri]] <- NA b[[ri]] <- NA } else { + mtype[[ri]] <- "probit" stderrlogEC50[[ri]] <- s$parameters["logEC50","Std. Error"] a[[ri]] <- coef(m)[["logEC50"]] b[[ri]] <- coef(m)[["scale"]] @@ -183,16 +185,17 @@ drfit <- function(data, startlogEC50 = NA, chooseone=TRUE, runit[[ri]] <- unit rlld[[ri]] <- log10(lowestdose) rlhd[[ri]] <- log10(highestdose) - mtype[[ri]] <- "logit" logEC50[[ri]] <- a[[ri]] <- coef(m)[["logEC50"]] b[[ri]] <- coef(m)[["scale"]] c[[ri]] <- NA if (logEC50[[ri]] > rlhd[[ri]]) { + mtype[[ri]] <- "no fit" logEC50[[ri]] <- NA stderrlogEC50[[ri]] <- NA a[[ri]] <- NA b[[ri]] <- NA } else { + mtype[[ri]] <- "logit" stderrlogEC50[[ri]] <- s$parameters["logEC50","Std. Error"] } } @@ -215,7 +218,6 @@ drfit <- function(data, startlogEC50 = NA, chooseone=TRUE, runit[[ri]] <- unit rlld[[ri]] <- log10(lowestdose) rlhd[[ri]] <- log10(highestdose) - mtype[[ri]] <- "weibull" a[[ri]] <- coef(m)[["location"]] b[[ri]] <- coef(m)[["shape"]] sqrdev <- function(logdose) { @@ -224,11 +226,13 @@ drfit <- function(data, startlogEC50 = NA, chooseone=TRUE, logEC50[[ri]] <- nlm(sqrdev,startlogEC50[[i]])$estimate c[[ri]] <- NA if (logEC50[[ri]] > rlhd[[ri]]) { + mtype[[ri]] <- "no fit" logEC50[[ri]] <- NA stderrlogEC50[[ri]] <- NA a[[ri]] <- NA b[[ri]] <- NA } else { + mtype[[ri]] <- "weibull" stderrlogEC50[[ri]] <- NA } } @@ -280,6 +284,7 @@ drplot <- function(drresults, data, dtype = "std", alpha = 0.95, pointsize = 12, colors = 1:8, devoff=T, lpos="topright") { + # Check if all data have the same unit unitlevels <- levels(as.factor(drresults$unit)) if (length(unitlevels) == 1) { unit <- unitlevels @@ -289,7 +294,7 @@ drplot <- function(drresults, data, dtype = "std", alpha = 0.95, # Get the plot limits on the x-axis (log of the dose) if(is.data.frame(data)) { - if (min(data$dose == 0)) { + if (min(data$dose) == 0) { cat("At least one of the dose levels is 0 - this is not a valid dose.") } else { lld <- log10(min(data$dose)) @@ -336,6 +341,7 @@ drplot <- function(drresults, data, dtype = "std", alpha = 0.95, # Plot the data either as raw data or as error bars if(is.data.frame(data)) { splitted <- split(data,data$substance) + # n is the index for the dose-response curves n <- 0 if (bw) colors <- rep("black",length(dsubstances)) # Loop over the substances in the data -- cgit v1.2.1