Learn R Programming

weibulltools (version 0.5.4)

plot_mod: Adding an Estimated Population Line to a Probability Plot

Description

This function adds a regression line to an existing probability plot using a model estimated by rank_regression or ml_estimation.

Usage

plot_mod(p_obj, x, y = NULL, loc_sc_params, distribution = c("weibull",
  "lognormal", "loglogistic"), title_trace = "Fit")

Arguments

p_obj

a plotly object provided by function plot_prob.

x

a numeric vector containing the x-coordinates of the regression line.

y

a numeric vector containing the y-coordinates of the regression line. The default value of y is NULL. If y is set NULL the y-coordinates with respect to x are calculated by function predict_prob using estimated coefficients in loc_sc_params. If confidence interval(s) should be added to the plot y should not be set to NULL. For more information see Details in plot_conf.

loc_sc_params

a (named) numeric vector of estimated location and scale parameters for a specified distribution. The order of elements is important. First entry needs to be the location parameter \(\mu\) and the second element needs to be the scale parameter \(\sigma\).

distribution

supposed distribution of the random variable. The value can be "weibull", "lognormal" or "loglogistic". Other distributions have not been implemented yet.

title_trace

a character string whis is assigned to the trace shown in the legend.

Value

Returns a plotly object containing the probability plot with plotting positions and the estimated regression line.

Examples

Run this code
# NOT RUN {
obs   <- seq(10000, 100000, 10000)
state <- c(0, 1, 1, 0, 0, 0, 1, 0, 1, 0)
id <- LETTERS[1:length(obs)]

df_john <- johnson_method(x = obs, event = state, id = id)
mrr <- rank_regression(x = df_john$characteristic,
                       y = df_john$prob,
                       event = df_john$status,
                       distribution = "weibull",
                       conf_level = .90)

plot_weibull <- plot_prob(x = df_john$characteristic,
                          y = df_john$prob,
                          event = df_john$status,
                          id = df_john$id,
                          distribution = "weibull",
                          title_main = "Weibull Analysis",
                          title_x = "Mileage in miles",
                          title_y = "Probability of Failure in %",
                          title_trace = "Failed Items")

plot_reg_weibull <- plot_mod(p_obj = plot_weibull, x = obs,
                             loc_sc_params = mrr$loc_sc_coefficients,
                             distribution = "weibull",
                             title_trace = "Estimated Weibull CDF")
# }

Run the code above in your browser using DataLab