Learn R Programming

embryogrowth (version 8.0)

tsd: Estimate the parameters that best describe temperature-dependent sex determination

Description

Estimate the parameters that best describe the thermal reaction norm for sex ratio when temperature-dependent sex determination occurs. It can be used also to evaluate the relationship between incubation duration and sex ratio. The parameter l was defined in Girondot (1999). The TRT is defined from the difference between the two boundary temperatures giving sex ratios of \(l\) and \(1 - l\), respectively: For logistic model (Girondot, 1999), it follows $$TRT_{l}=abs\left ( S\: K_{l} \right )$$ where \(K_{l}\) is a constant equal to \(2\: log\left ( \frac{l}{1-l} \right )\). In Girondot (1999), l was 0.05 and then the TRT was defined as being the range of temperatures producing from 5% to 95% of each sex. For other models, TRT is calculated numerically. The basic model is logistic one. This model has the particularity to have a symmetric shape around P. The other models have been built to alleviate this constraint. Hill and A-logistic models can be asymmetric, but it is impossible to control independently the low and high transitions. Hulin model is assymmetric but the control of asymmetry is difficult to manage./cr If asymmetric model is selected, it is always better to use flexit model. $$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 = S/((4/K1)*(2^(-K1))^(1/K1+1)*(2^K1-1))$$ $$S2 = S/((4/K2)*(2^(-K2))^(1/K2+1)*(2^K2-1))$$

Usage

tsd(
  df = NULL,
  males = NULL,
  females = NULL,
  N = NULL,
  temperatures = NULL,
  durations = NULL,
  l = 0.05,
  parameters.initial = c(P = NA, S = -2, K = 0, K1 = 1, K2 = 0),
  males.freq = TRUE,
  fixed.parameters = NULL,
  equation = "logistic",
  replicate.CI = 10000,
  range.CI = 0.95,
  replicate.NullDeviance = 1000,
  control = list(maxit = 1000),
  print = TRUE
)

Arguments

df

A dataframe with at least two columns named males, females or N and temperatures, Incubation.temperature or durations column

males

A vector with male numbers

females

A vector with female numbers

N

A vector with total numbers

temperatures

The constant incubation temperatures used to fit sex ratio

durations

The duration of incubation or TSP used to fit sex ratio

l

Sex ratio limits to define TRT are l and 1-l (see Girondot, 1999)

parameters.initial

Initial values for P, S or K search as a vector, ex. c(P=29, S=-0.3)

males.freq

If TRUE data are shown as males frequency

fixed.parameters

Parameters that will not be changed

equation

Could be "logistic", "Hill", "A-logistic", "Hulin", "Double-A-logistic", "flexit" or "GSD"

replicate.CI

Number of replicates to estimate confidence intervals

range.CI

The range of confidence interval for estimation, default=0.95

replicate.NullDeviance

Number of replicates to estimate null distribution of deviance

control

List of parameters used in optim.

print

Should the results be printed at screen? TRUE (default) or FALSE

Value

A list the pivotal temperature, transitional range of temperatures and their SE

Details

tsd estimates the parameters that best describe temperature-dependent sex determination

References

Girondot, M. 1999. Statistical description of temperature-dependent sex determination using maximum likelihood. Evolutionary Ecology Research, 1, 479-486.

Godfrey, M.H., Delmas, V., Girondot, M., 2003. Assessment of patterns of temperature-dependent sex determination using maximum likelihood model selection. Ecoscience 10, 265-272.

Hulin, V., Delmas, V., Girondot, M., Godfrey, M.H., Guillon, J.-M., 2009. Temperature-dependent sex determination and global change: are some species at greater risk? Oecologia 160, 493-506.

See Also

Other Functions for temperature-dependent sex determination: DatabaseTSD.version(), DatabaseTSD, P_TRT(), TSP.list, plot.tsd(), predict.tsd(), stages, tsd_MHmcmc_p(), tsd_MHmcmc()

Examples

