[R] non-linear regression and root finding

Troels Ring tr|ng @end|ng |rom gvdnet@dk
Tue Nov 7 07:14:02 CET 2023

Thanks a lot, Berwin. Unfortunately, pK1 may well be negative and as I 
understand the literature it may be poorly defined as such, and also 
seems to be at a boundary, since when lower is set to say rep(-4,3) pK1 
is returned as -4 while pK2 and pK3 are undisturbed. Perhaps the point 
is that pK1 is not carrying any information at the pH around 5. Fair 
enough, I guess. Only, I believe I need stick to including all three pK 
values to be in agreement with the molecular information about HEPES - 
although even this is contentious. Be as it may, I wonder if not your 
method might work if only we KNOW that pK1 is either positive OR 
negative, in which case we have pK1 = -exp(theta1)?

Best wishes

Den 07-11-2023 kl. 05:10 skrev Berwin A Turlach:
> 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.
> Cheers,
> 	Berwin

More information about the R-help mailing list