washb_mh(Y,tr,strat,contrast,measure="RR")
Mantel-Haenszel Pooled estimates of the prevalence ratio (PR) or the prevalence difference (PD) using randomization block as the stratification variable.
The function calls the M-H estimator for two different arms of the study. It relies on the rma.mh() function in the metafor package.
Estimate the Mantel-Haenszel prevalence ratio note: strata with no outcomes (i.e., missing PR) are dropped. This is consistent with a fixed-effects regression analysis, in which those strata would not contribute to the estimates. The arguments Y,tr,strat, below need to be from the same dataset.
#Prescreen function applied to the Bangladesh diarrheal disease outcome. #The function will test a matrix of covariates and return those related to child diarrheal disease with #a <0.2 p-value from a likelihood ratio test. #Load diarrhea data library(washb) data(washb_bd_diar) data(washb_bd_enrol) # drop svydate and month because they are superceded in the child level diarrhea data washb_bd_enrol$svydate <- NULL washb_bd_enrol$month <- NULL # merge the baseline dataset to the follow-up dataset ad <- merge(washb_bd_enrol,washb_bd_diar,by=c("dataid","clusterid","block","tr"),all.x=F,all.y=T) # subset to the relevant measurement # Year 1 or Year 2 ad <- subset(ad,svy==1|svy==2) #subset the diarrhea to children <36 mos at enrollment ### (exlude new births that are not target children) ad <- subset(ad,sibnewbirth==0) ad <- subset(ad,gt36mos==0) # Exclude children with missing data ad <- subset(ad,!is.na(ad$diar7d)) #Re-order the tr factor for convenience ad$tr <- factor(ad$tr,levels=c("Control","Water","Sanitation","Handwashing","WSH","Nutrition","Nutrition + WSH")) ###Create vector of contrasts for each hypothesis to facilitate comparisons between arms. #Hypothesis 1: Each intervention arm vs. Control h1.contrasts <- list( c("Control","Water"), c("Control","Sanitation"), c("Control","Handwashing"), c("Control","WSH"), c("Control","Nutrition"), c("Control","Nutrition + WSH") ) #Apply washb_mh to the water vs. control arm contrast. washb_mh(Y=ad$diar7d,tr=ad$tr, contrast=c("Control","Water"), strat=ad$block,measure="RR")PR, ci.lb ci.ub logPR se.logPR Z p 0.7898050 0.5793340 1.0767399 -0.2359692 0.1581187 -1.4923542 0.1356063#Return the risk difference instead of the risk ration: washb_mh(Y=ad$diar7d,tr=ad$tr, contrast=c("Control","Water"), strat=ad$block,measure="RD")RD se.RD ci.lb ci.ub Z p -0.008315341 0.005348086 -0.018797397 0.002166714 -1.554825694 0.119987588#Use sapply command to efficiently apply the function to all the treatment arm contrasts diff.h1 <- t(sapply(h1.contrasts,washb_mh,Y=ad$diar7d,tr=ad$tr,strat=ad$block,measure="RR")) rownames(diff.h1) <- c("Water v C","Sanitation v C","Handwashing v C","WSH v C","Nutrition v C","Nutrition + WSH v C") print(diff.h1)PR, ci.lb ci.ub logPR se.logPR Z p Water v C 0.7898050 0.5793340 1.076740 -0.23596915 0.1581187 -1.4923542 0.135606316 Sanitation v C 1.1676839 0.8962390 1.521342 0.15502223 0.1349874 1.1484202 0.250795139 Handwashing v C 1.2307787 0.9493770 1.595590 0.20764708 0.1324495 1.5677447 0.116940720 WSH v C 0.9375256 0.6999909 1.255665 -0.06451118 0.1490725 -0.4327504 0.665196128 Nutrition v C 1.0946230 0.8303822 1.442949 0.09040999 0.1409614 0.6413813 0.521274952 Nutrition + WSH v C 1.4996864 1.1705008 1.921450 0.40525600 0.1264433 3.2050413 0.001350431