Search code examples
rdrc

Non finite value error when trying to create dose-response curve with drm?


I have the dataframe below

enter image description here

and I'm trying to

library(drc)
AR231 <- drm(AR231 ~ conc, data = dosage, fct = LL.4()); summary(AR231)

but I get the error message

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

Why?? What does this mean?

I'm hoping to build a dose-response curve using my data and receive EC50 values for each subject tested. If anybody could give me some pointers, that would be greatly appreciated.

Below I've attached a similar data frame with the expected results that I'm looking for. Not my work- Not sure what I'm doing wrong.

dosage <- read.csv("MoyingDay1.csv")
> dosage
    conc X0G51 X0G63 X0G101 X0G117 X0G191 X0G214 X0G229 X0G402 X0G421 X5G51 X5G63 X5G101 X5G117 X5G191 X5G214 X5G229
1    0.0   4.1   4.3    4.1    4.2    4.1    4.0    4.6    4.3    4.5   4.0   3.9    4.0    3.9    4.2    3.8    4.2
2    0.0   4.0   4.2    4.0    4.1    4.3    4.1    4.4    4.2    4.6   3.9   4.1    4.0    4.0    4.2    3.8    4.2
3    0.0   4.1   4.3    4.1    4.2    4.1    4.1    4.4    4.2    4.6   4.1   4.1    4.0    3.8    4.0    3.9    4.2
4   12.5   2.3   2.4    2.6    3.0    2.9    3.6    4.0    2.4    2.7   2.4   1.9    3.0    3.2    2.7    3.7    3.5
5   12.5   2.4   2.3    3.0    3.0    2.7    3.6    3.9    2.9    2.8   2.4   2.4    2.8    2.9    2.6    3.7    3.5
6   12.5   2.5   2.6    2.9    2.6    2.8    3.5    3.7    2.5    2.9   2.5   2.3    2.9    3.1    2.8    3.7    3.6
7   25.0   1.4   1.4    2.1    2.5    1.9    3.1    3.2    2.1    1.4   1.5   1.6    2.4    2.3    2.5    3.5    3.1
8   25.0   1.7   1.6    2.1    2.2    1.9    3.1    3.3    2.0    2.0   1.4   1.6    2.4    2.3    2.4    3.3    3.1
9   25.0   1.8   1.6    2.4    2.4    1.6    3.2    3.4    2.1    1.6   1.4   1.6    2.4    2.3    2.5    3.4    3.0
10  50.0   0.4   0.9    1.8    1.8    1.0    2.3    2.7    0.9    1.0   0.9   0.7    1.2    1.4    1.4    2.4    2.2
11  50.0   0.4   0.9    1.7    1.4    1.1    2.3    2.6    0.4    0.9   1.1   0.9    1.4    1.6    1.5    2.2    2.3
12  50.0   0.9   0.9    2.3    1.7    0.9    2.4    2.6    0.6    0.8   0.6   1.0    1.5    1.4    1.6    2.2    2.2
13 100.0   0.2   0.1    0.3    0.3    0.2    0.5    1.4    0.4    0.5   0.7   0.2    0.3    0.3    0.3    1.1    1.1
14 100.0   0.2   0.2    0.3    0.3    0.2    0.7    1.0    0.2    0.4   0.7   0.2    0.3    0.3    0.3    0.9    0.0
15 100.0   0.2   0.2    0.3    0.3    0.2    0.7    1.2    0.4    0.6   0.6   0.2    0.4    0.3    0.3    1.1    1.0
16 200.0   0.1   0.1    0.2    0.3    0.3    0.7    0.4    0.2    0.2   0.2   0.2    0.2    0.4    0.3    0.3    0.6
17 200.0   0.1   0.2    0.3    0.3    0.2    0.7    0.7    0.2    0.2   0.3   0.2    0.4    0.3    0.3    0.4    0.6
18 200.0   0.2   0.1    0.3    0.3    0.2    0.5    0.6    0.2    0.2   0.3   0.2    0.3    0.3    0.3    0.5    0.3
   X5G251 X5G402 X5G421 X10G51 X10G63 X10G101 X10G117 X10G191 X10G214 X10G229 X10G251 X10G402 X10G421
