[R] non-linear regression and root finding

Berwin A Turlach berw|n@tur|@ch @end|ng |rom gm@||@com
Tue Nov 7 05:10:08 CET 2023

G'day Troels,

On Mon, 6 Nov 2023 20:43:10 +0100
Troels Ring <tring using gvdnet.dk> wrote:

> Thanks a lot! This was amazing. I'm not sure I see how the conditiion
> pK1 < pK2 < pK3 is enforced? 

One way of enforcing such constraints (well, in finite computer
arithemtic only "<=" can be enforced) is to rewrite the parameters as:

pK1 = exp(theta1)       ## only if pK1 > 0
pK2 = pK1 + exp(theta2)
pK3 = pk2 + exp(theta3)

And then use your optimiser to optimise over theta1, theta2 and theta3.

There might be better approaches depending on the specific problem.



More information about the R-help mailing list