# The Log-Normal distribution has a *non-monotonic* hazard function that *rises rapidly* to a peak before *steadily decreasing* toward zero over time.
# E.g., initial high risk (electric components): chips immediately after production often contain latent manufacturing defects. These weak units fail quickly during the first few hours or days of operation. Once these defective chips have failed, the remaining units are considered "healthy," and their risk of failure decreases steadily toward zero.
t_seq <- seq(from = 0.001, to = 5, length.out = 100); sigma_values <- c(0.3, 0.6); mulog_scale <- 0
df_combined <- lapply(sigma_values, function(sigma) { data.frame(t = t_seq, sigma_factor = factor(paste0("sigma = ", sigma)), ft = dlnorm(t_seq, meanlog = mulog_scale, sdlog = sigma), St = 1 - plnorm(t_seq, meanlog = mulog_scale, sdlog = sigma), ht = dlnorm(t_seq, meanlog = mulog_scale, sdlog = sigma) / (1 - plnorm(t_seq, meanlog = mulog_scale, sdlog = sigma))) }) %>% bind_rows()
custom_theme <- theme_bw() + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), panel.border = element_blank(), axis.line.x = element_line(linewidth = 0.5, color = "black"), axis.line.y = element_line(linewidth = 0.5, color = "black"), text = element_text(size = 16, family = "Latin Modern Roman 10"), legend.position = "right", legend.title = element_blank(), plot.title = element_text(hjust = 0.5))
shared_linetype <- scale_linetype_manual(values = c("sigma = 0.3" = "solid", "sigma = 0.6" = "dashed"))
p1 <- ggplot(df_combined, aes(x = t, y = ft, linetype = sigma_factor)) + geom_line(linewidth = 0.8) + labs(x = "t", y = "f(t)", title = "Density function" ) + shared_linetype + scale_x_continuous(limits = c(0, 5), expand = expansion(mult = c(0, 0))) + scale_y_continuous(limits = c(0, 1.55), expand = expansion(mult = c(0, 0))) + custom_theme + theme(legend.position = "none")
p2 <- ggplot(df_combined, aes(x = t, y = St, linetype = sigma_factor)) + geom_line(linewidth = 0.8) + labs(x = "t", y = "S(t)", title = "Survival function") + shared_linetype + scale_x_continuous(limits = c(0, 5), expand = expansion(mult = c(0, 0))) + scale_y_continuous(limits = c(0, 1.05), expand = expansion(mult = c(0, 0))) + custom_theme + theme(legend.position = "none")
p3 <- ggplot(df_combined, aes(x = t, y = ht, linetype = sigma_factor)) + geom_line(linewidth = 0.8) + labs(x = "t", y = "h(t)", title = "Hazard function" ) + shared_linetype + scale_x_continuous(limits = c(0, 5), expand = expansion(mult = c(0, 0))) + scale_y_continuous(limits = c(0, 5.05), expand = expansion(mult = c(0, 0))) + custom_theme + theme(legend.position = "none")
p1 + p2 + p3