# install.packages("readxl") library(readxl) data <- read_excel("E://raw data.xlsx") head(data) data$Risk_Score <- 0.011 * data$`Times of antibiotic use` + 0.005 * data$`Length of hospital stay` # install.packages("pROC") library(pROC) predicted_probs <- data$Risk_Score roc_curve <- roc(data$`Symptomatic urinary tract infection`, predicted_probs) auc_value <- auc(roc_curve) cat("AUC: ", auc_value) plot(roc_curve, main = "ROC Curve for Multivariate Logistic Regression Model", col = "blue", lwd = 2, xlab = "1 - Specificity", ylab = "Sensitivity") # install.packages("ResourceSelection") library(ResourceSelection) hoslem_test <- hoslem.test(data$`Symptomatic urinary tract infection`, predicted_probs) print(hoslem_test) # install.packages("boot") library(boot) bootstrap_auc_function <- function(data, indices) { sample_data <- data[indices, ] predicted_probs <- sample_data$Risk_Score roc_curve <- roc(sample_data$`Symptomatic urinary tract infection`, predicted_probs) return(auc(roc_curve)) } bootstrap_auc_results <- boot(data = data, statistic = bootstrap_auc_function, R = 1000) print(bootstrap_auc_results) boot.ci(bootstrap_auc_results, type = "bca") # install.packages("rms") library(rms) calibration_model <- lrm(`Symptomatic urinary tract infection` ~ `Times of antibiotic use` + `Length of hospital stay`, data = data) calibration_slope <- calibration_model$coefficients[2] cat("Calibration Slope: ", calibration_slope) bootstrap_calibration_function <- function(data, indices) { sample_data <- data[indices, ] calibration_model <- lrm(`Symptomatic urinary tract infection` ~ `Times of antibiotic use` + `Length of hospital stay`, data = sample_data) return(calibration_model$coefficients[2]) } bootstrap_calibration_results <- boot(data = data, statistic = bootstrap_calibration_function, R = 1000) print(bootstrap_calibration_results) boot.ci(bootstrap_calibration_results, type = "bca") # install.packages("car") library(car) multi_model <- glm(`Symptomatic urinary tract infection` ~ `Times of indwelling catheter use` + Department + `Times of antibiotic use` + `Length of hospital stay` + Polytrauma + `Injury level` + `AIS grade`, data = data, family = "binomial") vif_values <- vif(multi_model) print(vif_values)