Patient_Admission_Data_3_ <- read_excel("C:/Users/Vicodec/Downloads/Patient_Admission_Data (3).xlsx")
x <- na.omit(Patient_Admission_Data_3_$Number_Of_Days)
if(length(x) == 0){
stop("Error: No numeric data found in Number_Of_Days column")
}
fit_gumbel <- fgev(x, shape = 0)
dev.new(width = 10, height = 6)
hist(x,
probability = TRUE,
col = "lightgray",
border = "white",
main = "Histogram with Fitted Gumbel Distribution",
xlab = "Number of Days",
ylab = "Density")
x_range <- seq(min(x), max(x), length.out = 500)
gumbel_density <- dgev(x_range,
loc = fit_gumbel$estimate["loc"],
scale = fit_gumbel$estimate["scale"],
shape = 0)
lines(x_range, gumbel_density,
col = "blue",
lwd = 2)
legend("topright",
legend = "Fitted Gumbel Density",
col = "blue",
lwd = 2)
cat("\n====================================\n")
##
## ====================================
cat("MODEL EVALUATION RESULTS\n")
## MODEL EVALUATION RESULTS
cat("====================================\n")
## ====================================
cat("AIC:", AIC(fit_gumbel), "\n")
## AIC: 1849.373