0
$\begingroup$

I'm trying to reproduce a non-linear regression with various similar datasets. The original regressions were performed by sigmaplot with a modified morrison equation and estimates for parameters E=2,K=0.1,a=20.

Typically solved, the estimates are E=0.24,k=0.19,a=4.

I'm reproducing them in R using nls() with these params:

start=c(E=2,K=0.1,a=20)

Most of the regressions successfully complete and the results match closely those of sigmaplot, however some of the regressions fail with the error:

Error in nls(formula = ...
step factor 0.000488281 reduced below 'minFactor' of 0.000976562

To get these regressions to complete I have to increase the tolerance from the default 1e-05 to 1e-01. This affects the results of the other regressions. The problem regressions produced E=0.1,k=0.19,a=8

Sigmaplot completed the regressions with a tolerance of 1e-10.. if I try that with nls() not a single regression completes, they all present the same error.

I would like to make the nls() results as close to the sigmaplot results as possible, without failing the regression. What are the effects of raising the tolerance so much? is there another way I could attempt to diagnose the problem?

It's worth mentioning that using the Gauss-Newton algorithm with another software package (Statistica) does solve the regression and the results also match sigmaplot.

Here's an example trace, though I'm unsure how to read it

0.01686059 :  0.24 0.19 4.00
0.00805598 :  0.1877298 0.1946844 4.9112806
0.007518527 :  0.1695877 0.1956675 5.4388839
0.00719032 :  0.1545769 0.1962599 5.9792327
0.006858202 :  0.1421373 0.1965790 6.5239615
0.006440916 :  0.1318018 0.1967123 7.0650886
0.005930639 :  0.1231866 0.1967231 7.5953947
0.005353657 :  0.1159796 0.1966563 8.1086846
0.004746574 :  0.1099281 0.1965431 8.5999299
0.004494349 :  0.09972792 0.19626661 9.53068994
0.003657919 :   0.09259673  0.19595451 10.34599472
0.00298249 :   0.08252099  0.19538598 11.71954747
0.0009846386 :   0.07361911  0.19465785 13.42986353
0.0003378595 :   0.07411018  0.19464423 13.54705726
0.0003378492 :   0.07410485  0.19464299 13.54726343
0.009854093 :  0.24 0.19 4.00
0.008716119 :  0.1864634 0.2005271 4.9329848
0.00834241 :  0.1764615 0.2023560 5.2251765
0.00799378 :  0.1672293 0.2040194 5.5270667
0.007663479 :  0.1587056 0.2055335 5.8381789
0.00734641 :  0.1508333 0.2069125 6.1579808
0.007038855 :  0.1435598 0.2081697 6.4858860
0.006738227 :  0.1368367 0.2093169 6.8212571
0.006442853 :  0.1306196 0.2103646 7.1634095
0.006151782 :  0.1248676 0.2113226 7.5116149
0.005864623 :  0.1195432 0.2121993 7.8651069
0.005581409 :  0.1146122 0.2130026 8.2230871
0.005302474 :  0.1100433 0.2137393 8.5847300
0.005028361 :  0.1058077 0.2144157 8.9491899
0.004759742 :  0.1018790 0.2150373 9.3156092
0.004497351 :  0.09823341 0.21560917 9.68312249
0.004479617 :   0.09146404  0.21666246 10.41861532
0.004340651 :   0.08563871  0.21755453 11.15322816
0.004104982 :   0.08062153  0.21831220 11.87940670
0.003801579 :   0.07629616  0.21895758 12.59011348
0.003458628 :   0.07256327  0.21950885 13.27905565
0.003100557 :   0.06933821  0.21998097 13.94085438
0.00297072 :   0.06375928  0.22079172 15.20148490
0.002498298 :   0.05965429  0.22138066 16.32128995
0.002210852 :   0.05360403  0.22224198 18.24160742
0.001047117 :   0.04773992  0.22307086 20.74951037
0.0004387736 :   0.04781513  0.22307050 21.02550611
0.0004387723 :   0.04781597  0.22306990 21.02469434
Waiting for profiling to be done...
0.03596787 :   0.194643 13.547263
0.0003530948 :   0.1978191 15.2470495
0.0003522063 :   0.1974653 15.2474049
0.0003522063 :   0.197467 15.247379
0.002490067 :   0.2003082 16.9578154
0.0003955984 :   0.2003525 17.4415840
0.0003955984 :   0.2003509 17.4415921
0.003930259 :   0.2032361 19.6368715
0.0004679957 :   0.2032809 20.3633579
0.0004679957 :   0.2032787 20.3633726
0.00670296 :   0.206209 23.287596
0.0005693647 :   0.2062543 24.4489997
0.0005693647 :   0.2062514 24.4490238
0.01269327 :   0.2092277 28.5396302
0.0006996725 :   0.2092738 30.5710345
0.0006996724 :   0.2092697 30.5710738
0.02781167 :   0.2122928 36.7028617
0.0008588863 :   0.2123405 40.7647187
0.000858886 :   0.2123344 40.7647845
0.000858886 :   0.2123346 40.7647766
0.0366383 :   0.194643 13.547263
0.0003527573 :   0.1921402 12.1834017
0.0003522074 :   0.1918625 12.1836416
0.0003522074 :   0.1918614 12.1836603
0.001760713 :   0.1890631 10.8118341
0.0003956144 :   0.1891066 11.0593799
0.0003956144 :   0.189106 11.059375
0.001394486 :  0.1863499 9.9348085
0.0004680368 :   0.1863931 10.1213571
0.0004680368 :   0.1863929 10.1213505
0.001217861 :  0.183678 9.182726
0.0005694442 :  0.1837209 9.3264649
0.0005694442 :  0.183721 9.326457
0.001168366 :  0.1810464 8.5307696
0.0006998063 :  0.1810889 8.6439585
0.0006998063 :  0.1810892 8.6439495
0.001206994 :  0.1784539 7.9605192
0.0008590935 :  0.178496 8.051317
0.0008590935 :  0.1784965 8.0513070
0.0004282573 :   0.07410485 13.54726343
0.0004046287 :   0.07741263 12.94287223
0.0003610108 :   0.08076569 12.40825797
0.0003523552 :   0.08078717 12.42699849
0.0003523552 :   0.08078729 12.42697367
0.00100129 :   0.0874757 11.3056833
0.0003966258 :   0.08753661 11.46874014
0.0003966255 :   0.08753661 11.46861979
0.0009049989 :   0.09420575 10.52164996
0.00047066 :   0.09426814 10.64912267
0.0004706599 :   0.09426887 10.64894610
0.0008906163 :  0.1009214 9.8389842
0.0005744483 :  0.1009846 9.9398168
0.0005744482 :  0.100986 9.939604
0.0009437906 :  0.1076242 9.2386011
0.000707982 :  0.1076886 9.3196543
0.0007079819 :  0.1076906 9.3194163
0.0004256347 :   0.07410485 13.54726343
0.0003588664 :   0.07074914 14.16053820
0.0003545971 :   0.06909279 14.50638923
0.000352982 :   0.06746091 14.87184482
0.0003520157 :   0.06748073 14.87617672
0.0003520157 :   0.06748056 14.87621346
0.001261355 :   0.0607714 16.2221921
0.0003945627 :   0.06082957 16.50135033
0.0003945619 :   0.06082748 16.50165950
0.001770696 :   0.05409469 18.14657971
0.0004654832 :   0.05415229 18.53360912
0.0004654818 :   0.05414958 18.53414118
0.002621999 :   0.0473912 20.5911191
0.000564771 :   0.04744802 21.14885739
0.0005647681 :   0.04744444 21.14980944
0.004129769 :   0.04065794 23.79721776
0.0006924207 :   0.04071452 24.64172585
0.0006924142 :   0.04071008 24.64327395
0.0006924142 :   0.04071044 24.64305255
0.007036566 :   0.03389418 28.17896795
0.0008484294 :   0.03394955 29.54552253
0.0008484133 :   0.0339442 29.5479979
0.0008484133 :   0.03394458 29.54766318
0.0008484133 :   0.03394439 29.54783455
0.03422739 :  0.07410485 0.19464299
0.0003561122 :  0.08328429 0.19155058
0.0003559713 :  0.08326395 0.19157545
0.001919694 :  0.09146576 0.18882852
0.0004200807 :  0.09361941 0.18817256
0.0004200793 :  0.09361644 0.18818505
0.001608791 :  0.1018193 0.1854987
0.0005286835 :  0.1038402 0.1848971
0.0005286812 :  0.1038360 0.1849172
0.0005286812 :  0.1038360 0.1849174
0.001368156 :  0.1120443 0.1822929
0.0006778203 :  0.1138094 0.1817797
0.0006778174 :  0.1138044 0.1818043
0.0006778174 :  0.1138044 0.1818047
0.001324205 :  0.1220223 0.1792385
0.0008651483 :  0.1235802 0.1787958
0.0008651449 :  0.1235746 0.1788235
0.0008651449 :  0.1235745 0.1788241
0.03422739 :  0.07410485 0.19464299
0.0003496011 :  0.06677112 0.19711364
0.0003495088 :  0.06675668 0.19715051
0.002226678 :  0.0585532 0.1999499
0.0003801812 :  0.0600996 0.1994701
0.0003801805 :  0.06010011 0.19945767
0.002988073 :  0.05189237 0.20230247
0.0004292733 :  0.05351645 0.20179027
0.0004292721 :  0.05351721 0.20177288
0.0004292721 :  0.0535172 0.2017731
0.004433659 :  0.0453037 0.2046620
0.0004952602 :  0.04707952 0.20409259
0.0004952581 :  0.04708047 0.20406889
0.0004952581 :  0.04708045 0.20406922
0.006867877 :  0.03885952 0.20700185
0.0005765857 :  0.04080838 0.20636738
0.0005765822 :  0.04080946 0.20633632
0.0005765822 :  0.04080943 0.20633687
0.0112555 :  0.0325795 0.2093129
0.0006713118 :  0.03473459 0.20860083
0.0006713059 :  0.03473569 0.20856106
0.0006713059 :  0.03473566 0.20856190
0.01972438 :  0.02649537 0.21158060
0.0007770626 :  0.02889796 0.21077562
0.0007770524 :  0.02889897 0.21072537
0.0007770524 :  0.02889893 0.21072660
Joining, by = "parameter"
Waiting for profiling to be done...
0.1305003 :   0.2230699 21.0246943
0.000462952 :   0.2275676 26.6730942
0.0004573555 :   0.2266089 26.6740593
0.0004573554 :   0.2266156 26.6739216
0.03705432 :   0.2301889 32.3670351
0.0005136632 :   0.2302597 36.5262169
0.0005136627 :   0.2302508 36.5262487
0.1106036 :   0.233887 46.381242
0.0006076404 :   0.2339657 57.8042869
0.0006076387 :   0.2339489 57.8043686
0.0006076387 :   0.2339491 57.8043511
0.5131702 :   0.2376503 79.0989152
0.00073924 :    0.2377594 137.9527816
0.0007392258 :    0.2377105 137.9531525
0.0007392257 :    0.2377116 137.9529843
7.270925 :    0.2414788 218.2043818
0.0009085388 :     0.2413762 -359.3840174
0.0009083664 :     0.2415439 -359.3828830
0.0009083664 :     0.2415394 -359.3847425
280.2325 :     0.245374 -857.613366
0.001115023 :    0.2453797 -78.1138010
0.001115004 :    0.245436 -78.113818
0.001115003 :    0.2454342 -78.1139783
0.1333998 :   0.2230699 21.0246943
0.0004596076 :   0.2201944 17.3372759
0.0004573466 :   0.219588 17.337679
0.0004573466 :   0.2195858 17.3377375
0.0163258 :   0.2160738 13.6212602
0.0005136115 :   0.2161406 14.7238227
0.0005136113 :   0.2161363 14.7238124
0.00854195 :   0.2126842 12.1080039
0.0006075118 :   0.2127494 12.7860015
0.0006075117 :   0.2127469 12.7859884
0.005131482 :   0.2093533 10.8458092
0.0007389941 :   0.2094172 11.2911118
0.0007389941 :   0.2094158 11.2910970
0.003544006 :  0.2060792 9.7936687
0.000908006 :   0.2061419 10.1021735
0.000908006 :   0.2061415 10.1021575
0.002797863 :  0.20286 8.91064
0.001114497 :  0.2029217 9.1334294
0.001114497 :  0.2029219 9.1334127
0.0005610067 :   0.04781597 21.02469434
0.000548083 :   0.04882678 20.58058907
0.0005395189 :   0.05060298 19.83476299
0.0005375031 :   0.0532918 18.7978762
0.0004748822 :   0.05604189 17.89581480
0.0004577806 :   0.05608692 17.92518812
0.0004577806 :   0.05608754 17.92495842
0.007759422 :   0.0643296 14.8362845
0.0005155714 :   0.06441794 15.60796447
0.0005155575 :   0.06441598 15.60735882
0.004598502 :   0.07263363 13.32058835
0.0006121036 :   0.07272271 13.82443635
0.0006120975 :   0.07272281 13.82377224
0.003096796 :   0.08091966 12.06380133
0.0007473861 :   0.08100983 12.40861942
0.0007473832 :   0.08101172 12.40791336
0.002396363 :   0.08919193 11.01062150
0.0009214006 :   0.08928361 11.25666919
0.000921399 :   0.08928694 11.25596227
0.0005569626 :   0.04781597 21.02469434
0.0005378553 :   0.04370283 22.83214531
0.0005272625 :   0.04164418 23.99215802
0.0004774029 :   0.0396108 25.3096603
0.0004572799 :   0.03962633 25.36736277
0.0004572799 :   0.03962644 25.36726404
0.0004572799 :   0.03962606 25.36751733
0.01503152 :   0.03135571 29.75298943
0.0005126419 :   0.03144118 31.97249089
0.0005125379 :   0.03143429 31.97347714
0.03459211 :   0.02313235 38.66828441
0.000604997 :   0.02321897 43.29494570
0.000604537 :   0.02320821 43.29777700
0.101524 :   0.01487079 54.77536162
0.0007370178 :   0.01496324 67.21583379
0.0007332643 :   0.0149429 67.2304192
0.0007332643 :   0.01494326 67.22883279
0.0007332643 :   0.0149447 67.2223002
0.0007332643 :   0.01494398 67.22557419
0.4554704 :   0.006566961 91.479908193
0.001027296 :  6.679888e-03 1.513632e+02
0.0008987084 :  6.644375e-03 1.511547e+02
0.0008987083 :  6.645432e-03 1.511295e+02
0.0008987083 :  6.635381e-03 1.513589e+02
0.0008987083 :  6.640075e-03 1.512516e+02
0.0008987083 :  6.641331e-03 1.512229e+02
0.0008987083 :    0.00664135 151.22260526
0.0008987083 :  6.637189e-03 1.513178e+02
0.0008987083 :  6.638527e-03 1.512873e+02
0.0008987083 :  6.638988e-03 1.512767e+02
5.670852 :   -0.00178024 236.48397708
0.07629167 :  -1.978927e-03 -5.903500e+02
0.001146235 :  -1.763803e-03 -5.715189e+02
0.001100861 :  -1.770178e-03 -5.671698e+02
0.001100861 :  -1.768766e-03 -5.676219e+02
0.001100861 :    -0.00176754 -568.01534533
0.001100861 :  -1.767101e-03 -5.681566e+02
0.001100861 :  -1.767729e-03 -5.679553e+02
0.001100861 :  -1.766164e-03 -5.684578e+02
0.001100861 :  -1.765957e-03 -5.685248e+02
0.001100861 :  -1.763511e-03 -5.693125e+02
0.00110086 :  -1.761629e-03 -5.699212e+02
0.00110086 :  -1.761644e-03 -5.699164e+02
0.00110086 :  -1.761602e-03 -5.699299e+02
0.00110086 :  -1.761476e-03 -5.699708e+02
0.00110086 :  -1.761478e-03 -5.699701e+02
0.00110086 :  -1.761597e-03 -5.699318e+02
0.00110086 :  -1.761783e-03 -5.698715e+02
0.00110086 :    -0.00176032 -570.34448663
0.00110086 :  -1.758844e-03 -5.708224e+02
0.00110086 :  -1.757306e-03 -5.713217e+02
0.00110086 :  -1.756509e-03 -5.715815e+02
0.00110086 :  -1.754367e-03 -5.722780e+02
$\endgroup$
  • $\begingroup$ One of the best ways to obtain the same results as another procedure is to use its results as the starting values in your search. (Note that this is not to be recommended in general: it's solely to check that the original solutions really are at least local minima of the loss function.) $\endgroup$ – whuber Aug 1 '18 at 19:12
  • $\begingroup$ "I would like to make the nls() results as close to the sigmaplot results as possible, without failing the regression." Then you might need to use the same optimizer as in Sigmaplot. You'll need to provide the model equation and the data if you require specific help. $\endgroup$ – Roland Aug 2 '18 at 6:09
  • $\begingroup$ Here's the formula: formula = std1$average ~a*(E-std1$concentration -K +sqrt((E-std1$concentration-K)^2+4*E*K))/2 $\endgroup$ – variable Aug 2 '18 at 16:46
  • $\begingroup$ I'm not sure what the optimizer sigmaplot uses, I guess by that you mean the algorithm for convergence? $\endgroup$ – variable Aug 2 '18 at 16:47
  • $\begingroup$ An issue may be with the performance of the Gauss–Newton fitting used by nls. See this page for an example using the Levenberg–Marquardt method (search for nlsLM). Another option is the the Marquardt–Nash method, though I don't know where this is available in R. $\endgroup$ – Sal Mangiafico Aug 3 '18 at 3:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.