- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
作为后续 this question ,我拟合了具有定量和定性解释变量之间相互作用的多元 Logistic 回归。 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)
的置信区间分别地。
Type
是代表不同类型药物的定性变量,
Conc
是代表不同药物浓度的定量变量。
最佳答案
您使用 drc
适合逻辑剂量 react 模型的软件包。
先拟合模型
require(drc)
mod <- drm(Kill/Total ~ Conc,
curveid = Type,
weights = Total,
data = df,
fct = L.4(fixed = c(NA, 0, 1, NA)),
type = 'binomial')
curveid=
指定数据的分组和
fct=
指定一个 4 参数逻辑函数,下键和上键的参数固定为 0 和 1。
glm
的区别可以忽略不计:
df2 <- with(data=df,
expand.grid(Conc=seq(from=min(Conc), to=max(Conc), length=51),
Type=levels(Type)))
df2$Pred <- predict(object=mod, newdata = df2)
hist(df2$Pred - df1$Pred)
ED()
功能:
ED(mod, c(50, 90, 95), interval = 'delta')
Estimated effective doses
(Delta method-based confidence interval(s))
Estimate Std. Error Lower Upper
A:50 9.1468 2.3257 4.5885 13.705
A:90 39.8216 4.3444 31.3068 48.336
A:95 50.2532 5.8773 38.7338 61.773
B:50 16.2936 2.2893 11.8067 20.780
B:90 52.0214 6.0556 40.1527 63.890
B:95 64.1714 8.0068 48.4784 79.864
C:50 12.5477 1.5568 9.4963 15.599
C:90 33.4740 2.7863 28.0129 38.935
C:95 40.5904 3.6006 33.5334 47.648
关于r - 具有定量和定性解释变量之间相互作用的多元 Logistic 回归,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36065327/
我打算在 AngularJS 中尝试一个项目,其中所有组件都将使用 Polymer 开发。现在在开始这个项目之前,我有几个疑问: 在使用 Angular 服务获取数据后,我可以更新 Polymer 组
假设我有多个线程正在从文件中读取,并且我想确保在任何时间点只有一个线程正在从文件中读取。 实现这一点的一种方法是使用 mvar :: MVar ()并确保如下互斥: thread = do ..
对于只有因子列的给定数据框,我想列出数据中没有出现的最多 m 个属性的所有因子组合。下面是一个简单的例子: d cc unlist(cc, recursive=F) -> cc length(cc)
对于相关图,我希望有一个光学正方形图(x 和 y 的像素长度相同),但 x 和 y 也有一定的轴限制。我可以分别获取这两个,但不能同时获取: import matplotlib.pyplot as p
对于相关图,我希望有一个光学正方形图(x 和 y 的像素长度相同),但 x 和 y 也有一定的轴限制。我可以分别获取这两个,但不能同时获取: import matplotlib.pyplot as p
关闭。这个问题是opinion-based .它目前不接受答案。 想改善这个问题吗?更新问题,以便可以通过 editing this post 用事实和引文回答问题. 7年前关闭。 Improve t
我是一名优秀的程序员,十分优秀!