# NOT RUN {
# Data is taken from given reference:
hours <- c(2, 28, 67, 119, 179, 236, 282, 317, 348, 387, 3, 31, 69, 135,
191, 241, 284, 318, 348, 392, 5, 31, 76, 144, 203, 257, 286,
320, 350, 412, 8, 52, 78, 157, 211, 261, 298, 327, 360, 446,
13, 53, 104, 160, 221, 264, 303, 328, 369, 21, 64, 113, 168,
226, 278, 314, 328, 377)
state <- c(1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1,
1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0,
1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1, 1)
id <- 1:length(hours)
# Example 1 - mix_output = NULL:
plot_weibull <- plot_prob_mix(x = hours,
event = state,
id = id,
distribution = "weibull",
mix_output = NULL,
title_main = "Weibull Probability Plot",
title_x = "Time in Hours",
title_y = "Probability of Failure",
title_trace = "Failed Items")
# Example 2 - Using result of mixmod_em in mix_output:
mix_mod_em <- mixmod_em(x = hours, event = state, distribution = "weibull",
conf_level = 0.95, k = 2, method = "EM", n_iter = 150)
plot_weibull_em <- plot_prob_mix(x = hours,
event = state,
id = id,
distribution = "weibull",
mix_output = mix_mod_em,
title_main = "Weibull Mixture EM",
title_x = "Time in Hours",
title_y = "Probability of Failure",
title_trace = "Subgroup")
# Example 3 - Using result of mixmod_regression in mix_output:
john <- johnson_method(x = hours, event = state)
mix_mod_reg <- mixmod_regression(x = john$characteristic,
y = john$prob,
event = john$status,
distribution = "weibull")
plot_weibull_reg <- plot_prob_mix(x = hours,
event = state,
id = id,
distribution = "weibull",
mix_output = mix_mod_reg,
title_main = "Weibull Mixture Regression",
title_x = "Time in Hours",
title_y = "Probability of Failure",
title_trace = "Subgroup")
# }
Run the code above in your browser using DataLab