Lecturer:
Don’t forget to set your working directory first by click the “session” tab -> “Set Working Directory” -> save your script as “YOUR NAME_UAS_BIOSTAT.R”!
Change “YOUR NAME” into your real name!
169 instances (rows) 2 features (columns)
Diarrhea is a major public health problem in underdeveloped countries, especially for babies. Diarrhea leads to dehydration, which results in millions of deaths each year worldwide. Bismuth salicylate (the active ingredient in Pepto Bismol) has been shown to reduce diarrhea in adults. Researchers in Peru conducted a double-blind randomized controlled trial to determine whether it would do so in infants suffering from diarrhea as well.
In their study, all infants received the standard therapy for diarrhea: oral rehydration. In addition to the rehydration, 85 babies received bismuth salicylate, while 84 babies received a placebo. The total stool volumes for all infants over the course of their illness was measured. To adjust for body size, the researchers divided by body weight to obtain their outcome of interest: stool output per kilogram of body weight.
Group: Therapy group (Control, Treatment) Stool: Stool output (ml/kg)
Figueroa-Quintanilla D, Salazar-Lindo E, Sack RB, Leon-Barua R, Sarabia-Arce S, Campos-Sanchez M, and Eyzaguirre-Maccan E. (1993). A controlled trial of bismuth subsalicylate in infants with acute watery diarrheal disease. New England Journal of Medicine, 328: 1653-1658.
diarrhea <- read.delim(
"https://raw.githubusercontent.com/IowaBiostat/data-sets/main/diarrhea/diarrhea.txt"
)The dataset comes from a double-blind randomized controlled trial. Randomization justifies causal comparison between Treatment and Control groups.
There are 169 infants: 84 in the Control group and 85 in the Treatment group. The outcome variable (Stool) is continuous and measured in ml/kg.
desc_stats <- diarrhea %>%
group_by(Group) %>%
summarise(
n = n(),
mean = mean(Stool),
median = median(Stool),
sd = sd(Stool),
IQR = IQR(Stool),
min = min(Stool),
max = max(Stool)
)The Treatment group shows lower mean and median stool output than the Control group. Both groups display large variability and extreme values, suggesting right-skewness.
boxplot(
Stool ~ Group,
data = diarrhea,
col = c("lightgray", "lightblue"),
ylab = "Stool Output (ml/kg)",
main = "Stool Output by Treatment Group"
)par(mfrow = c(1,2))
hist(diarrhea$Stool[diarrhea$Group == "Control"],
main = "Control", xlab = "Stool", col = "gray")
hist(diarrhea$Stool[diarrhea$Group == "Treatment"],
main = "Treatment", xlab = "Stool", col = "lightblue")
par(mfrow = c(1,1))Boxplots and histograms reveal strong right-skewness in both groups. Several extreme values indicate severe diarrhea episodes. The Treatment group appears to have lower central tendency.
Shapiro–Wilk tests reject normality in both groups (p < 0.05). Normality assumptions for classical parametric tests are violated.
Bartlett’s test indicates unequal variances between groups. Welch’s t-test or non-parametric methods are therefore preferred.
Welch’s t-test shows a statistically significant difference in mean stool output. The Treatment group has a lower mean stool output than the Control group. This suggests bismuth salicylate reduces diarrhea severity.
The Wilcoxon rank-sum test confirms a significant difference between groups. This result is robust to skewness and outliers. Non-parametric inference is more appropriate for these data.
Cohen’s d indicates a small-to-moderate treatment effect. Given the clinical context, even moderate reductions in stool output are meaningful.
The negative mean difference indicates lower stool output in the Treatment group. This aligns with both parametric and non-parametric findings.
boxplot(
log_stool ~ Group,
data = diarrhea,
col = c("gray", "lightblue"),
ylab = "log(Stool Output)",
main = "Log-Transformed Stool Output"
)Log transformation reduces skewness and stabilizes variance. Results remain statistically significant, supporting robustness of conclusions. Effects can be interpreted as relative (percentage) reductions.
Linear regression estimates the same group difference as the t-test. The model framework allows extension to covariate-adjusted analyses.
Quantile regression shows a reduction in median stool output. This method is resistant to extreme values and clinically informative.
The Treatment group shows a lower proportion of severe diarrhea cases. This reframes the effect in clinically actionable terms (risk reduction).
mean_diff_fn <- function(data, index) {
d <- data[index, ]
mean(d$Stool[d$Group == "Treatment"]) -
mean(d$Stool[d$Group == "Control"])
}Bootstrap confidence intervals do not rely on normality assumptions. The interval excluding zero confirms a statistically significant treatment effect.
perm_test <- function(data, n_perm = 5000) {
obs <- mean(data$Stool[data$Group == "Treatment"]) -
mean(data$Stool[data$Group == "Control"])
perm_diffs <- replicate(n_perm, {
perm_group <- sample(data$Group)
mean(data$Stool[perm_group == "Treatment"]) -
mean(data$Stool[perm_group == "Control"])
})
p_value <- mean(abs(perm_diffs) >= abs(obs))
list(observed = obs, p_value = p_value)
}Permutation testing aligns directly with the randomized trial design. The small p-value provides strong randomization-based evidence of treatment efficacy.
Save your script as “YOUR NAME_UAS_BIOSTAT.R”
Then run this code below
Important: Change ““YOUR_NAME” into your real name!
Across parametric, non-parametric, robust, and resampling methods, bismuth salicylate consistently reduces stool output in infants with diarrhea. The effect is statistically robust, clinically meaningful, and causally interpretable due to the randomized controlled trial design.