Run this code
# NOT RUN {
library(embryogrowth)
CC_AtlanticSW <- subset(DatabaseTSD, RMU=="Atlantic, SW" & 
                          Species=="Caretta caretta" & (!is.na(Sexed) & Sexed!=0) &
                          !is.na(Correction.factor))
tsdL <- with (CC_AtlanticSW, tsd(males=Males, females=Females, 
                                 temperatures=Incubation.temperature-Correction.factor, 
                                 equation="logistic", replicate.CI=NULL))
tsdH <- with (CC_AtlanticSW, tsd(males=Males, females=Females, 
                                 temperatures=Incubation.temperature-Correction.factor, 
                                 equation="Hill", replicate.CI=NULL))
tsdR <- with (CC_AtlanticSW, tsd(males=Males, females=Females, 
                                 temperatures=Incubation.temperature-Correction.factor, 
                                 equation="A-logistic", replicate.CI=NULL))
tsdF <- with (CC_AtlanticSW, tsd(males=Males, females=Females, 
                                 temperatures=Incubation.temperature-Correction.factor, 
                                 equation="Flexit", replicate.CI=NULL))
tsdDR <- with (CC_AtlanticSW, tsd(males=Males, females=Females, 
                                 temperatures=Incubation.temperature-Correction.factor, 
                                 equation="Double-A-logistic", replicate.CI=NULL))
gsd <- with (CC_AtlanticSW, tsd(males=Males, females=Females, 
                                 temperatures=Incubation.temperature-Correction.factor, 
                                 equation="GSD", replicate.CI=NULL))
compare_AIC(Logistic_Model=tsdL, Hill_model=tsdH, Alogistic_model=tsdR, 
               flexit=tsdF, 
               DoubleAlogistic_model=tsdDR, GSD_model=gsd)
compare_AICc(Logistic_Model=tsdL, Hill_model=tsdH, Alogistic_model=tsdR, 
               DoubleAlogistic_model=tsdDR, GSD_model=gsd, factor.value = -1)
compare_BIC(Logistic_Model=tsdL, Hill_model=tsdH, Alogistic_model=tsdR, 
               DoubleAlogistic_model=tsdDR, GSD_model=gsd, factor.value = -1)
##############
eo <- subset(DatabaseTSD, Species=="Emys orbicularis", c("Males", "Females", 
                                       "Incubation.temperature"))
                                       
eo_Hill <- with(eo, tsd(males=Males, females=Females, 
                                       temperatures=Incubation.temperature,
                                       equation="Hill"))
eo_Hill <- tsd(df=eo, equation="Hill", replicate.CI=NULL)
eo_logistic <- tsd(eo, replicate.CI=NULL)
eo_Alogistic <- with(eo, tsd(males=Males, females=Females, 
                                 temperatures=Incubation.temperature, 
                                 equation="a-logistic", replicate.CI=NULL))
### The Hulin model is a modification of A-logistic (See Hulin et al. 2009)

########## Caution
### It should not be used anymore as it can produce unexpected results
par <- eo_Alogistic$par
names(par)[which(names(par)=="K")] <- "K2"
par <- c(par, K1=0)
eo_Hulin <- with(eo, tsd(males=Males, females=Females, 
                                 parameters.initial=par, 
                                 temperatures=Incubation.temperature, 
                                 equation="Hulin", replicate.CI=NULL))
                                 
### The Double-A-logistic model is a A-logistic model with K1 and K2 using respectively
### below and above P

########## Caution
### The curve is not smooth at pivotal temperature

par <- eo_Alogistic$par
names(par)[which(names(par)=="K")] <- "K2"
par <- c(par, K1=as.numeric(par["K2"])*0.8)
par["K2"] <- par["K2"]*0.8
eo_Double_Alogistic <- with(eo, tsd(males=Males, females=Females,
                                 parameters.initial=par,
                                 temperatures=Incubation.temperature,
                                 equation="Double-a-logistic", replicate.CI=NULL))
                                 
### The flexit model is modeled with K1 and K2 using respectively
### below and above P and smooth transition at P; S is the slope at P

