Disclaimer: I'm about one week into my R journey
No matter what I do I cannot get knit to pdf to work. The error I get says:
Error in eval(expr, envir, enclos) : object 'thomas_binomial_f' not found
Calls: ... handle -> withCallingHandlers -> withVisible -> eval -> eval
This is my code:
# Binomial Logistic Regression
# Timeliness is defined as admission within 14 days
# Packages
library(broom)
library(visreg)
library(rcompanion)
library(tidyr)
library(knitr)
library(ggplot2)
# Data
data <- thomas_binomial_f
str(data)
# Model
logistic <- glm(time_ranked ~ cj_ref + gender + prior_admits + drug + freq_ranked + route + first_age_drug, data, family = "binomial")
summary(logistic)
# Fit
nagelkerke(logistic)
# Graphics
visreg(logistic, "drug", scale="response", rug=2, xlab="drug level",
ylab="P(time_ranked)")
visreg(logistic, "cj_ref", scale="response", rug=2, xlab="cj_ref level",
ylab="P(time_ranked)")
visreg(logistic, "prior_admits", scale="response", rug=2, xlab="prior_admits level",
ylab="P(time_ranked)")
visreg(logistic, "first_age_drug", scale="response", rug=2, xlab="first_age_drug level",
ylab="P(time_ranked)")
visreg(logistic, "drug", scale="response", rug=2, xlab="drug level",
ylab="P(time_ranked)")
visreg(logistic, "freq_ranked", scale="response", rug=2, xlab="freq_ranked",
ylab="P(time_ranked)")
# ODDS Ratio
(exp(coef(logistic)))
tidy(logistic, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE)
I have no idea how bad/good this code is, but obviously something is wrong.
Let me know if there is any other information I can give.
Any help would be sooooo appreciated!