I am trying to calculate LC50 from a list of bootstrapped GLM output
I have the output of bootstrapped GLM in a list (named results) as such: (I have just put in the last result for ease rather than the whole list)
$thetastar[[100]]
Call: glm(formula = dead[x] ~ concentration[x] + factor(female.no[x]),
family = binomial, data = subset.data.48hr)
Coefficients:
(Intercept) concentration[x] factor(female.no[x])3 factor(female.no[x])4 factor(female.no[x])7
0.7386 0.1869 -0.8394 -5.6613 -2.9576
factor(female.no[x])8 factor(female.no[x])9
-1.5329 -2.7826
Degrees of Freedom: 354 Total (i.e. Null); 348 Residual
(1265 observations deleted due to missingness)
Null Deviance: 484.2
Residual Deviance: 257 AIC: 271
using dose.p
from the MASS
package I am trying to calculate the LC50 for each individual within the model which has run
dose.p(results$thetastar[[100]], cf = c(2,3), p = 0.5)
which returns
Dose SE
p = 0.5: 0.2227249 0.161769
From what I understand this is the LC50 for factor(female.no[x])3.
i.e. into dose.p
I have put cf = c(2,3)
which i take to be column 2 and column 3, the concentration
and the factor(female.no[x])3.
Is this correct?
secondly:
Is there a way I can get LC50 for each of the females, i.e. factor(female.no[x])3
, factor(female.no[x])4
, factor(female.no[x])7
and so on, I don't see how i can get dose.p
work work along the differing variables without manually changing the code cf=
:
dose.p(results$thetastar[[100]], cf = c(2,3), p = 0.5)
dose.p(results$thetastar[[100]], cf = c(2,4), p = 0.5)
dose.p(results$thetastar[[100]], cf = c(2,4), p = 0.5)
finally:
My results are stored in a list, How do i get dose.p
to work along the list, would it be something like:
test=matrix
for(i in 1:results){
test[i,]= dose.p(results$thetastar[[i]], cf = c(2,3), p = 0.5)
Thanks for any help
The cf
argument to dose.p
takes the columns of the intercept and the log-dose. (If you are using concentration, isn't it an LC50?)
For the default animal (that isn't 3, 4, 8 or 9), you can use the (Intercept)
and concentration[x]
columns, cf = 1:2
.
For the other animals, you want the intercept plus a factor. For example, for animal 3, you'd want column 1 plus column 3 (as well as column 2 for the concentration). Unfortunately, dose.p
won't accept a specification like that, so you'll have to rerun your model without an intercept.
Add a 0
to the formula to achieve this:
glm(
dead[x] ~ 0 + concentration[x] + factor(female.no[x]),
family = binomial,
data = subset.data.48hr
)
Now each factor(female.no[x])
will contain the "intercept" for that animal.