From 4d60b8ed0236af9227db79bf062f2381e683cc4a Mon Sep 17 00:00:00 2001 From: ranke Date: Mon, 22 May 2006 18:59:14 +0000 Subject: Make the logit model work again, by setting a sensible starting value for the scale argument. Now all models get separate starting arguments, with hopefully effective default values. git-svn-id: http://kriemhild.uft.uni-bremen.de/svn/drfit@80 d1b72e20-2ee0-0310-a1c4-ad5adbbefcdc --- DESCRIPTION | 4 ++-- R/drfit.R | 17 +++++++++-------- inst/doc/index.html | 2 +- man/drfit-package.Rd | 6 ++++-- man/drfit.Rd | 18 ++++++++++++------ tests/XY.R | 2 +- tests/XY.Rout.save | 13 +++++++++---- 7 files changed, 38 insertions(+), 24 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 7182eda..ee6d4ff 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: drfit -Version: 0.05-78 -Date: 2006-05-08 +Version: 0.05-80 +Date: 2006-05-22 Title: Dose-response data evaluation Author: Johannes Ranke Maintainer: Johannes Ranke diff --git a/R/drfit.R b/R/drfit.R index e3d9d3b..e993c61 100644 --- a/R/drfit.R +++ b/R/drfit.R @@ -2,7 +2,8 @@ drfit <- function(data, startlogED50 = NA, chooseone=TRUE, probit = TRUE, logit = FALSE, weibull = FALSE, linlogit = FALSE, level = 0.95, linlogitWrong = NA, allWrong = NA, - s0 = 0.5, b0 = 2, f0 = 0) + ps0 = 1, ls0 = 0.5, ws0 = 0.5, + b0 = 2, f0 = 0) { require(MASS) if(!is.null(data$ok)) data <- subset(data,ok!="no fit") # Don't use data @@ -114,7 +115,7 @@ drfit <- function(data, startlogED50 = NA, chooseone=TRUE, length(subset(allWrong,allWrong == i))==0) { m <- try(nls(response ~ pnorm(-log10(dose),-logED50,scale), data=tmp, - start=list(logED50=startlogED50[[i]],scale=1))) + start=list(logED50=startlogED50[[i]],scale=ps0))) if (chooseone==FALSE || fit==FALSE) { if (!inherits(m, "try-error")) { fit <- TRUE @@ -157,7 +158,7 @@ drfit <- function(data, startlogED50 = NA, chooseone=TRUE, length(subset(allWrong,allWrong == i))==0) { m <- try(nls(response ~ plogis(-log10(dose),-logED50,scale), data=tmp, - start=list(logED50=startlogED50[[i]],scale=1))) + start=list(logED50=startlogED50[[i]],scale=ls0))) if (chooseone==FALSE || fit==FALSE) { if (!inherits(m, "try-error")) { fit <- TRUE @@ -199,7 +200,7 @@ drfit <- function(data, startlogED50 = NA, chooseone=TRUE, length(subset(allWrong,allWrong == i))==0) { m <- try(nls(response ~ pweibull(-log10(dose)+location,shape), data=tmp, - start=list(location=startlogED50[[i]],shape=s0))) + start=list(location=startlogED50[[i]],shape=ws0))) if (chooseone==FALSE || fit==FALSE) { if (!inherits(m, "try-error")) { fit <- TRUE @@ -273,10 +274,10 @@ drfit <- function(data, startlogED50 = NA, chooseone=TRUE, } results <- data.frame(rsubstance, rndl, rn, rlld, rlhd, mtype, logED50, logED50low, logED50high, runit, sigma, a, b) - names(results) <- c("Substance","ndl","n","lld","lhd","mtype","logED50", - paste(100*(1-level)/2,"%",sep=""), - paste(100*(1+level)/2,"%",sep=""), - "unit","sigma","a","b") + names(results) <- c("Substance","ndl","n","lld","lhd","mtype","logED50", + paste(100*(1-level)/2,"%",sep=""), + paste(100*(1+level)/2,"%",sep=""), + "unit","sigma","a","b") if (linlogit) { results$c <- c diff --git a/inst/doc/index.html b/inst/doc/index.html index d6cedf5..6d27f48 100644 --- a/inst/doc/index.html +++ b/inst/doc/index.html @@ -8,7 +8,7 @@

User Guide for package drfit

