第十五章-交互作用分析-参考答案_第1页
第十五章-交互作用分析-参考答案_第2页
第十五章-交互作用分析-参考答案_第3页
第十五章-交互作用分析-参考答案_第4页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

第十五章交互作用分析练习案例参考答案案例一本例还是以传统二分类变量为例,构建了以outcome为结局,smoke(吸烟)和alcohol(酒精)为二分类变量(0代表未暴露,1代表暴露)的模拟数据,分别计算两者的相乘交互作用和相加交互作用。##案例1##

outcome<-c(rep(1,times=231),rep(0,times=178),rep(1,times=11),

rep(0,times=38))

smoke<-c(rep(1,times=225),rep(0,times=6),rep(1,times=166),

rep(0,times=12),rep(1,times=8),rep(0,times=3),rep(1,times=18),rep(0,times=20))

alcohol<-c(rep(1,times=409),rep(0,times=49))

data<-data.frame(outcome,smoke,alcohol)首先,构建基本模型,基本形式如下fit<-glm(as.factor(outcome)~as.factor(smoke)*as.factor(alcohol),data=data,family=binomial)采用summary()函数,查看模型结果summary(fit)

Call:

glm(formula=as.factor(outcome)~as.factor(smoke)*as.factor(alcohol),

family=binomial,data=data)

DevianceResiduals:

Min1QMedian3QMax

-1.309-1.3091.0511.0512.018

Coefficients:

EstimateStd.ErrorzvaluePr(>|z|)

(Intercept)-1.897120.61914-3.0640.00218**

as.factor(smoke)11.086190.750921.4460.14805

as.factor(alcohol)11.203970.795821.5130.13031

as.factor(smoke)1:as.factor(alcohol)1-0.088930.90794-0.0980.92197

---

Signif.codes:0'***'0.001'**'0.01'*'0.05'.'0.1''1

(Dispersionparameterforbinomialfamilytakentobe1)

Nulldeviance:633.45on457degreesoffreedom

Residualdeviance:605.93on454degreesoffreedom

AIC:613.93

NumberofFisherScoringiterations:4相乘交互作用将上述模型结果,采用以下计算过程换算得到相乘交互作用效应值和置信区间。##相乘交互作用##

##smoke##

or<-exp(coefficients(summary(fit))[2,1])

orl<-exp(coefficients(summary(fit))[2,1]-1.96*coefficients(summary(fit))[2,2])

orh<-exp(coefficients(summary(fit))[2,1]+1.96*coefficients(summary(fit))[2,2])

paste0(round(or,4),"(",round(orl,4),",",round(orh,4),")")[1]"2.963(0.68,12.91)"##alcohol##

or<-exp(coefficients(summary(fit))[3,1])

orl<-exp(coefficients(summary(fit))[3,1]-1.96*coefficients(summary(fit))[3,2])

orh<-exp(coefficients(summary(fit))[3,1]+1.96*coefficients(summary(fit))[3,2])

paste0(round(or,4),"(",round(orl,4),",",round(orh,4),")")[1]"3.3333(0.7006,15.8597)"##smoke×alcohol##

or<-exp(coefficients(summary(fit))[4,1])

orl<-exp(coefficients(summary(fit))[4,1]-1.96*coefficients(summary(fit))[4,2])

orh<-exp(coefficients(summary(fit))[4,1]+1.96*coefficients(summary(fit))[4,2])

paste0(round(or,4),"(",round(orl,4),",",round(orh,4),")")[1]"0.9149(0.1544,5.4229)"模型结果提示,由于“smoke×alcohol”项置信区间包含1,因此吸烟暴露和饮酒暴露对结局出现之间不存在相乘交互作用。相加交互作用在这一部分我们可以使用两种方式计算相加交互作用。首先是param="product"时的计算方法:将上述模型结果,采用以下计算过程换算得到相加交互作用效应值和置信区间。##RERI##

reri<-as.data.frame(eraction(fit,coef=c(2,3,4),param="product")[1])

round(reri,3)reri.estreri.lowerreri.upper

3.74-1.8379.316##AP##

ap<-as.data.frame(eraction(fit,coef=c(2,3,4),param="product")[2])

round(ap,3)apab.estapab.lowerapab.upper

0.414-0.0730.901##S##

s<-as.data.frame(eraction(fit,coef=c(2,3,4),param="product")[3])

round(s,3)s.ests.lowers.upper

1.870.6465.416模型结果提示,由于RERI、AP置信区间包含0,S的置信区间包含1,因此高浓度PM2.5和高相对湿度暴露对老年人血压升高之间不存在相加交互作用。接下来是param="dummy"时的计算方法:首先,建立代表共暴露、单暴露和无暴露的形式的变量,即建立一个变量,当酒精和香烟暴露均无暴露,赋值为0,仅暴露于酒精时赋值为1,仅暴露于香烟时赋值为2,同时暴露于香烟和酒精赋值为3。建立过程如下:##dummy法##

##建立代表共暴露、单暴露和无暴露的形式的变量##

data$exposure<-rep(NA,times=nrow(data))

data$exposure[data$alcohol==0&data$smoke==0]<-0

data$exposure[data$alcohol==1&data$smoke==0]<-1

data$exposure[data$alcohol==0&data$smoke==1]<-2

data$exposure[data$alcohol==1&data$smoke==1]<-3

data$exposure<-factor(data$exposure)##采用summary()函数,查看模型结果##

fit<-glm(outcome~exposure,family=binomial,data=data)

summary(fit)

Call:

glm(formula=outcome~exposure,family=binomial,data=data)

DevianceResiduals:

Min1QMedian3QMax

-1.309-1.3091.0511.0512.018

Coefficients:

EstimateStd.ErrorzvaluePr(>|z|)

(Intercept)-1.89710.6191-3.0640.002183**

exposure11.20400.79581.5130.130313

exposure21.08620.75091.4460.148045

exposure32.20120.62753.5080.000452***

---

Signif.codes:0'***'0.001'**'0.01'*'0.05'.'0.1''1

(Dispersionparameterforbinomialfamilytakentobe1)

Nulldeviance:633.45on457degreesoffreedom

Residualdeviance:605.93on454degreesoffreedom

AIC:613.93

NumberofFisherScoringiterations:4将上述模型结果,采用以下计算过程换算得到相加交互作用效应值和置信区间,此时需要修改param="dummy"。##RERI##

reri<-as.data.frame(eraction(fit,coef=c(2,3,4),param="dummy")[1])

round(reri,3)reri.estreri.lowerreri.upper

13.74-1.8379.316##AP##

ap<-as.data.frame(eraction(fit,coef=c(2,3,4),param="dummy")[2])

round(ap,3)apab.estapab.lowerapab.upper

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论