# load your libraries
library(ggplot2)Practice Assessment Solution
Read In Your Data
anorexia <- read.delim('https://raw.githubusercontent.com/IowaBiostat/data-sets/main/anorexia/anorexia.txt')
treat_only <- subset(anorexia, Treat != "Control")Visualization
ggplot(treat_only, aes(x = Prewt)) +
geom_histogram(bins = 15)
ggplot(treat_only, aes(x = Postwt))+
geom_histogram(bins = 15)Numerical Summary
mean(treat_only$Prewt)[1] 82.88913
mean(treat_only$Postwt)[1] 87.46957
Conduct a test
pre <- treat_only$Prewt
post <- treat_only$Postwt
t.test(post, pre, paired = TRUE)
Paired t-test
data: post and pre
t = 4.16, df = 45, p-value = 0.0001413
alternative hypothesis: true mean difference is not equal to 0
95 percent confidence interval:
2.362776 6.798094
sample estimates:
mean difference
4.580435
Conclusion/Interpretation
There is strong evidence that anorexic patients who received any treatment have higher post-treatment weight on average. Plausible values for the true effect size (weight gain) given by the confidence interval are between 2.4 and 6.8 pounds.