drfit-Rnews.pdf:
-
Preliminary version of an Introductory article on drfit
+
Introductory article on drfit, published in R News
diff --git a/man/drfit-package.Rd b/man/drfit-package.Rd index 43334ff..3064787 100644 --- a/man/drfit-package.Rd +++ b/man/drfit-package.Rd @@ -8,7 +8,9 @@ Dose-response data evaluation See \url{../DESCRIPTION} } \details{ -There is a preliminary version of an introductory article located in \url{../doc/drfit-Rnews.pdf}. +There is an introductory article located in \url{../doc/drfit-Rnews.pdf}, +which will be published in the R News special edition on the use +of R for chemists. } \author{ Author and Maintainer: Johannes Ranke @@ -28,5 +30,5 @@ the advantage of my package is its user-friendliness. data(antifoul) r <- drfit(antifoul) format(r,digits=2) -\dontrun{drplot(r,antifoul,overlay=TRUE,bw=FALSE)} +drplot(r,antifoul,overlay=TRUE,bw=FALSE) } diff --git a/man/drfit.Rd b/man/drfit.Rd index 453c0f8..6b98f36 100644 --- a/man/drfit.Rd +++ b/man/drfit.Rd @@ -8,7 +8,7 @@ \usage{ drfit(data, startlogED50 = NA, chooseone = TRUE, probit = TRUE, logit = FALSE, weibull = FALSE, linlogit = FALSE, level = 0.95, linlogitWrong = NA, - allWrong = NA, s0 = 0.5, b0 = 2, f0 = 0) + allWrong = NA, ps0 = 1, ls0 = 0.5, ws0 = 0.5, b0 = 2, f0 = 0) } \arguments{ \item{data}{ @@ -56,12 +56,18 @@ logit, weibull, and the first model that produces a valid fit is used. If FALSE, all models that are set to TRUE and that can be fitted will be reported.} - \item{s0}{ - If the weibull model is fitted, s0 gives the possibility to adjust the - starting value for the shape parameter of \code{\link{pweibull}}.} + \item{ps0}{ + If the probit model is fitted, \code{ps0} gives the possibility to adjust + the starting value for the scale parameter of \code{\link{pnorm}}.} + \item{ls0}{ + If the logit model is fitted, \code{ls0} gives the possibility to adjust + the starting value for the scale parameter of \code{\link{plogis}}.} + \item{ws0}{ + If the weibull model is fitted, \code{ws0} gives the possibility to adjust + the starting value for the shape parameter of \code{\link{pweibull}}.} \item{b0,f0}{ - If the linearlogistic model is fitted, b0 and f0 give the possibility to - adjust the starting values for the parameters b and f.} + If the linearlogistic model is fitted, \code{b0} and \code{f0} give the + possibility to adjust the starting values for the parameters b and f.} } \value{ \item{results}{ diff --git a/tests/XY.R b/tests/XY.R index e295be4..7e3ecb2 100644 --- a/tests/XY.R +++ b/tests/XY.R @@ -1,4 +1,4 @@ library(drfit) data(XY) -rXY <- drfit(XY) +rXY <- drfit(XY,logit=TRUE,weibull=TRUE,chooseone=FALSE) rXY diff --git a/tests/XY.Rout.save b/tests/XY.Rout.save index d8098ae..9da519f 100644 --- a/tests/XY.Rout.save +++ b/tests/XY.Rout.save @@ -1,6 +1,6 @@ R : Copyright 2006, The R Foundation for Statistical Computing -Version 2.3.0 (2006-04-24) +Version 2.3.1 beta (2006-05-18 r38119) ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. @@ -19,21 +19,26 @@ Type 'q()' to quit R. Loading required package: MASS Loading required package: RODBC > data(XY) -> rXY <- drfit(XY) +> rXY <- drfit(XY,logit=TRUE,weibull=TRUE,chooseone=FALSE) Control: Fitting data... Substance X: Fitting data... Waiting for profiling to be done... +Waiting for profiling to be done... Substance Y: Fitting data... > rXY Substance ndl n lld lhd mtype logED50 2.5% 97.5% unit 1 Control 1 6 -Inf -Inf inactive NA NA NA mg/L 2 Substance X 4 12 1 3 probit 2.161905 2.105861 2.214359 mg/L -3 Substance Y 4 12 1 3 active NA NA NA mg/L +3 Substance X 4 12 1 3 logit 2.160948 2.112152 2.207912 mg/L +4 Substance X 4 12 1 3 weibull 2.174365 NA NA mg/L +5 Substance Y 4 12 1 3 active NA NA NA mg/L sigma a b 1 NA NA NA 2 0.04131746 2.161905 0.5061306 -3 NA NA NA +3 0.03758732 2.160948 0.2991424 +4 0.05723870 3.009640 2.0362368 +5 NA NA NA > -- cgit v1.2.1