I. Introduction

patients <- read.csv("C:/Users/Lisa/Downloads/patients.csv")

II. Data

mosaicplot(obese ~ gender, data = patients, main = "Weight Category by Gender", color=c("purple","red"))

two.cat = table(patients$gender,patients$obese)
two.cat
##    
##     normal obese overweight underweight
##   F    700   994        744          51
##   M    605   846        953          22

III. Analysis

gender.obese.table = table(patients$gender,patients$obese)
another.test = chisq.test(gender.obese.table,correct = FALSE)
gender.obese.table
##    
##     normal obese overweight underweight
##   F    700   994        744          51
##   M    605   846        953          22

Our test-statistic is 55.2822891, with p-value 5.977087710^{-12}.

The \(e_{ij}\) values are:

another.test$expected
##    
##       normal    obese overweight underweight
##   F 660.8637 931.7925    859.376    36.96785
##   M 644.1363 908.2075    837.624    36.03215

The \(o_{ij}\) values are:

gender.obese.table
##    
##     normal obese overweight underweight
##   F    700   994        744          51
##   M    605   846        953          22