我试图查看这些LT50曲线彼此之间的差异。我希望为LT50曲线(GLM二项式)添加一个置信区间。如何计算此图并在其中添加95%的置信区间?
用于基本的LT50代码:https://lukemiller.org/index.php/2010/02/calculating-lt50-median-lethal-temperature-aka-ld50-quickly-in-r/
数据按列进行组织:(1)暴露于温度处理的动物,(2)死亡的人数,(3)存活的人数
fhl.adult.lt50 <- read.csv("~/Documents/UCI/FHL 2019/Class Docs/Projects/Project 1/Data/Friday Harbor Dock - 2019/fhl_dock_lt50_adult_redo.csv")
head(fhl.adult.lt50)
treatment dead alive
1 11.80609 0 5
2 29.11496 1 4
3 32.62465 2 3
4 37.97368 5 0
y<-cbind(alive, dead)
model.results = glm(y~treatment,binomial)
summary(model.results)
#dose.p function will calculate any fractional dosage value you want (LT50, LT90, etc)
dose.p(model.results,p=0.5)
#plot data
plot(treatment, (alive/(alive+dead)), ylab="% Survival", ylim=c(0,1.0), xaxp = c(10, 42, 8), xlab="Temperature (°C)", cex.lab = 1.50, cex.axis = 1.5)
logisticline = function(z) {
eta = 18.1276 + -0.5575 * z;
1 / (1 + exp(-eta))} #use intercept and slope reported in summary of glm
x=seq(11.80609,37.97368,0.01) #vector of temp values for logisticline
#temp limits (lowest, highest, step size of 0.01) #0.01 is small -- gives smooth curve
lines(x, logisticline(x), new=TRUE) #plotting by having every x value plugged into logistic equation and then plotting it