washb_permute: Conditional permutation test using the Wilcoxon signed rank...

View source: R/washb_permute.R

washb_permuteR Documentation

Conditional permutation test using the Wilcoxon signed rank statistic in the WASH Benefits trials

Description

WASH Benefits Wilcoxon Signed Rank permutation test function for two treatment arms conditional on randomization block. Conducts a permutation test of the independence of Y and tr, conditional on randomization block using the Wilcoxon rank-sum test statistic.

Usage

washb_permute(Y,tr,pair,contrast,nreps=100000,seed=NULL)

Arguments

Y

Outcome variable (continuous, such as LAZ, or binary, such as diarrhea)

tr

Binary treatment group variable (ideally a factor), comparison group first

pair

Pair-matched randomization ID variable (in WASH Benefits: block)

contrast

Vector of length 2 that includes the groups to contrast, e.g., c("Control","Water")

nreps

Number of permutations to run.

seed

Number for psuedo-random number generation in R

print

If print==FALSE, suppress printed output.

Details

The washb_glm and washb_tmle related functions enable us to test hypotheses about whether the average outcome differs between trial arms – that is, whether the difference in means is equal to zero. The mean is just one function of the outcome distribution. A sharper test is the “sharp null hypothesis” first proposed by Ronald Fisher, in which we test whether there is any difference at all in the outcome distributions between intervention arms. Under the null hypothesis of no treatment effect, the outcome distributions should be indistinguishable from random sampling variation. A way to test the sharp null hypothesis is with a permutation test (also called a Fisher randomization test). The intuition behind the test is that there is a single source of random variation in the trial: namely the random allocation of treatment. If we re-randomize treatment in every possible combination (or a very large number of combinations), and compare arms using a test statistic for each combination, then this provides us with the test statistic’s distribution under the null hypothesis of no effect (since we re-shuffle treatment in each iteration, it is completely uninformative). We can then compare the observed test statistic with real group assignments to the null distribution to see how likely it would be to have occurred by chance. For more details on randomization tests, see the references below.

In the WASH Benefits primary analysis, we pre-specified that we would test this sharp null using a Wilcoxon signed rank test, which is a non-parametric test statistic has been shown to have good power against alternatives for outcomes that could potentially have skewed distributions [Imbens GW, Rubin DB. Causal Inference in Statistics, Social, and Biomedical Sciences. Cambridge University Press; 2015.](http://dl.acm.org/citation.cfm?id=2764565).

Value

A list of four slices (replace "~" with the assigned object name): ~$p.value The permutation test p-value ~$Z The z-statistic ~$Ho ~$W The full output of the wilcoxsign_test function called within the washb_permute function.

References

1. Gail, M. H., Mark, S. D., Carroll, R. J., Green, S. B. & Pee, D. On Design Considerations and Randomization-Based Inference for Community Intervention Trials. Statist. Med. 15, 1069–1092 (1996). [Link](http://onlinelibrary.wiley.com/doi/10.1002/(SICI)1097-0258(19960615)15:11 2. Braun, T. M. & Feng, Z. Optimal Permutation Tests for the Analysis of Group Randomized Trials. Journal of the American Statistical Association 96, 1424–1432 (2001). [Link](http://www.tandfonline.com/doi/abs/10.1198/016214501753382336) 3. Rosenbaum, P. R. Covariance Adjustment in Randomized Experiments and Observational Studies. Statist. Sci. 17, 286–327 (2002). [Link](http://projecteuclid.org/euclid.ss/1042727942)

Examples

#Unadjusted permutation test of Bangladesh diarrheal disease primary outcome

#######################
#Load and clean data
#######################
data(washb_bangladesh_enrol)
washb_bangladesh_enrol <- washb_bangladesh_enrol
data(washb_bangladesh_diar)
washb_bangladesh_diar <- washb_bangladesh_diar

 # 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=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"))

#Ensure that month is coded as a factor
ad$month <- factor(ad$month)

#Sort the data for perfect replication when using V-fold cross-validation
ad <- ad[order(ad$block,ad$clusterid,ad$dataid,ad$childid),]

#Unadjusted permutation test of Bangladesh diarrheal disease outcome.

# Hypothesis 1 permutation tests (Intervention arms vs. control arms)
set.seed(242524)
permute.C.W <- washb_permute(Y=ad$diar7d,tr=ad$tr,pair=ad$block,contrast=c("Control","Water"),nreps=100000)
permute.C.S <- washb_permute(Y=ad$diar7d,tr=ad$tr,pair=ad$block,contrast=c("Control","Sanitation"),nreps=100000)
permute.C.H <- washb_permute(Y=ad$diar7d,tr=ad$tr,pair=ad$block,contrast=c("Control","Handwashing"),nreps=100000)
permute.C.WSH <- washb_permute(Y=ad$diar7d,tr=ad$tr,pair=ad$block,contrast=c("Control","WSH"),nreps=100000)
permute.C.N   <- washb_permute(Y=ad$diar7d,tr=ad$tr,pair=ad$block,contrast=c("Control","Nutrition"),nreps=100000)
permute.C.NWSH <- washb_permute(Y=ad$diar7d,tr=ad$tr,pair=ad$block,contrast=c("Control","Nutrition + WSH"),nreps=100000)

# put objects in the standard format
h1res <- list(permute.C.W,permute.C.S,permute.C.H,permute.C.WSH,permute.C.N,permute.C.NWSH)
diar_h1_pval_unadj <- as.matrix(sapply(h1res,function(x) x$p.value),nrow=6)
rownames(diar_h1_pval_unadj) <- c("Water v C","Sanitation v C","Handwashing v C","WSH v C","Nutrition v C","Nutrition + WSH v C")

# print results
diar_h1_pval_unadj

ben-arnold/washb documentation built on Dec. 11, 2023, 7:06 p.m.