Return a vector with the probabilities.
The flexit equation is published in:
Abreu-Grobois, F.A., Morales-Mérida, B.A., Hart, C.E., Guillon, J.-M., Godfrey, M.H.,
Navarro, E. & Girondot, M. (2020) Recent advances on the estimation of the thermal
reaction norm for sex ratios. PeerJ, 8, e8451.
If dose < P then \((1 + (2^K1 - 1) * exp(4 * S1 * (P - x)))^(-1/K1)\)
If dose > P then \(1-((1 + (2^K2 - 1) * exp(4 * S2 * (x - P)))^(-1/K2)\)
with:
$$S1 = (2^(K1 - 1) * S * K1)/(2^K1 - 1)$$
$$S2 = (2^(K2 - 1) * S * K2)/(2^K2 - 1)$$
New in version 4.7-3 and larger:
If \(2^K1\) is too large to be estimated, the approximation \(S1 = S*K1/2\) is used.
Demonstration:
$$S1 = (2^(K1 - 1) * S * K1)/(2^K1 - 1)$$
$$S1 = exp(log((2^(K1 - 1) * S * K1)/(2^K1 - 1)))$$
$$S1 = exp(log(2^(K1 - 1)) + log(S * K1) - log(2^K1 - 1))$$
When \(K1\) is very large, \(2^K1 - 1 = 2^K1\) then
$$S1 = exp((K1 - 1) * log(2) + log(S * K1) - K1 * log(2))$$
$$S1 = exp((K1 * log(2) - log(2) + log(S * K1) - K1 * log(2))$$
$$S1 = exp(log(S * K1)- log(2))$$
$$S1 = S * K1 / 2$$
If \(2^K2\) is too large to be estimated, the approximation \(S2 = S*K2/2\) is used.
If \((1 + (2^K1 - 1) * exp(4 * S1 * (P - x)))^(-1/K1)\) is not finite,
the following approximation is used:
$$exp((-1/K1)*(K1*log(2)+(4*S1*(P-x))))$$
If \(1-((1 + (2^K2 - 1) * exp(4 * S2 * (x - P)))^(-1/K2)\) is not finite,
the following approximation is used:
$$1 - exp((-1/K2)*(K2*log(2)+(4*S2*(x - P))))$$
BP_flexit(
x,
par = NULL,
P = NULL,
S = NULL,
K1 = NULL,
K2 = NULL,
Min = 0,
Max = 1,
zero = 1e-10,
error0 = 1e-10,
error1 = 1 - 1e-10
)
A vector with the probabilities
The values at which the flexit model must be calculated
The vector with P, S, K1, and K2 values
P value
S value
K1 value
K2 value
Min value for scaled flexit model
Max value for scaled flexit model
Value to replace zero
Value to return if an error is observed toward 0
Value to return if an error is observed toward 1
Marc Girondot marc.girondot@gmail.com
Return the flexit value
n <- flexit(x=1:100, par=c(P=50, S=0.001, K1=0.01, K2=0.02))
n <- flexit(x=1:100, P=50, S=0.001, K1=0.01, K2=0.02)
1/(1+exp(0.01*4*(50-1:100)))
flexit(1:100, P=50, S=0.01, K1=1, K2=1)
Run the code above in your browser using DataLab