if (FALSE) {
library(embryogrowth)
eo <- subset(DatabaseTSD, Species=="Emys orbicularis", c("Males", "Females",
"Incubation.temperature"))
eo_logistic <- tsd(eo)
pMCMC <- tsd_MHmcmc_p(eo_logistic, accept=TRUE)
# Take care, it can be very long
result_mcmc_tsd <- tsd_MHmcmc(result=eo_logistic,
parametersMCMC=pMCMC, n.iter=10000, n.chains = 1,
n.adapt = 0, thin=1, trace=FALSE, adaptive=TRUE)
# summary() permits to get rapidly the standard errors for parameters
summary(result_mcmc_tsd)
plot(result_mcmc_tsd, parameters="S", scale.prior=TRUE, xlim=c(-3, 3), las=1)
plot(result_mcmc_tsd, parameters="P", scale.prior=TRUE, xlim=c(25, 35), las=1)
plot(eo_logistic, resultmcmc = result_mcmc_tsd)
1-rejectionRate(as.mcmc(result_mcmc_tsd))
raftery.diag(as.mcmc(result_mcmc_tsd))
heidel.diag(as.mcmc(result_mcmc_tsd))
library(car)
o <- P_TRT(x=eo_logistic, resultmcmc=result_mcmc_tsd)
outEo <- dataEllipse(x=o$P_TRT[, "PT"],
y=o$P_TRT[, "TRT"],
levels=c(0.95),
draw=FALSE)
plot(x = o$P_TRT[, "PT"],
y=o$P_TRT[, "TRT"],
pch=".", las=1, bty="n",
xlab="Pivotal temperature",
ylab=paste0("TRT ", as.character(100*eo_logistic$l), "%"),
xlim=c(28.4, 28.6),
ylim=c(0.8, 1.8))
lines(outEo[, 1], outEo[, 2], col="green", lwd=2)
legend("topleft", legend = c("Emys orbicularis", "95% confidence ellipse"),
pch=c(19, NA), col=c("black", "green"), lty=c(0, 1), lwd=c(0, 2))
logistic <- function(x, P, S) {
return(1/(1+exp((1/S)*(P-x))))
}
q <- as.quantile(result_mcmc_tsd, fun=logistic,
xlim=seq(from=25, to=35, by=0.1), nameparxlim="x")
plot(x=seq(from=25, to=35, by=0.1), y=q[1, ], type="l", las=1,
xlab="Temperatures", ylab="Male proportion", bty="n")
lines(x=seq(from=25, to=35, by=0.1), y=q[2, ])
}
Run the code above in your browser using DataLab