In: Statistics and Probability
The dataset ’anorexia’ in the MASS package in R-Studio contains
data for an anorexia study. In the study, three treat-
ments (Treat) were applied to groups of young female anorexia
patients, and their weights before (Prewt) and after (Postwt)
treatment were recorded. The three treatments adminstered were
no treatment (Cont), Cognitive Behavioural treatment
(CBT), and family treatment (FT).
Determine at the 5% significance level if there is a difference in
mean weight gain between those receiving no treatment
and those receiving Cognitive behavioral treatment. Perform all
necessary steps for the hypothesis test and interpret your
re-
sults in the context of the study. Assume random selection and
normal population distribution for all samples and populations.
Important: Make sure the MASS package is selected under the
packages tab in R-Studio.
Useful Tip: The command subset(anorexia, Treat == "Cont")$Prewt
could be used to access just the Prewt values
for subjects in the Cont treatment group.
This is the code/data I have:
> library(MASS)
> attach(anorexia)
> data=anorexia
> newdata=data[Treat=="FT",]
> newdata
Treat Prewt Postwt
56 FT 83.8 95.2
57 FT 83.3 94.3
58 FT 86.0 91.5
59 FT 82.5 91.9
60 FT 86.7 100.3
61 FT 79.6 76.7
62 FT 76.9 76.8
63 FT 94.2 101.6
64 FT 73.4 94.9
65 FT 80.5 75.2
66 FT 81.6 77.8
67 FT 82.1 95.5
68 FT 77.6 90.7
69 FT 83.5 92.5
70 FT 89.9 93.8
71 FT 86.0 91.7
72 FT 87.3 98.0
> test=t.test(data$Postwt,data$Prewt,alt="greater")
> test
The R output is:
The R code is:
library(MASS)
attach(anorexia)
data=anorexia
newdata=data[Treat=="FT",]
newdata
t.test(data$Postwt,data$Prewt,paired = TRUE, alternative
="two.sided")
The hypothesis being tested is:
H0: µd = 0
Ha: µd ≠ 0
p-value = 0.0044
Since the p-value (0.0044) is less than the significance level (0.05), we can reject the null hypothesis.
Therefore, we can conclude that
there is a difference in mean weight gain between those receiving no treatment and those receiving Cognitive-behavioral treatment.
Please give me a thumbs-up if this helps you out. Thank you!