flexit: Return the flexit

View source: R/flexit.R

flexitR Documentation

Return the flexit

Description

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))))

Usage

flexit(
  x,
  par = NULL,
  P = NULL,
  S = NULL,
  K1 = NULL,
  K2 = NULL,
  zero = 1e-09,
  error0 = 0,
  error1 = 1
)

Arguments

x

The values at which the flexit model must be calculated

par

The vector with P, S, K1, and K2 values

P

P value

S

S value

K1

K1 value

K2

K2 value

zero

Value to replace zero

error0

Value to return if an error is observed toward 0

error1

Value to return if an error is observed toward 1

Details

Return the flexit value

Value

A vector with the probabilities

Author(s)

Marc Girondot marc.girondot@gmail.com

See Also

Other logit: invlogit(), logit()

Examples

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)

HelpersMG documentation built on Oct. 5, 2023, 5:08 p.m.