From c5f30593d42ecd9a21f799a4943709b1b73a1162 Mon Sep 17 00:00:00 2001 From: ranke Date: Tue, 2 Aug 2005 12:15:15 +0000 Subject: drplot: Added the pointsize argument for postscript and png graphs drfit: Changed the order of fits in the case of chooseone=TRUE git-svn-id: http://kriemhild.uft.uni-bremen.de/svn/drfit@34 d1b72e20-2ee0-0310-a1c4-ad5adbbefcdc --- R/drfit.R | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) (limited to 'R') diff --git a/R/drfit.R b/R/drfit.R index d8ad40b..f2480d2 100644 --- a/R/drfit.R +++ b/R/drfit.R @@ -126,11 +126,11 @@ drfit <- function(data, startlogEC50 = NA, chooseone=TRUE, } } - if (weibull && + if (probit && length(subset(allWrong,allWrong == i))==0) { - m <- try(nls(response ~ pweibull(-log10(dose)+location,shape), - data=tmp, - start=list(location=startlogEC50[[i]],shape=s0))) + m <- try(nls(response ~ pnorm(-log10(dose),-logEC50,scale), + data=tmp, + start=list(logEC50=startlogEC50[[i]],scale=1))) if (chooseone==FALSE || fit==FALSE) { if (!inherits(m, "try-error")) { fit <- TRUE @@ -142,13 +142,8 @@ 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) { - (0.5 - pweibull( - logdose + a[[ri]], b[[ri]]))^2 - } - logEC50[[ri]] <- nlm(sqrdev,startlogEC50[[i]])$estimate + mtype[[ri]] <- "probit" + logEC50[[ri]] <- coef(m)[["logEC50"]] c[[ri]] <- NA if (logEC50[[ri]] > rlhd[[ri]]) { logEC50[[ri]] <- NA @@ -156,7 +151,9 @@ drfit <- function(data, startlogEC50 = NA, chooseone=TRUE, a[[ri]] <- NA b[[ri]] <- NA } else { - stderrlogEC50[[ri]] <- NA + stderrlogEC50[[ri]] <- s$parameters["logEC50","Std. Error"] + a[[ri]] <- coef(m)[["logEC50"]] + b[[ri]] <- coef(m)[["scale"]] } } } @@ -194,11 +191,11 @@ drfit <- function(data, startlogEC50 = NA, chooseone=TRUE, } } - if (probit && + if (weibull && length(subset(allWrong,allWrong == i))==0) { - m <- try(nls(response ~ pnorm(-log10(dose),-logEC50,scale), - data=tmp, - start=list(logEC50=startlogEC50[[i]],scale=1))) + m <- try(nls(response ~ pweibull(-log10(dose)+location,shape), + data=tmp, + start=list(location=startlogEC50[[i]],shape=s0))) if (chooseone==FALSE || fit==FALSE) { if (!inherits(m, "try-error")) { fit <- TRUE @@ -210,8 +207,13 @@ 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"]] + mtype[[ri]] <- "weibull" + a[[ri]] <- coef(m)[["location"]] + b[[ri]] <- coef(m)[["shape"]] + sqrdev <- function(logdose) { + (0.5 - pweibull( - logdose + a[[ri]], b[[ri]]))^2 + } + logEC50[[ri]] <- nlm(sqrdev,startlogEC50[[i]])$estimate c[[ri]] <- NA if (logEC50[[ri]] > rlhd[[ri]]) { logEC50[[ri]] <- NA @@ -219,14 +221,13 @@ drfit <- function(data, startlogEC50 = NA, chooseone=TRUE, a[[ri]] <- NA b[[ri]] <- NA } else { - stderrlogEC50[[ri]] <- s$parameters["logEC50","Std. Error"] - a[[ri]] <- coef(m)[["logEC50"]] - b[[ri]] <- coef(m)[["scale"]] + stderrlogEC50[[ri]] <- NA } } } } + } else { inactive <- TRUE } -- cgit v1.2.1