我正在使用逻辑模型来获得具有三个独立预测变量的二元结果。调整模型后,我想用边际均值(lsmeans)估计我的结果(y)的预测,并对比这些预测。但是,我注意到,如果我使用的模型是逻辑模型,则对比度是以相对比例(比率)而不是绝对比例(差异)完成的。有没有人知道我如何才能获得从逻辑模型中获得的预测对比(使用lsmeans)的绝对差异?
以下是一个例子:
library(lsmeans)
#### Creating my Data
y<- rbinom(10000, 1, .02)
a<- sample(c(2005:2014), 10000, replace = T, prob = c(0.10023452, 0.09867466,
0.09869976, 0.09880913,
0.09903145, 0.10275898,
0.10470253, 0.09909241,
0.09889877, 0.09909779))
b<- rbinom(10000, 1, 0.57)
c<- sample(c(1:4), 10000, replace = T, prob = c(0.61969154, 0.12735996, 0.16385892, 0.08908958))
df<-data.frame(cbind(y, a, b, c))
df$a<-factor(df$a)
df$b<-factor(df$b)
df$c<-factor(df$c)
#### Logistic Model
m1<-glm(y~a*b*c, family = quasibinomial(link = "logit"), data = df)
summary(m1)
#### LSMEANS prediction
m1.ls<-lsmeans(m1, "a", by=c("b", "c"), infer=c(TRUE, TRUE), level=.95,
data=df)
#### Checking my predictions in the log odds scale
summary(m1.ls)
#### Checking my predictions in the probability scale
summary(m1.ls, type = "response")
m1.ctr.odds<-summary(contrast(m1.ls, infer=c(TRUE, TRUE), by=c("b", "c"),
level=.95, method="revpairwise"))
m1.ctr.prob<-summary(contrast(m1.ls, infer=c(TRUE, TRUE), by=c("b", "c"),
level=.95, method="revpairwise"), type = "response")
#### Contrasts are in the log odds ratio scale. NOTE this are RATIOS of log odds
m1.ctr.odds
#### Contrasts are in the probability scale. NOTE this are RATIOS of probabilities
m1.ctr.prob #### I would like these contrasts to be absolute differences (substractions)
最好,
→