Re: [R] Failure in predicting parameters

2021-03-18 Thread Luigi Marongiu
Thank you, I'll try it! On Thu, Mar 18, 2021 at 9:46 PM Rui Barradas wrote: > > Hello, > > Maybe a bit late but there is a contributed package [1] for quantitative > PCR fitting non-linear models with the Levenberg-Marquardt algorithm. > > estim and vector R below are your model and your fitted v

Re: [R] Failure in predicting parameters

2021-03-18 Thread Rui Barradas
Hello, Maybe a bit late but there is a contributed package [1] for quantitative PCR fitting non-linear models with the Levenberg-Marquardt algorithm. estim and vector R below are your model and your fitted values vector. The RMSE of this fit is smaller than your model's. Isn't this simpler

Re: [R] Failure in predicting parameters

2021-03-17 Thread Luigi Marongiu
It worked. I re-written the equation as: ``` rutledge_param <- function(p, x, y) ( (p$M / ( 1 + exp(-(x-p$m)/p$s)) ) + p$B ) - y ``` and used Desmos to estimate the slope, so: ``` estim <- nls.lm(par = list(m = halfCycle, s = 2.77, M = MaxFluo, B = high[1]), fn = rutledge_param, x = 1:4

Re: [R] Failure in predicting parameters

2021-03-16 Thread Luigi Marongiu
Just an update: I tried with desmos and the fitting looks good. Desmos calculated the parameters as: Fmax = 11839.8 Chalf = 27.1102 (with matches with my estimate of 27 cycles) k = 2.76798 Fb = -138.864 I forced R to accept the right parameters using a single named list and re-written the formula (

Re: [R] Failure in predicting parameters

2021-03-14 Thread Luigi Marongiu
Hello, the negative data comes from the machine. Probably I should use raw data directly, although in the paper this requirement is not reported. The p$x was a typo. Now I corrected it and I got this error: ``` > rutledge_param <- function(p, x, y) ((p$M / (1 + exp(-1*(x-p$m)/p$s))) + p$B) > - y

Re: [R] Failure in predicting parameters

2021-03-14 Thread Bill Dunlap
> rutledge_param <- function(p, x, y) ((p$M / (1 + exp(-1*(p$x-p$m)/p$s))) + > p$B) - y Did you mean that p$x to be just x? As is, this returns numeric(0) for the p that nls.lm gives it because p$x is NULL and NULL-aNumber is numeric(). -Bill On Sun, Mar 14, 2021 at 9:46 AM Luigi Marongiu wro

Re: [R] Failure in predicting parameters

2021-03-14 Thread Bert Gunter
Do the negative values in your data make any sense? Note that if Fb must be >0, Fc must be also. But I have *not* examined your code/equations in detail, so feel free to ignore if this is irrelevant. Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along

[R] Failure in predicting parameters

2021-03-14 Thread Luigi Marongiu
Hello, I would like to use the Rutledge equation (https://pubmed.ncbi.nlm.nih.gov/15601990/) to model PCR data. The equation is: Fc = Fmax / (1+exp(-(C-Chalf)/k)) + Fb I defined the equation and another that subtracts the values from the expectations. I used minpack.lm to get the parameters, but I