padpadpadpad / rTPC

R package to help fit Thermal Performance Curves
https://padpadpadpad.github.io/rTPC/
22 stars 3 forks source link

Coeficient depends on order in function #50

Closed mrebolleda closed 1 year ago

mrebolleda commented 1 year ago

Hi, First of all great package!!! I was fitting a few functions and getting the coefficients, but I noticed that in the end, even though the fit looked right, the parameters were very odd. My topt was in a range between 0 and 1.2 and my rmax had a mean of 30. I switched the order I gave the parameters to the multstart function and it all worked well.

That is:

nls_multstart(mean_r~gaussian_1987(temp = tmp, topt, rmax, a),
                                                     data = d,
                                                     iter = 500,
                                                     start_lower = start_vals - 5,
                                                     start_upper = start_vals + 5,
                                                     lower = low_lims,
                                                     upper = upper_lims,
                                                     supp_errors = 'Y')

gives weird things and it is not the same as

nls_multstart(mean_r~gaussian_1987(temp = tmp, rmax, topt, a),
                                                     data = d,
                                                     iter = 500,
                                                     start_lower = start_vals - 5,
                                                     start_upper = start_vals + 5,
                                                     lower = low_lims,
                                                     upper = upper_lims,
                                                     supp_errors = 'Y')
padpadpadpad commented 1 year ago

Hi

It is because the order of the parameters matters in the model functon. You can work out the order at which they should be inputted by looking at the help page for each function.

For gaussian_1987, it is, gaussian_1987(temp, rmax, topt, a).