guess_quadratic_parameters is too simplistic
Closed this issue · 3 comments
I have at least one dataset (from March 17th) which yields a guess of kd=250 using guess_quadratic_parameters()
, whereas the real value is 26. It seems to be a problem for nls()
, which cannot fit properly with a first guess too far from the actual value.
Error from nls()
:
NaNs produced
Error in numericDeriv(form[[3L]], names(ind), env) : Missing value or an infinity produced when evaluating the model
7. numericDeriv(form[[3L]], names(ind), env)
6. getRHS()
5. assign("rhs", getRHS(), envir = thisEnv)
4. assign("resid", .swts * (lhs - assign("rhs", getRHS(), envir = thisEnv)), envir = thisEnv)
3. (function (newPars) { setPars(newPars) assign("resid", .swts * (lhs - assign("rhs", getRHS(), envir = thisEnv)), ...
2. stats::nls(formula = equation, data = fret_corrected, start = parameters) at fit_binding_model.R#44
1. fit_binding_model(dat_Mar17_corr, donor_concentration = 10, params_Mar17)
I don't know how to solve this problem. There is no easier guess for kd than taking the concentration at half-maximum FRET signal. Maybe the call to nls()
can be modified to use a more robust algorithm? Maybe we need to use nls2
instead?
Practical examples for using nls2
:
I am actually not sure it is a good idea to make the fit function more robust.
Getting an error because of a very bad guess of the initial value of kd
forces the user to think about their data. On the other hand, having a fit function that "works" no matter what and will always output a value can lead some users to believe completely meaningless values.
I just noticed that three equations share these same parameters. For now, this function will be enough.