Loading Data

library(readr)
data_M5<- read_csv("C:/Users/gmutya048/Downloads/data (4).csv")
## 
## -- Column specification --------------------------------------------------------
## cols(
##   `Patient ID` = col_double(),
##   Gender = col_character(),
##   Race = col_character(),
##   Treatment = col_character(),
##   Improved = col_character()
## )
data_M5$Improved <- plyr::mapvalues(data_M5$Improved, from = c("Y", "N"), to = c("Yes", "No"))
data_M5$Gender <- plyr::mapvalues(data_M5$Gender, from = c("M", "F"), to = c("Male", "Female"))

Analysis

df1<-table(data_M5$Treatment, data_M5$Improved, data_M5$Gender)

mantelhaen.test(df1)
## 
##  Mantel-Haenszel chi-squared test with continuity correction
## 
## data:  df1
## Mantel-Haenszel X-squared = 17.26, df = 1, p-value = 3.26e-05
## alternative hypothesis: true common odds ratio is not equal to 1
## 95 percent confidence interval:
##   3.115328 23.921939
## sample estimates:
## common odds ratio 
##          8.632768
library(vcd)
## Loading required package: grid
woolf_test(df1)
## 
##  Woolf-test on Homogeneity of Odds Ratios (no 3-Way assoc.)
## 
## data:  df1
## X-squared = 0.02621, df = 1, p-value = 0.8714

There is no evidence to suggest that Gender impacts this joint association (??2 = 0.02621 p = 0.8714).

df2<-table(data_M5$Treatment, data_M5$Improved, data_M5$Race)

mantelhaen.test(df2) 
## 
##  Mantel-Haenszel chi-squared test with continuity correction
## 
## data:  df2
## Mantel-Haenszel X-squared = 13.457, df = 1, p-value = 0.0002441
## alternative hypothesis: true common odds ratio is not equal to 1
## 95 percent confidence interval:
##   2.238563 14.959234
## sample estimates:
## common odds ratio 
##          5.786811
library(vcd)

woolf_test(df2)
## 
##  Woolf-test on Homogeneity of Odds Ratios (no 3-Way assoc.)
## 
## data:  df2
## X-squared = 5.7032, df = 3, p-value = 0.127

Likewise there is no evidence to suggest that Race impacts this joint association (??2 = 5.7032 p = 0.127).

Tables and Figures

library(vcd)
mosaic(~Treatment +Improved, data = data_M5, shade=TRUE, legend=TRUE , main = "Improved", labeling = labeling_values)

library(vcd)
mosaic(~Treatment +Improved+Gender, data = data_M5, shade=TRUE, legend=TRUE , main = "Improved", labeling = labeling_values,)

library(vcd)
mosaic(~Treatment +Improved+Race, data = data_M5, shade=TRUE, legend=TRUE , main = "Improved", labeling = labeling_values)