Mantel-Haenszel pooled estimates of the prevalence ratio (PR) or the prevalence difference (PD) using randomization block as the stratification variable.

washb_mh(Y,tr,strat,contrast,measure="RR")

Arguments

Y

binary outcome variable (here: diar7d)

tr

binary treatment group variable, comparison group first

strat

stratification variable (here: block)

contrast

vector of length 2 that includes the tr groups to contrast (control(reference arm) and then intervention)

measure

measure of effect. RR = prev ratio, RD = prev difference

Value

res: Matrix of RD, se.RD, ci.lb, ci.ub, Z, p-value.

Details

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.

Examples

#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_bangladesh_diar) washb_bangladesh_diar <- washb_bangladesh_diar data(washb_bangladesh_enrol) washb_bangladesh_enrol <- washb_bangladesh_enrol # drop svydate and month because they are superceded in the child level diarrhea data washb_bangladesh_enrol$svydate <- NULL washb_bangladesh_enrol$month <- NULL # merge the baseline dataset to the follow-up dataset ad <- merge(washb_bangladesh_enrol,washb_bangladesh_diar,by=c("dataid","clusterid","block","tr"),all.x=FALSE,all.y=TRUE) # 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.8882606 0.6966217 1.1326188 -0.1184901 0.1239934 -0.9556162 0.3392662
#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.006287385 0.006478159 -0.018984344 0.006409574 -0.970551083 0.331771875
#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 #> Water v C 0.8882606 0.6966217 1.1326188 -0.1184901 0.1239934 #> Sanitation v C 0.6084525 0.4569245 0.8102311 -0.4968365 0.1461255 #> Handwashing v C 0.6001693 0.4526173 0.7958228 -0.5105435 0.1439643 #> WSH v C 0.6916926 0.5309844 0.9010409 -0.3686137 0.1349050 #> Nutrition v C 0.6437575 0.4872484 0.8505389 -0.4404332 0.1421190 #> Nutrition + WSH v C 0.6193351 0.4708506 0.8146448 -0.4791088 0.1398524 #> Z p #> Water v C -0.9556162 0.3392661732 #> Sanitation v C -3.4000675 0.0006736921 #> Handwashing v C -3.5463216 0.0003906492 #> WSH v C -2.7323934 0.0062876008 #> Nutrition v C -3.0990454 0.0019414528 #> Nutrition + WSH v C -3.4258172 0.0006129528