knitr::opts_chunk$set( collapse = TRUE, screenshot.force = FALSE, comment = "#>" ) library(weibulltools)
In this vignette two methods for the separation of mixture models are presented. A mixture model can be assumed, if the points in a probability plot show one or more changes in slope, depict one or several saddle points or follow an S-shape. A mixed distribution often represents the combination of multiple failure modes and thus must be split in its components to get reasonable results in further analyses.
Segmented regression aims to detect breakpoints in the sample data from which a split in subgroups can be made. The expectation-maximization (EM) algorithm is a computation-intensive method that iteratively tries to maximize a likelihood function, which is weighted by posterior probabilities. These are conditional probabilities that an observation belongs to subgroup k.
In the following, the focus is on the application of these methods and their
visualizations using the functions
To apply the introduced methods the dataset
voltage is used. The dataset contains
observations for units that were passed to a high voltage stress test. hours
indicates the number of hours until a failure occurs or the number of hours until
a unit was taken out of the test and has not failed. status is a flag variable
and describes the condition of a unit. If a unit has failed the flag is 1 and 0
otherwise. The dataset is taken from Reliability Analysis by Failure Mode [^note1].
[^note1]: Doganaksoy, N.; Hahn, G.; Meeker, W. Q.: Reliability Analysis by Failure Mode, Quality Progress, 35(6), 47-52, 2002
For consistent handling of the data,
weibulltools introduces the function
reliability_data() that converts the original dataset into a
object. This formatted object allows to easily apply the presented methods.
voltage_tbl <- reliability_data(data = voltage, x = hours, status = status) voltage_tbl
To get an intuition whether one can assume the presence of a mixture model, a Weibull probability plot is constructed.
# Estimating failure probabilities: voltage_cdf <- estimate_cdf(voltage_tbl, "johnson") # Probability plot: weibull_plot <- plot_prob( voltage_cdf, distribution = "weibull", title_main = "Weibull Probability Plot", title_x = "Time in Hours", title_y = "Probability of Failure in %", title_trace = "Defectives", plot_method = "ggplot2" ) weibull_plot
Since there is one obvious slope change in the Weibull probability plot of Figure 1, the appearance of a mixture model consisting of two subgroups is strengthened.
The method of segmented regression is implemented in the function
If a breakpoint was detected, the failure data is separated by that point. After
breakpoint detection the function
rank_regression() is called inside
and is used to estimate the distribution parameters of the subgroups. The visualization
of the obtained results is done by functions
# Applying mixmod_regression(): mixreg_weib <- mixmod_regression( x = voltage_cdf, distribution = "weibull", k = 2 ) mixreg_weib # Using plot_prob_mix(). mix_reg_plot <- plot_prob( x = mixreg_weib, title_main = "Weibull Mixture Regression", title_x = "Time in Hours", title_y = "Probability of Failure", title_trace = "Subgroup", plot_method = "ggplot2" ) mix_reg_plot
# Using plot_mod() to visualize regression lines of subgroups: mix_reg_lines <- plot_mod( mix_reg_plot, x = mixreg_weib, title_trace = "Fitted Line" ) mix_reg_lines
The method has separated the data into $k = 2$ subgroups. This can bee seen in Figure 2 and Figure 3.
An upside of this function is that the segmentation is done in a comprehensible manner.
Furthermore, the segmentation process can be done automatically by setting
k = NULL.
The danger here, however, is an overestimation of the breakpoints.
To sum up, this function should give an intention of the existence of a mixture model. An in-depth analysis should be done afterwards.
The EM algorithm can be applied through the usage of the function
In contrast to
mixmod_regression(), this method does not support an automatic
separation routine and therefore k, the number of subgroups, must always be specified.
The obtained results can be also visualized by the functions
# Applying mixmod_regression(): mix_em_weib <- mixmod_em( x = voltage_tbl, distribution = "weibull", k = 2 ) mix_em_weib # Using plot_prob(): mix_em_plot <- plot_prob( x = mix_em_weib, title_main = "Weibull Mixture EM", title_x = "Time in Hours", title_y = "Probability of Failure", title_trace = "Subgroup", plot_method = "ggplot2" ) mix_em_plot
# Using plot_mod() to visualize regression lines of subgroups: mix_em_lines <- plot_mod( mix_em_plot, x = mix_em_weib, title_trace = "Fitted Line" ) mix_em_lines
One advantage over
mixmod_regression() is, that the EM algorithm can also assign
censored items to a specific subgroup. Hence, an individual analysis of the mixing
components, depicted in Figure 4 and Figure 5, is possible.
In conclusion an analysis of a mixture model using
mixmod_em() is statistically founded.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.