par <- c(eo_logistic$par["P"], 1/4*eo_logistic$par["S"], K1=1, K2=1)
eo_flexit <- with(eo, tsd(males=Males, females=Females,
                                 parameters.initial=par,
                                 temperatures=Incubation.temperature,
                                 equation="flexit", replicate.CI=NULL))
                                 
compare_AIC(Logistic=eo_logistic, Hill=eo_Hill, Alogistic=eo_Alogistic, 
             Hulin=eo_Hulin, Double_Alogistic=eo_Double_Alogistic, 
             flexit=eo_flexit)
## Note that SE for lower limit of TRT is wrong
plot(eo_flexit)
## To get correct confidence interval, check \code{tsd_MHmcmc()}. 
             
### Note the asymmetry of the Double-A-logistic and flexit models
predict(eo_Double_Alogistic, 
       temperatures=c(eo_Double_Alogistic$par["P"]-0.2, eo_Double_Alogistic$par["P"]+0.2))
predict(eo_Double_Alogistic)

(p <- predict(eo_flexit, 
       temperatures=c(eo_flexit$par["P"]-0.3, eo_flexit$par["P"]+0.3)))
p["50%", 1]-0.5; 0.5-p["50%", 2]
predict(eo_flexit)

### It can be used also for incubation duration
CC_AtlanticSW <- subset(DatabaseTSD, RMU=="Atlantic, SW" & 
                          Species=="Caretta caretta" & Sexed!=0)
tsdL_IP <- with (CC_AtlanticSW, tsd(males=Males, females=Females, 
                                 durations=IP.mean, 
                                 equation="logistic", replicate.CI=NULL))
plot(tsdL_IP, xlab="Incubation durations in days")
# Example with Chelonia mydas
cm <- subset(DatabaseTSD, Species=="Chelonia mydas" & !is.na(Sexed), c("Males", "Females", 
                                       "Incubation.temperature", "RMU"))
tsd(subset(cm, subset=RMU=="Pacific, SW"))
tsd(subset(cm, subset=RMU=="Pacific, Northwest"))
tsd(subset(cm, subset=RMU=="Atlantic, S Caribbean"))

### Eretmochelys imbricata
Ei_PacificSW <- subset(DatabaseTSD, RMU=="Pacific, SW" & 
                       Species=="Eretmochelys imbricata")
Ei_AtlanticW <- subset(DatabaseTSD, RMU=="Atlantic, W (Caribbean and E USA)" & 
                       Species=="Eretmochelys imbricata")
Ei_AtlanticSW <- subset(DatabaseTSD, RMU=="Atlantic, SW" & 
                       Species=="Eretmochelys imbricata")
Ei_PacSW <- tsd(Ei_PacificSW)
Ei_AtlW <- tsd(Ei_AtlanticW)
Ei_AtlSW <- tsd(Ei_AtlanticSW)

plot(Ei_PacSW, xlim=c(27, 33), show.PTRT = FALSE, main=expression(italic("Eretmochelys imbricata")))
par(new=TRUE)
plot(Ei_AtlW, xlim=c(27, 33), col="red", xlab="", ylab="", 
     axes=FALSE, xaxt="n", show.PTRT = FALSE, errbar.col="red")
par(new=TRUE)
plot(Ei_AtlSW, xlim=c(27, 33), col="blue", xlab="", ylab="", axes=FALSE, 
     xaxt="n", show.PTRT = FALSE, errbar.col="blue")
legend("topright", legend=c("Pacific, SW", "Atlantic, W", "Atlantic, SW"), lty=1, 
col=c("black", "red", "blue"))

### Chelonia mydas
Cm_PacificSW <- subset(DatabaseTSD, RMU=="Pacific, SW" & !is.na(Sexed) & 
                       Species=="Chelonia mydas")
Cm_PacificNW <- subset(DatabaseTSD, RMU=="Pacific, NW" &  !is.na(Sexed) & 
                       Species=="Chelonia mydas")
Cm_AtlanticSC <- subset(DatabaseTSD, RMU=="Atlantic, S Caribbean" &  !is.na(Sexed) & 
                       Species=="Chelonia mydas")
