washb_ttest: Paired t-test for the WASH Benefits trials

View source: R/washb_ttest.R

washb_ttestR Documentation

Paired t-test for the WASH Benefits trials

Description

Function to call the paired t-test for two different arms of the study.

Usage

washb_ttest(Y,tr,strat,contrast)

Arguments

Y

quantitative outcome variable (e.g. LAZ)

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

Details

washb_ttest estimates a paired t-test for differences in means paired within randomization blocks. The arguments Y,tr, and strat need to be from the same dataset.

Value

Returns a vector with the mean difference (diff), 95 percent confidence intervals (ci.lb and ci.ub), t-statistic (t-stat), and p-value (p) for the paired t-test

Examples

## Not run: 
#The washb_ttest function

 #Load in Bangladesh anthropometry data.
 data(washb_bangladesh_enrol)
 washb_bangladesh_enrol <- washb_bangladesh_enrol
 data(washb_bangladesh_anthro)
 washb_bangladesh_anthro <- washb_bangladesh_anthro

 washb_bangladesh_enrol$svydate <- NULL
 washb_bangladesh_enrol$month <- NULL
 laz <- merge(washb_bangladesh_enrol,washb_bangladesh_anthro,by=c("dataid","clusterid","block","tr"),all.x=F,all.y=T)

 # subset to the endline target children
 laz <- subset(laz,svy==2)
 laz <- subset(laz,tchild=="Target child")

 # Drop children with extreme LAZ values
 laz <- subset(laz,laz_x!=1)

 laz$tr <- factor(laz$tr,levels=c("Control","Water","Sanitation","Handwashing","WSH","Nutrition","Nutrition + WSH"))


 #Run paired ttest function for water vs. control comparison:
 washb_ttest(Y=laz$laz,tr=laz$tr,strat=laz$block, contrast=c("Control","Water"))

## End(Not run)

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