【发布时间】:2016-07-04 01:59:36
【问题描述】:
作为this question 的后续行动,我将多重逻辑回归与定量和定性解释变量之间的交互进行了拟合。 MWE如下:
Type <- rep(x=LETTERS[1:3], each=5)
Conc <- rep(x=seq(from=0, to=40, by=10), times=3)
Total <- 50
Kill <- c(10, 30, 40, 45, 38, 5, 25, 35, 40, 32, 0, 32, 38, 47, 40)
df <- data.frame(Type, Conc, Total, Kill)
fm1 <-
glm(
formula = Kill/Total~Type*Conc
, family = binomial(link="logit")
, data = df
, weights = Total
)
summary(fm1)
Call:
glm(formula = Kill/Total ~ Type * Conc, family = binomial(link = "logit"),
data = df, weights = Total)
Deviance Residuals:
Min 1Q Median 3Q Max
-4.871 -2.864 1.204 1.706 2.934
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -0.65518 0.23557 -2.781 0.00541 **
TypeB -0.34686 0.33677 -1.030 0.30302
TypeC -0.66230 0.35419 -1.870 0.06149 .
Conc 0.07163 0.01152 6.218 5.04e-10 ***
TypeB:Conc -0.01013 0.01554 -0.652 0.51457
TypeC:Conc 0.03337 0.01788 1.866 0.06201 .
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 277.092 on 14 degrees of freedom
Residual deviance: 96.201 on 9 degrees of freedom
AIC: 163.24
Number of Fisher Scoring iterations: 5
anova(object=fm1, test="LRT")
Analysis of Deviance Table
Model: binomial, link: logit
Response: Kill/Total
Terms added sequentially (first to last)
Df Deviance Resid. Df Resid. Dev Pr(>Chi)
NULL 14 277.092
Type 2 6.196 12 270.895 0.04513 *
Conc 1 167.684 11 103.211 < 2e-16 ***
Type:Conc 2 7.010 9 96.201 0.03005 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
df$Pred <- predict(object=fm1, data=df, type="response")
df1 <- with(data=df,
expand.grid(Type=levels(Type)
, Conc=seq(from=min(Conc), to=max(Conc), length=51)
)
)
df1$Pred <- predict(object=fm1, newdata=df1, type="response")
library(ggplot2)
ggplot(data=df, mapping=aes(x=Conc, y=Kill/Total, color=Type)) + geom_point() +
geom_line(data=df1, mapping=aes(x=Conc, y=Pred), linetype=2) +
geom_hline(yintercept=0.5,col="gray")
我想计算LD50、LD90 和LD95 及其置信区间。由于交互很重要,所以我想分别计算 LD50、LD90 和 LD95 以及每个 Type (A, B, and C) 的置信区间。
LD 代表lethal dose. 它是杀死X% (LD50 = 50%) 的测试人群所需的物质量。
已编辑
Type 是代表不同类型药物的定性变量,Conc 是代表不同药物浓度的定量变量。
【问题讨论】:
-
这是什么
LD50、LD90和LD95,在你的MWE中没有这样的东西。 -
正如您在给我的消息中指出的那样,this question 具有高度相关性。你有没有尝试过让它适应你的问题?
-
@TheRimalaya,他想计算 50%、90% 和 95% 的动物死亡的浓度。
-
@BenBolker:感谢您的评论。在相关问题中,两个解释变量都进行了定量处理。然而,在这个问题中,一个变量是定量的,另一个是定性的,这使得它与相关问题不同。谢谢
-
你的变量我不清楚。您能否在您的问题中澄清,而不是 cmets?貌似
Type代表药物类别,conc代表剂量,但我不确定
标签: r logistic-regression