Sam Peterson s3722250
24/05/2021
Rpubs link: https://rpubs.com/SamDP222/773336
Image(Physicians Premier ER,2019)
a<-is.na(HA$DEATH_EVENT) %>% table
b<-is.na(HA$smoking) %>% table
knitr::kable(a,caption = 'NA values in "DEATH_EVENT"" variable')| . | Freq |
|---|---|
| FALSE | 299 |
| . | Freq |
|---|---|
| FALSE | 299 |
Dimensions of the total data set
## [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.')| 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.')| Alive | Dead | |
|---|---|---|
| Non-smoker | 0.458 | 0.221 |
| Smoker | 0.221 | 0.100 |
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'))##
## Pearson's Chi-squared test with Yates' continuity correction
##
## data: Table
## X-squared = 0.0073315, df = 1, p-value = 0.9318
\[\chi^{2}=\sum\frac{(Obs - Exp)^{2}}{Exp} \]
| 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.
Chicco, D. and Jurman, G. (2020). Machine learning can predict survival of patients with heart failure from serum creatinine and ejection fraction alone. BMC Medical Informatics and Decision Making, 20(1).
Healthline. (2018). Tobacco Allergy: Can You Be Allergic to Cigarette Smoke? [online] Available at: https://www.healthline.com/health/allergic-to-cigarette-smoke.
Mount Sinai Health System. (2017). Creatine phosphokinase test Information | Mount Sinai - New York. [online] Available at: https://www.mountsinai.org/health-library/tests/creatine-phosphokinase-test.
Physicians Premier ER. (2019). Life-Saving Facts About Heart Attack | Calallen, TX Emergency Room. [online] Available at: https://mdpremier.com/life-saving-facts-about-heart-attack/.
World Health Organization: WHO (2019). Cardiovascular diseases. [online] Who.int. Available at: https://www.who.int/health-topics/cardiovascular-diseases/#tab=tab_1.