【发布时间】:2021-06-24 06:24:54
【问题描述】:
我正在尝试获得实际上是预测边际均值的比例的 95% CI,如使用 R 的 survey package 计算的那样。我包括这个可重复的示例,它在内容方面没有任何意义,但希望能很好地说明我的目的:
library(survey)
data(api)
dstrat <- svydesign(id=~1,strata=~stype, weights=~pw, data=apistrat, fpc=~fpc)
# 1.- marginal means for groups according to a variable
svyglm(I(sch.wide=="Yes") ~ awards+comp.imp, design=dstrat, family=quasipoisson()) %>% svypredmeans(., ~yr.rnd)
# 2.- the confidence intervals I'd like to compute by svyciprop(), in an obviously wrong way
svyby(I(sch.wide=="Yes") ~ awards+comp.imp, ~yr.rnd, design=dstrat, svyciprop, vartype="ci", method="xlogit")
我不知道如何在svyciprop() 中输入正确的参数,或者这是否可能。 svyciprop() 函数采用单个公式,这似乎与计算预测边际均值的计算方式不兼容,也与 svypredmeans() 的输出不兼容。
在此先感谢您的帮助!
编辑抱歉,因为代码是正确的,但有一个错字。但是,有一个后续问题:第 1 步中预测边际均值的估计值与第 2 步中的相同估计值不匹配。有人可以解释为什么会出现这些差异吗?
【问题讨论】: