The R script in the notepad file below will calculate the 'dose' for a user specified proportion and its 95% confidence interval for binomial and beta-binomial linear and quadratic models fit with mle2 (from Ben Bolker's R package 'bbmle').

ld_calc_1.1.txt | |
File Size: | 1 kb |
File Type: | txt |
Directions for use:
Install Richard McElreath's 'Rethinking' package. After fitting your model using mle2, cut and paste the 'ld_calc' R script into R. Run the script. Input the following into the LD_calc funtion: a proportion (e.g., 0.5 to calculate an LD50), the name of the model object, and the names used for each of the parameters in quotes. Optional: input the minimum 'dose' for your data (i.e., the lowest value of 'x' for which there is data) and the maximum 'dose' for your data (i.e., the highest value of 'x' for which there is data). This will provide a warning if the calculated value of 'x' is beyond the range for which there is data.
For example, here is a linear model fit in R followed by the calculation of the LD50 (salinity is the stressor, 20 organisms were used per replicate):
m1<-mle2(mortality~dbinom(prob=logistic(a+b*salinity), size=20),data=d,start=list(a=0,b=0))
LD_calc(0.5, m1, "a", "b")
Here is a quadratic model:
m2<-mle2(mortality~dbetabinom(prob=logistic(a+b*salinity+c*salinity*salinity), size=20),data=d,start=list(a=0,b=0,c=0))
LD_calc(0.5, m2, "a", "b","c")
Gideon Bradburd, Frances Hammock, and Bruce G Hammock wrote the script. Please email Bruce with questions: brucehammock [at] gmail dot com
Install Richard McElreath's 'Rethinking' package. After fitting your model using mle2, cut and paste the 'ld_calc' R script into R. Run the script. Input the following into the LD_calc funtion: a proportion (e.g., 0.5 to calculate an LD50), the name of the model object, and the names used for each of the parameters in quotes. Optional: input the minimum 'dose' for your data (i.e., the lowest value of 'x' for which there is data) and the maximum 'dose' for your data (i.e., the highest value of 'x' for which there is data). This will provide a warning if the calculated value of 'x' is beyond the range for which there is data.
For example, here is a linear model fit in R followed by the calculation of the LD50 (salinity is the stressor, 20 organisms were used per replicate):
m1<-mle2(mortality~dbinom(prob=logistic(a+b*salinity), size=20),data=d,start=list(a=0,b=0))
LD_calc(0.5, m1, "a", "b")
Here is a quadratic model:
m2<-mle2(mortality~dbetabinom(prob=logistic(a+b*salinity+c*salinity*salinity), size=20),data=d,start=list(a=0,b=0,c=0))
LD_calc(0.5, m2, "a", "b","c")
Gideon Bradburd, Frances Hammock, and Bruce G Hammock wrote the script. Please email Bruce with questions: brucehammock [at] gmail dot com