What are the null and alternate hypotheses for YOUR research scenario?
H0: There is no difference in the number of headaches between the participants who take medication A and medication B
H1: There is a difference in the number of headaches between the participants who take medication A and medication B
library(readxl)
A6R1 <- read_excel("C:/Users/odhee/Downloads/A6R1.xlsx")
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
A6R1 %>%
group_by(Medication) %>%
summarise(
# Mean = mean(HeadacheDays, na.rm = TRUE),
Median = median(HeadacheDays, na.rm = TRUE),
SD = sd(HeadacheDays, na.rm = TRUE),
N = n()
)
## # A tibble: 2 Ă— 4
## Medication Median SD N
## <chr> <dbl> <dbl> <int>
## 1 A 8 2.81 50
## 2 B 12.5 3.59 50
hist(A6R1$HeadacheDays[A6R1$Medication == "A"],
main = "Histogram of Medication A Headache days",
xlab = "Value",
ylab = "Frequency",
col = "lightblue",
border = "black",
breaks = 20)
hist(A6R1$HeadacheDays[A6R1$Medication == "B"],
main = "Histogram of Medication B HeadacheDays",
xlab = "Value",
ylab = "Frequency",
col = "lightgreen",
border = "black",
breaks = 20)
Q1) Check the SKEWNESS of the medication A histogram. In your opinion, does the histogram look symmetrical, positively skewed, or negatively skewed?
Approximately Symmetrical and is slightly postively skewed
Q2) Check the KURTOSIS of the medication A histogram. In your opinion, does the histogram look too flat, too tall, or does it have a proper bell curve?
Proper Bell Curve
Q3) Check the SKEWNESS of the medication B histogram. In your opinion, does the histogram look symmetrical, positively skewed, or negatively skewed?
Positively skewed
Q4) Check the KUROTSIS of the medication B histogram. In your opinion, does the histogram look too flat, too tall, or does it have a proper bell curve?
Too flat
shapiro.test(A6R1$HeadacheDays[A6R1$Medication == "A"])
##
## Shapiro-Wilk normality test
##
## data: A6R1$HeadacheDays[A6R1$Medication == "A"]
## W = 0.97852, p-value = 0.4913
shapiro.test(A6R1$HeadacheDays[A6R1$Medication == "B"])
##
## Shapiro-Wilk normality test
##
## data: A6R1$HeadacheDays[A6R1$Medication == "B"]
## W = 0.98758, p-value = 0.8741
Was the data normally distributed for Medication?
Normal
Was the data normally distributed for Headache days?
Normal
library(ggplot2)
library(ggpubr)
ggboxplot(A6R1, x = "Medication", y = "HeadacheDays",
color = "Medication",
palette = "jco",
add = "jitter")
Q1) Were there any dots outside of the boxplot? Are these dots close to the whiskers of the boxplot (check if there are any dots past the lines on the boxes) or are they very far away?
There are a few dots (two or less), and they are close to the whiskers, So we are continuing with the Independent t-test.
t.test(HeadacheDays ~ Medication, data = A6R1, var.equal = TRUE)
##
## Two Sample t-test
##
## data: HeadacheDays by Medication
## t = -6.9862, df = 98, p-value = 3.431e-10
## alternative hypothesis: true difference in means between group A and group B is not equal to 0
## 95 percent confidence interval:
## -5.778247 -3.221753
## sample estimates:
## mean in group A mean in group B
## 8.1 12.6
library(effectsize)
cohens_d_result <- cohens_d(HeadacheDays ~ Medication, data = A6R1, pooled_sd = TRUE)
print(cohens_d_result)
## Cohen's d | 95% CI
## --------------------------
## -1.40 | [-1.83, -0.96]
##
## - Estimated using pooled SD.
What is the size of the effect?
A Cohen’s D of 1.40 indicates the difference between the group averages was very large.
Which group had the higher average score?
Medication B had a higher average number of headache days than Medication A.
Final Report
An Independent t-test was conducted to compare the number of headaches between the participants who take medication A (n = 50) and who take medication B (n = 50). Participants who take medication B significantly higher (M = 12.6, SD = 3.59) than Participants who take medication A (M = 8.1, SD = 2.81), t(118) = -6.9862, p = 3.431e-10. The effect size was very large (d = 1.40), indicating a very large difference between participants who take medication A and participants who take medication B. Overall, participants who take medication B has higher average number of headaches.