aboutsummaryrefslogtreecommitdiff
path: root/R
diff options
context:
space:
mode:
Diffstat (limited to 'R')
-rw-r--r--R/drfit.R43
1 files changed, 22 insertions, 21 deletions
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
}

Contact - Imprint