Research Scenario 2: Medication A vs Medication B

A medical research team created a new medication to reduce headaches (Medication A). They want to determine if Medication A is more effective at reducing headaches than the current medication on the market (Medication B). A group of participants were randomly assigned to either take Medication A or Medication B. Data was collected for 30 days through an app and participants reported each day if they did or did not have a headache. Was there a difference in the number of headaches between the groups?

Hypothesis

H0: There is no difference between the number of headaches of who took medication A and medication B

H1: There is a difference between the number of headaches of who took medication A and medication B

Load Required Library

library(readxl)

Read dataset

dataset <- read_excel("~/Downloads/A6R1.xlsx")

Descriptive Statistics

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

Calculate the Descriptive Statistics

dataset %>%
  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 × 5
##   Medication  Mean Median    SD     N
##   <chr>      <dbl>  <dbl> <dbl> <int>
## 1 A            8.1    8    2.81    50
## 2 B           12.6   12.5  3.59    50

Histograms

hist(dataset$HeadacheDays[dataset$Medication == "A"],
main = "Histogram of A Scores",
xlab = "Value",
ylab = "Frequency",
col = "lightblue",
border = "black",
breaks = 20)

hist(dataset$HeadacheDays[dataset$Medication == "B"],
main = "Histogram of B Scores",
xlab = "Value",
ylab = "Frequency",
col = "lightgreen",
border = "black",
breaks = 20)

QUESTIONS: Histogram Analysis

Q1) Check the SKEWNESS of the VARIABLE 1 histogram. In your opinion, does the histogram look symmetrical, positively skewed, or negatively skewed?

A) The histogram looks symmetrical

Q2) Check the KURTOSIS of the VARIABLE 1 histogram. In your opinion, does the histogram look too flat, too tall, or does it have a proper bell curve?

A) The histogram too tall

Q3) Check the SKEWNESS of the VARIABLE 2 histogram. In your opinion, does the histogram look symmetrical, positively skewed, or negatively skewed?

A) The histogram looks symmetrical

Q4) Check the KUROTSIS of the VARIABLE 2 histogram. In your opinion, does the histogram look too flat, too tall, or does it have a proper bell curve?

A) The histogram too tall

Shapiro-wilk Test

shapiro.test(dataset$HeadacheDays[dataset$Medication == "A"])
## 
##  Shapiro-Wilk normality test
## 
## data:  dataset$HeadacheDays[dataset$Medication == "A"]
## W = 0.97852, p-value = 0.4913
shapiro.test(dataset$HeadacheDays[dataset$Medication == "B"])
## 
##  Shapiro-Wilk normality test
## 
## data:  dataset$HeadacheDays[dataset$Medication == "B"]
## W = 0.98758, p-value = 0.8741

Answer the questions below as a comment within the R script: Was the data normally distributed for Variable 1? A) The data is normal for variable 1 (p = 0.4913, which is > 0.05) Was the data normally distributed for Variable 2? A) The data is normal for variable 2 (p = 0.8741, which is > 0.05)

Load Required Library

library(ggplot2)
library(ggpubr)

Create the Boxplot

ggboxplot(dataset, x = "Medication", y = "HeadacheDays",
          color = "Medication",
          palette = "jco",
          add = "jitter")

QUESTION

Q) Were there any dots outside of the boxplot? Are these dots close to the whiskers of the boxplot or are they very far away?

A) There are no dots outside the boxplot, So continue with Independent t-test.

Test if there was a difference between the means of the two groups.

t.test(HeadacheDays ~ Medication, data = dataset, 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

DETERMINE STATISTICAL SIGNIFICANCE

The results are statistically significant continue to effect size

Effect Size

library(effectsize)

Calculate the effect size

cohens_d_result <- cohens_d(HeadacheDays ~ Medication, data = dataset, pooled_sd = TRUE)
print(cohens_d_result)
## Cohen's d |         95% CI
## --------------------------
## -1.40     | [-1.83, -0.96]
## 
## - Estimated using pooled SD.

Final Report

An Independent t-test was conducted to compare headache days between patients who took Medication A (n = 50) and patients who took Medication B (n = 50). Patients who took Medication A had significantly fewer headache days (M = 8.10, SD = 2.81) than patients who took Medication B (M = 12.60, SD = 3.59), t(98) = -6.99, p < .001. The effect size was large (d = -1.40), indicating a very large difference between the two medications. Overall, Medication A resulted in significantly fewer headache days than Medication B.