誰かが私がこれらの相対リスク計算(およびその信頼区間)をRで複製するのを手伝ってもらえますか?
ここでは、Stataで使用される同様の手順について説明します。誰かがRでこれを行う方法を教えてもらえますか(私のデータにはクラスターと階層がありますが、より簡単な例を取り上げました)?relrisk.est関数を試しましたが、非常に複雑な設計を処理するため、調査パッケージを使用したいと思います。また、StataとRの推定値を比較したいと思います。ここで提案されているように、ポアソンを使用しています。
###STATA CODE
use http://www.ats.ucla.edu/stat/stata/faq/eyestudy
tabulate carrot lenses
*same as R binomial svyglm below
xi: glm lenses carrot, fam(bin)
*switch reference code
char carrot[omit] 1
xi: glm lenses i.carrot, fam(poisson) link(log) nolog robust eform
###R
library(foreign)
library(survey)
D<-read.dta("http://www.ats.ucla.edu/stat/stata/faq/eyestudy.dta")
table(D$lenses,D$carrot)
D$wgt<-rep(1,nrow(D))
Dd<-svydesign(id=~1,data=D,weights=~wgt)
#change category and eform....?
svyglm(lenses~carrot,Dd,family=binomial)
svyglm(lenses~carrot,Dd,family=quasipoisson(log))