R-Lum / Luminescence

Development of the R package 'Luminescence'
http://r-lum.github.io/Luminescence/
GNU General Public License v3.0
15 stars 7 forks source link

fit_DoseResponseCurve(): function get stuck somehow #381

Open RLumSK opened 18 hours ago

RLumSK commented 18 hours ago

Describe the bug The function does not proceed any further and get stuck.

Please add a minimalistic reproducible example

library(Luminescence)

df <- structure(list(Dose = c(0, 5, 10, 20), LxTx = c(0.233270744277096, 
0.0551573585592141, 0.115689013035382, 0.224497656801695), LxTx.Error = c(0.00905041641275636, 
0.00410088704173231, 0.005624752955861, 0.00791604672464381)), class = "data.frame", row.names = c(NA, 
-4L))
fit_DoseResponseCurve(df, fit.method = "EXP+LIN")

Expected behaviour Should work and works, for instance for `fit.method = "EXP"). I've tested all other fitting methods and apparently they work.

Session info Latest build of master.

Update 1

It seems to be again related to the port algorithm and these lines:

https://github.com/R-Lum/Luminescence/blob/c27a3afde7bee0db4295f170894e21cc707ba182/R/fit_DoseResponseCurve.R#L855-L865

Update 2

It seems to happen in cases where the number of parameters is larger than the number of data. I've replaced the nls() call by minpack.lm::nlsLM() (https://github.com/R-Lum/Luminescence/commit/6000c14168f0ad6a49f3a0d74c0dca1ae73f155f). This should do for the time being. However, it is not really a fix and the function needs a careful look.

RLumSK commented 14 hours ago

@mcol Please have an additional look at it, I realised again that this function needs certainly some extra care.