I have the dataframe below
d50<-structure(list(VOT = c("VOT 0", "VOT 5", "VOT 10", "VOT 15",
"VOT 20", "VOT -10", "VOT -20", "VOT -30", "VOT -40", "VOT -50",
"VOT -60", "VOT 0", "VOT 5", "VOT 10", "VOT 15", "VOT 20", "VOT -10",
"VOT -20", "VOT -30", "VOT -40", "VOT -50", "VOT -60", "VOT 0",
"VOT 5", "VOT 10", "VOT 15", "VOT 20", "VOT -10", "VOT -20",
"VOT -30", "VOT -40", "VOT -50", "VOT -60", "VOT 0", "VOT 5",
"VOT 10", "VOT 15", "VOT 20", "VOT -10", "VOT -20", "VOT -30",
"VOT -40", "VOT -50", "VOT -60", "VOT 0", "VOT 5", "VOT 10",
"VOT 15", "VOT 20", "VOT -10"), response = c(0, 0, 0, 0, 0, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1)), row.names = c(NA, -50L), class = c("tbl_df", "tbl", "data.frame"
))
and Im trying to
library(drc)
# Fit a logistic regression model to the data
fit <- drm(response ~ VOT, data = d50, fct = LL.4())
but I get:
Error in optim(startVec, opfct, hessian = TRUE, method = optMethod, control = list(maxit = maxIt, :
non-finite value supplied by optim
Error in drmOpt(opfct, opdfct1, startVecSc, optMethod, constrained, warnVal, :
Convergence failed
You have at least two problems:
It is possible to fit a logistic regression to this:
I would think that the right model would be
but I haven't gotten that working yet either ... (posting anyway in case it gives you or someone else a head start).
drmcan't handle the wide scale of your data. It expects to get dosages on an original scale and fits a log-logistic model. I don't know whatVOTis, but its range is from -60 to +20, which if we exponentiate gives a very wide range (and we can't log-transform, since it includes negative numbers).I can get
drmto fit withLL.2()by scaling, i.e. makingexp(VOT/10)the response variable. This almost matches the results of a binomial GLM, but not quite, and the binomial GLM is better; if I re-fit using starting conditions derived from the GLM fit, I get an improveddrmfit. (Code below.)If you're interested in estimating the ED50 from this data set, I have some bad news - even with the better fit, the estimate is 26.4 with a standard error of 42, hence your 95% confidence range is approximately (-58, 110) ... although plotting the GLM fit (see below) suggests this is an overestimate, and the lower bound on the ED50 may be near 15 ...
Plot
glmfit with extended range: