自学内容网 自学内容网

R语言NHANES数据分析(2)

#交互分析
library(jstable)
help(package="nhanesA")
help(package="jstable")
str(data_c)
svy_design$variables$DMDCITZN<-as.factor(svy_design$variables$DMDCITZN)
TableSubgroupMultiGLM(BPQ020~BMXBMI,data=svy_design,var_subgroups = c("DMDCITZN"))

#中介分析
library(mediation)
#install.packages("mma")
help(package="mma")
svy_design <- survey::svydesign(strata= ~SDMVSTRA, id = ~SDMVPSU, weights = ~WTINT2YR, nest = TRUE,data = data_c)
result<-survey::svyglm(BPQ020~BMXBMI, family = gaussian(), design = svy_design)
result1<-survey::svyglm(DMDCITZN~BMXBMI, family = gaussian(), design = svy_design)
med_out <- mediate(model.m=result1, model.y=result, 
                   treat = "BMXBMI", 
                   mediator = "BPQ020",
                   boot = TRUE)
summary(med_out)

接之前代码,完成交互分析和中介分析。

结果解读:

交互分析:

中介分析:

ACME间接效应,P值大于0.05,无统计学意义。

ADE直接效应,P值小于0.05,有统计学意义,说明BMXBMI对DMDCITZN的影响主要通过直接效应。


原文地址:https://blog.csdn.net/weixin_49320263/article/details/142317371

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!