Cm_IndianSE <- subset(DatabaseTSD, RMU=="Indian, SE" &  !is.na(Sexed) & 
                       Species=="Chelonia mydas")
Cm_PacSW <- tsd(Cm_PacificSW)
Cm_PacNW <- tsd(Cm_PacificNW)
Cm_IndSE <- tsd(Cm_IndianSE)
Cm_AtlSC <- tsd(Cm_AtlanticSC)

plot(Cm_PacSW, xlim=c(24, 34), show.PTRT = FALSE, main=expression(italic("Chelonia mydas")))
par(new=TRUE)
plot(Cm_PacNW, xlim=c(24, 34), col="red", xlab="", ylab="", 
     axes=FALSE, xaxt="n", show.PTRT = FALSE, errbar.col="red")
par(new=TRUE)
plot(Cm_IndSE, xlim=c(24, 34), col="blue", xlab="", ylab="", 
     axes=FALSE, xaxt="n", show.PTRT = FALSE, errbar.col="blue")
par(new=TRUE)
plot(Cm_AtlSC, xlim=c(24, 34), col="green", xlab="", ylab="", 
     axes=FALSE, xaxt="n", show.PTRT = FALSE, errbar.col="green")

# To fit a TSDII or FMF TSD pattern, you must indicate P_low, S_low, P_high, and S_high
# for logistic model and P_low, S_low, K1_low, K2_low, P_high, S_high, K1_high, and K2_high for 
# flexit model
# The model must be 0-1 for low and 1-0 for high with P_low < P_high

Chelydra_serpentina <- subset(DatabaseTSD, !is.na(Sexed) & (Sexed != 0) & 
                       Species=="Chelydra serpentina")
                       
model_TSDII <- tsd(Chelydra_serpentina, males.freq=FALSE, 
                   parameters.initial=c(P_low=21, S_low=0.3, P_high=28, S_high=-0.4), 
                   equation="logistic")
plot(model_TSDII, lab.TRT = "TRT l = 5 %")
priors <- tsd_MHmcmc_p(result=model_TSDII, accept=TRUE)
out_mcmc <- tsd_MHmcmc(result=model_TSDII, n.iter=10000, parametersMCMC=priors)
plot(model_TSDII, resultmcmc=out_mcmc, lab.TRT = "TRT l = 5 %")
predict(model_TSDII, temperatures=25:35)

# Podocnemis expansa
Podocnemis_expansa <- subset(DatabaseTSD, !is.na(Sexed) & (Sexed != 0) & 
                       Species=="Podocnemis expansa")
Podocnemis_expansa_Valenzuela_2001 <- subset(Podocnemis_expansa, 
                   Reference=="Valenzuela, 2001")
PeL2001 <- tsd(df=Podocnemis_expansa_Valenzuela_2001)
# The pivotal temperature is 32.133 <U+00B0>C (CI 95% 31.495;32.766)
# In Valenzuela, 2001: "Using data from the present study alone, 
# the critical temperature was 32.2 <U+00B0>C by both methods and the 95% 
# confidence limits were 31.4 <U+00B0>C and 32.9 <U+00B0>C."
# Data are close but not identical to what was published.

# The pivotal temperature calculated by maximum likelihood and by inverse 
# prediction from logistic regression, was 32.6<U+00B0>C using raw data from 
# 1991 (N. Valenzuela, unpublished data) and from this study. The lower 
# and upper 95% confidence limits of the pivotal temperature were 32.2<U+00B0>C 
# and 33.2<U+00B0>C,

Podocnemis_expansa_Valenzuela_1997 <- subset(Podocnemis_expansa, 
                   subset=(((Reference=="Lance et al., 1992; Valenzuela et al., 1997") | 
                   (Reference=="Valenzuela, 2001")) & 
                   (!is.na(Sexed)) & (Sexed != 0)))

PeL1997 <- tsd(df=Podocnemis_expansa_Valenzuela_1997)

# }

Run the code above in your browser using DataLab