plot_pop {weibulltools} | R Documentation |
Add Population Line(s) to an Existing Grid
Description
This function adds one (or multiple) linearized CDF(s) to an existing plot grid.
Usage
plot_pop(
p_obj = NULL,
x,
dist_params_tbl,
distribution = c("weibull", "lognormal", "loglogistic", "sev", "normal", "logistic",
"exponential"),
tol = 1e-06,
title_trace = "Population",
plot_method = c("plotly", "ggplot2")
)
Arguments
p_obj |
A plot object to which the population line(s) is (are) added or
|
x |
A numeric vector of length two or greater used for the x coordinates
of the population line. If |
dist_params_tbl |
A |
distribution |
Supposed distribution of the random variable. The distinction
between a threshold distribution and the respective standard variant is made with
|
tol |
The failure probability is restricted to the interval
|
title_trace |
A character string which is assigned to the legend trace. |
plot_method |
Package, which is used for generating the plot output. Only
used when |
Details
dist_params_tbl
is a data.frame
with parameter columns. An overview of the
distribution-specific parameters and their order can be found in section
'Distributions'.
If only one population line should be displayed, a numeric vector is also supported. The order of the vector elements also corresponds to the table in section 'Distributions'.
Value
A plot object containing the linearized CDF(s).
Distributions
The following table summarizes the available distributions and their parameters
-
location parameter
\mu
, -
scale parameter
\sigma
or\theta
and -
threshold parameter
\gamma
.
The column order within dist_params_tbl
is given in the table header.
distribution | dist_params_tbl[1] | dist_params_tbl[2] | dist_params_tbl[3] |
"sev" | \mu | \sigma | - |
"weibull" | \mu | \sigma | (\gamma ) |
"normal" | \mu | \sigma | - |
"lognormal" | \mu | \sigma | (\gamma ) |
"logistic" | \mu | \sigma | - |
"loglogistic" | \mu | \sigma | (\gamma ) |
"exponential" | \theta | (\gamma ) | - |
Examples
x <- rweibull(n = 100, shape = 1, scale = 20000)
# Example 1 - Two-parametric straight line:
pop_weibull <- plot_pop(
p_obj = NULL,
x = range(x),
dist_params_tbl = c(log(20000), 1),
distribution = "weibull"
)
# Example 2 - Three-parametric curved line:
x2 <- rweibull(n = 100, shape = 1, scale = 20000) + 5000
pop_weibull_2 <- plot_pop(
p_obj = NULL,
x = x2,
dist_params_tbl = c(log(20000 - 5000), 1, 5000),
distribution = "weibull"
)
# Example 3 - Multiple lines:
pop_weibull_3 <- plot_pop(
p_obj = NULL,
x = x,
dist_params_tbl = data.frame(
p_1 = c(log(20000), log(20000), log(20000)),
p_2 = c(1, 1.5, 2)
),
distribution = "weibull",
plot_method = "ggplot2"
)
# Example 4 - Compare two- and three-parametric distributions:
pop_weibull_4 <- plot_pop(
p_obj = NULL,
x = x,
dist_params_tbl = data.frame(
param_1 = c(log(20000), log(20000)),
param_2 = c(1, 1),
param_3 = c(NA, 2)
),
distribution = "weibull"
)