Search code examples
rdrc

Curve fit error non-finite value supplied by optim


I am trying to create some dose response curves for an experiment I did. IFor one of the DRC's I am getting the following error:

Error in optim(startVec, opfct, hessian = TRUE, method = optMethod, control = list(maxit = maxIt,  : 
  non-finite finite-difference value [4]
Error in drmOpt(opfct, opdfct1, startVecSc, optMethod, constrained, warnVal,  : 
  Convergence failed

this is the dataset for this example:

test <-data.frame(value1 = c(30000, 7500, 1875, 469, 117, 29.3, 7.32, 1.83, 0.458),value2= c(0.817, 0.773, 0.811, 0.861, 0.833, 0.904, 0.903, 0.875, 1.07))

and with the following code to reproduce the error.

drm(data = test, value2 ~ value1,fct=LL.4(names = c("Slope","LowerLimit","UpperLimit", "ED50")))

what is going wrong here? Thanks alot in advance


Solution

  • Add some points using approx interpolation to get better starting values from fm0.

    xy <- with(test, approx(value1, value2))
    
    Names <- c("Slope", "LowerLimit", "UpperLimit", "ED50")
    fm0 <- drm(y ~ x, data = xy, fct = LL.4(names = Names))
    fm <- drm(value2 ~ value1, data = test, fct = LL.4(names = Names), start = coef(fm0))
    fm
    

    giving

    A 'drc' model.
    
    Call:
    drm(formula = value2 ~ value1, data = test, fct = LL.4(names = Names),     start = coef(fm0))
    
    Coefficients:
         Slope:(Intercept)  LowerLimit:(Intercept)  UpperLimit:(Intercept)  
                    0.5580                  0.8134                  1.1787  
          ED50:(Intercept)  
                    0.8140  
    

    The graph looks like this

    plot(fm)
    

    sreenshot