diff options
author | Johannes Ranke <jranke@uni-bremen.de> | 2017-03-24 15:24:04 +0100 |
---|---|---|
committer | Johannes Ranke <jranke@uni-bremen.de> | 2017-03-24 15:24:04 +0100 |
commit | 22c11d5dbc118881f9cfd7c9c2ac9711295a0f16 (patch) | |
tree | a2c88069b82633027047c60bf656e53c4b561182 /R/drcfit.R | |
parent | b05f8438729e8070f4e0cbbf628bbbcbbe3f1a7a (diff) |
Suppress error messages in dr(c)fit, maintenance
- Checking examples fails if error messages in dr(c)fit stemming from
failed fits are printed
- Delete trailing whitespace
- Update packaging
Diffstat (limited to 'R/drcfit.R')
-rw-r--r-- | R/drcfit.R | 31 |
1 files changed, 18 insertions, 13 deletions
@@ -14,7 +14,7 @@ drcfit <- function(data, chooseone=TRUE, # model result was appended rsubstance <- array() # the substance names in the results rndl <- vector() # number of dose levels - rn <- vector() # mean number of replicates + 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 @@ -69,7 +69,8 @@ drcfit <- function(data, chooseone=TRUE, active <- FALSE if (linlogit) { - m <- try(drm(response ~ dose, data = tmp, fct = BC.4(fixed = c(NA, 1, NA, NA)))) + m <- try(drm(response ~ dose, data = tmp, fct = BC.4(fixed = c(NA, 1, NA, NA))), + silent = TRUE) if (chooseone==FALSE || fit==FALSE) { if (!inherits(m, "try-error")) { fit <- TRUE @@ -90,10 +91,11 @@ drcfit <- function(data, chooseone=TRUE, a[[ri]] <- coef(m)[[2]] b[[ri]] <- coef(m)[[1]] c[[ri]] <- coef(m)[[3]] - ED50 <- try(ED(m, 50, interval = "delta", + ED50 <- try(ED(m, 50, interval = "delta", lower = lowestdose / 10, upper = highestdose * 10, - display = FALSE)) + display = FALSE), + silent = TRUE) if (!inherits(ED50, "try-error")) { logED50[[ri]] <- log10(ED50["1:50", "Estimate"]) logED50low[[ri]] <- log10(ED50["1:50", "Lower"]) @@ -101,14 +103,14 @@ drcfit <- function(data, chooseone=TRUE, if (logED50[[ri]] > rlhd[[ri]]) { mtype[[ri]] <- "no fit" } - } + } } } } if (probit) { - m <- try(drm(response ~ dose, data = tmp, - fct = LN.2())) + m <- try(drm(response ~ dose, data = tmp, + fct = LN.2()), silent = TRUE) if (chooseone==FALSE || fit==FALSE) { if (!inherits(m, "try-error")) { fit <- TRUE @@ -142,7 +144,8 @@ drcfit <- function(data, chooseone=TRUE, } if (logit) { - m <- try(drm(response ~ dose, data = tmp, fct = LL.2())) + m <- try(drm(response ~ dose, data = tmp, fct = LL.2()), + silent = TRUE) if (chooseone==FALSE || fit==FALSE) { if (!inherits(m, "try-error")) { fit <- TRUE @@ -179,7 +182,8 @@ drcfit <- function(data, chooseone=TRUE, } if (weibull) { - m <- try(drm(response ~ dose, data = tmp, fct = W1.2())) + m <- try(drm(response ~ dose, data = tmp, fct = W1.2()), + silent = TRUE) if (chooseone==FALSE || fit==FALSE) { if (!inherits(m, "try-error")) { fit <- TRUE @@ -252,7 +256,7 @@ drcfit <- function(data, chooseone=TRUE, } } - results <- data.frame(rsubstance, rndl, rn, rlld, rlhd, mtype, + results <- data.frame(rsubstance, rndl, rn, rlld, rlhd, mtype, logED50, logED50low, logED50high, runit, sigma, a, b) lower_level_percent = paste(100 * (1 - level)/2, "%", sep = "") upper_level_percent = paste(100 * (1 + level)/2, "%", sep = "") @@ -275,12 +279,13 @@ drcfit <- function(data, chooseone=TRUE, mtype <- as.character(results[row.i, "mtype"]) if (mtype %in% c("probit", "logit", "weibull", "linlogit")) { for (EDi in EDx) { - EDx.drc = try(ED(m, EDi, interval = "delta", display = FALSE, level = level)) + EDx.drc = try(ED(m, EDi, interval = "delta", display = FALSE, level = level), + silent = TRUE) if (!inherits(EDx.drc, "try-error")) { results[row.i, paste0("EDx", EDi)] <- EDx.drc[paste0("1:", EDi), "Estimate"] - results[row.i, paste0("EDx", EDi, " ", lower_level_percent)] <- EDx.drc[paste0("1:", EDi), + results[row.i, paste0("EDx", EDi, " ", lower_level_percent)] <- EDx.drc[paste0("1:", EDi), "Lower"] - results[row.i, paste0("EDx", EDi, " ", upper_level_percent)] <- EDx.drc[paste0("1:", EDi), + results[row.i, paste0("EDx", EDi, " ", upper_level_percent)] <- EDx.drc[paste0("1:", EDi), "Upper"] } } |