1     4.3    4.3    4.3    4.1    3.8     4.0     4.0     4.1     4.3     3.9     4.0     4.2     3.6
2     4.3    4.3    4.4    4.3    3.6     3.9     4.0     4.2     4.2     4.1     4.0     4.1     4.1
3     4.3    4.3    4.4    4.2    4.0     4.1     4.0     4.1     4.2     4.3     4.0     4.0     4.0
4     2.4    2.9    2.9    2.6    2.9     2.9     2.9     2.6     3.7     3.9     2.8     2.7     2.9
5     2.4    3.1    2.8    3.0    2.6     2.9     2.9     2.4     3.7     3.4     2.8     2.9     2.6
6     2.5    2.9    2.8    3.3    2.8     2.9     2.9     2.9     3.6     3.6     3.0     2.9     2.7
7     1.9    2.4    1.9    1.5    2.4     2.5     2.4     2.0     3.3     3.0     1.6     1.2     1.6
8     2.0    1.9    1.9    2.0    2.2     2.5     2.5     2.2     3.3     2.9     1.6     1.4     1.6
9     1.9    2.1    1.9    2.3    2.6     2.5     2.4     1.5     3.4     3.0     1.6     1.4     1.7
10    1.0    1.0    0.9    1.1    1.2     1.4     1.6     0.8     2.3     2.2     0.7     0.9     0.9
11    0.9    1.0    0.9    1.0    1.2     1.4     1.6     0.7     2.4     2.6     1.0     0.7     0.7
12    0.9    0.9    1.1    0.9    1.4     1.6     1.6     0.9     2.5     2.3     0.9     0.9     0.9
13    0.5    0.3    0.5    0.5    0.7     0.3     0.1     0.0     0.5     0.4     0.0     0.0     0.4
14    0.4    0.3    0.5    0.6    0.5     0.3     0.3     0.0     0.4     0.4     0.0     0.0     0.6
15    0.3    0.5    0.5    0.5    0.7     0.3     0.3     0.0     0.5     0.3     0.0     0.0     0.5
16    0.0    0.0    0.5    0.1    0.4     0.1     0.3     0.0     0.5     0.4     0.0     0.0     0.2
17    0.0    0.1    0.3    0.1    0.3     0.3     0.4     0.0     0.5     0.4     0.0     0.0     0.2
18    0.1    0.1    0.2    0.1    0.3     0.4     0.2     0.0     0.6     0.5     0.0     0.0     0.2

> X0G51.m1 <- drm(X0G51 ~ conc, data = dosage, fct = LL.4()); summary(X0G51.m1)

Model fitted: Log-logistic (ED50 as parameter) (4 parms)

Parameter estimates:

               Estimate Std. Error   t-value p-value
b:(Intercept)  1.428520   0.176953  8.072886   0.000
c:(Intercept) -0.064166   0.129133 -0.496900   0.627
d:(Intercept)  4.055672   0.103229 39.288115   0.000
e:(Intercept) 17.429622   1.355903 12.854626   0.000

Solution

  • I think your main problem is probably that the NoSHAM values in your concentration column are making the whole column into a non-numeric variable.

    Replicating the first two columns of your data frame:

    dosage <-data.frame(
        conc = c(10^(rep(c(-3:2), each = 3)), rep ("NoSHAM", 3)),
        AR231 = c(0.98, 0.89, 0.96, 0.84, 0.82, 0.85, 0.32, 0.4, 0.37, 0, 0.4, rep(0,10)))
    

    This works fine if I use as.numeric() to convert concentrations back to numeric (the "NoSHAM" values will get converted to NA, and those observations will then be automatically dropped):

    fit <- drm(AR231 ~ as.numeric(conc), data = dosage, fct = LL.4()); summary(fit)
    

    You should check and make sure that your conc variable is currently of type character, not factor: if it is factor you must use as.numeric(as.character(conc)) (rather than just as.numeric(conc)) to convert back, otherwise weird/wrong stuff will happen.

    Model fitted: Log-logistic (ED50 as parameter) (4 parms)
    
    Parameter estimates:
    
                   Estimate Std. Error t-value   p-value    
    b:(Intercept) 0.8547343  0.2589153  3.3012   0.00525 ** 
    c:(Intercept) 0.0073816  0.0443913  0.1663   0.87031    
    d:(Intercept) 0.9861405  0.0761105 12.9567 3.473e-09 ***
    e:(Intercept) 0.0596658  0.0201075  2.9673   0.01019 *  
    ---
    Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
    
    Residual standard error:
    
     0.09528289 (14 degrees of freedom)
    

    (The "14 degrees of freedom" reported is consistent with the "NoSHAM" rows being dropped: the data set has 21 rows, minus 3 NoSHAM rows = 18. The df listed is the residual df, which is (18 observations - 4 model parameters) = 14.)