Does smoking alter your chance of surviving a heart attack?

Sam Peterson s3722250

24/05/2021

Introduction

Rpubs link: https://rpubs.com/SamDP222/773336

Image(Physicians Premier ER,2019)

Problem Statement

Data

Data Cont.

HA$age <- round(HA$age, digits = 0)
HA$DEATH_EVENT <- factor(HA$DEATH_EVENT,
                         levels = c(0,1),
                         labels = c("Alive", "Dead")
                         )
HA$smoking <- factor(HA$smoking,
                         levels = c(0,1),
                         labels = c("Non-smoker","Smoker")
                         )

Checking for NA values

a<-is.na(HA$DEATH_EVENT) %>% table 
b<-is.na(HA$smoking) %>% table

knitr::kable(a,caption = 'NA values in "DEATH_EVENT"" variable')
NA values in “DEATH_EVENT”" variable
. Freq
FALSE 299
knitr::kable(b,caption = 'NA values in "smoking"" variable')          
NA values in “smoking”" variable
. Freq
FALSE 299

Descriptive Statistics

Dimensions of the total data set

dim(HA)
## [1] 299  13
Table <- table(HA$smoking,HA$DEATH_EVENT) 
TableMargin <- Table %>% addmargins()
knitr::kable(TableMargin, caption = 'Value counts of the patients within both the catagories.')
Value counts of the patients within both the catagories.
Alive Dead Sum
Non-smoker 137 66 203
Smoker 66 30 96
Sum 203 96 299
propTable <- Table %>% prop.table
knitr::kable(propTable, digits = 3, caption = 'Proportion of patients within each category.')
Proportion of patients within each category.
Alive Dead
Non-smoker 0.458 0.221
Smoker 0.221 0.100

Visualisation

barplot(propTable, main ="Heart attack survival by smoker status",
        ylab="Proportion of smokers"
        ,ylim=c(0,1),legend=rownames(propTable),beside=TRUE,
        args.legend=c(x ="topright",horiz=TRUE,
        title="Smoker status"),xlab="Survival", col = c('BLUE','RED'))

Hypothesis Testing

chitest<- chisq.test(Table)
chitest
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  Table
## X-squared = 0.0073315, df = 1, p-value = 0.9318

Hypthesis Testing Cont.

\[\chi^{2}=\sum\frac{(Obs - Exp)^{2}}{Exp} \]

knitr::kable(chitest$expected, caption = 'Assumption test')
Assumption test
Alive Dead
Non-smoker 137.82274 65.17726
Smoker 65.17726 30.82274

As seen from the assumption test no cell counts were below five. The Assumption of no more than 25% of expected cell counts are below 5 was met.

\(\chi^{2}\)=0.0073315
– df = 1
– p-value = 0.931
As the p-value is not <0.05 we fail to reject the null hypothesis. This causes the conclusion of there being no significant difference between smokers and non smokers in their chance to survive a heart attack to be made.

Discussion

References