This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
heart_failure <- read_csv(file = “C:/Users/Arene Butto/Documents/MSCR/MSCR 598 - B2K/clinical_heart-failure.csv”) view(heart_failure)
head(heart_failure) tail(heart_failure) dim(heart_failure)
summary(heart_failure)
library(skimr) skim(heart_failure)
library(gtsummary)
tbl_summary(heart_failure, by = smoking) %>% add_p()
fit_lm <- lm(serum_creatinine ~ age + anaemia + creatinine_phosphokinase + diabetes + ejection_fraction + high_blood_pressure + platelets + serum_sodium + sex, data = heart_failure) summary(fit_lm)
c <- 0 point <- tribble(~age, ~anaemia, ~creatinine_phosphokinase, ~diabetes, ~ejection_fraction, ~high_blood_pressure, ~platelets, ~serum_sodium, ~sex, ~smoking, ~death, 70, c, c, 1, c, 1, c, 130, c, c, c) point predict(fit_lm, point)
fit_glm <- glm(death ~ age + anaemia + creatinine_phosphokinase + diabetes + ejection_fraction + high_blood_pressure + platelets + serum_sodium + sex, data = heart_failure, family = “binomial”) summary(fit_glm) ## Predictors for death are age, ejection fraction, and serum sodium
tidy(fit_glm, exponentiate = TRUE) augment(fit_glm, type.predict = “response”)
library(yardstick) roc_glm <- augment(fit_glm, type.predict = “response”)
roc_curve(roc_glm, TRUTH = death, .fitted, event_level = “second”) %>% autoplot()
rlang::last_error()