使用epiR和purr::map或其他方法构建分层epi分析的最佳方法是什么?

使用epiR和purr::map或其他方法构建分层epi分析的最佳方法是什么?,r,loops,purrr,R,Loops,Purrr,这是我的数据(编辑-参见下面的可复制示例,准备输入): 我需要确定cov(%)与物质剥夺(mat2)、社会剥夺(soc2)和城市/农村地位(UR)的关系,以及按性别分层的情况。这意味着计算相对风险和风险差异。我也需要为每个7岁和17岁的孩子这样做 到目前为止,我打算按年龄进行筛选,并像这样单独进行分析(我还有5个区域数据集): 请提供一些现成的示例数据,例如使用dput()。请提供一些现成的示例数据,例如使用dput()。 ID Age Sex mat2

这是我的数据(编辑-参见下面的可复制示例,准备输入):

我需要确定cov(%)与物质剥夺(mat2)、社会剥夺(soc2)和城市/农村地位(UR)的关系,以及按性别分层的情况。这意味着计算相对风险和风险差异。我也需要为每个7岁和17岁的孩子这样做

到目前为止,我打算按年龄进行筛选,并像这样单独进行分析(我还有5个区域数据集):


请提供一些现成的示例数据,例如使用
dput()
。请提供一些现成的示例数据,例如使用
dput()
      ID       Age  Sex mat2                soc2                UR      cov
    1002523330  7   M   Lower deprivation   Higher deprivation  Urban   Yes
2   1005112260  7   F   Lower deprivation   Lower deprivation   Urban   Yes
3   1011043400  17  M   Higher deprivation  Higher deprivation  Rural   Yes
4   1015656900  17  F   Higher deprivation  Higher deprivation  Urban   No
6   1019107140  17  F   Lower deprivation   Higher deprivation  Urban   Yes
8   1028359840  17  F   Lower deprivation   Higher deprivation  Rural   No
lreg <- list(ispa.r = ispa.r, ispa.h = ispa.h,ispa.l= ispa.l, ispa.k = ispa.k) 
l7 <- lapply(lreg, function(x) filter(x, Age == 7)) 


tabh7 <- table(l7$ispa.h$mat2,l7$ispa.h$cov,l7$ispa.h$Sex)
rh7 <- epi.2by2(dat = tabh7, method = "cohort.count", 
                 conf.level = 0.95, units = 100, outcome = "as.columns")

#and copy and paste above for the remaining two predictors - soc2 and UR, then repeat for Age == 17 and for the remaining 4 regions
> dput(ispa.h [1:25,])
structure(list(ID = c("1016336950", "1028389950", "1028420100", 
"1028436670", "1028452360", "1028470250", "1028479560", "1028481260", 
"1028481890", "1028486640", "1028487390", "1028489410", "1028493420", 
"1028517680", "1028607180", "1028654080", "1028668740", "1028698070", 
"1028713520", "1037884040", "1049097290", "1049097330", "1049097380", 
"1049097400", "1049411570"), Age = c("7", "17", "17", "17", "17", 
"17", "17", "17", "17", "17", "17", "17", "17", "17", "17", "7", 
"7", "7", "7", "17", "17", "17", "17", "17", "7"), Sex = c("M", 
"F", "M", "F", "F", "F", "F", "F", "F", "M", "F", "F", "F", "F", 
"M", "M", "M", "F", "F", "M", "M", "M", "M", "F", "M"), mat2 = structure(c(1L, 
1L, 1L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 
1L, 1L, 2L, 2L, 2L, 2L, 2L, 1L), .Label = c("Higher deprivation", 
"Lower deprivation"), class = "factor"), soc2 = structure(c(2L, 
1L, 1L, 2L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 
1L, 1L, 2L, 2L, 2L, 2L, 2L, 1L), .Label = c("Higher deprivation", 
"Lower deprivation"), class = "factor"), UR = structure(c(2L, 
2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 
2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L), .Label = c("Rural", "Urban"), class = "factor"), 
    cov = structure(c(2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L
    ), .Label = c("Yes", "No"), class = "factor")), row.names = c(5L, 
9L, 10L, 11L, 12L, 13L, 14L, 16L, 17L, 19L, 20L, 21L, 22L, 23L, 
24L, 25L, 26L, 27L, 28L, 48L, 126L, 127L, 129L, 130L, 204L), class = "data.frame")