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的影响主要通过直接效应。