| sim_failures | R Documentation |
Simulates which units in a non-failed population fail next by using a
Weibull life model conditional on each unit's current runtime. When a
positive window is supplied, the function calibrates a Weibull scale
parameter (unless provided directly) so that the expected number of failures
within the window matches n. Units are then sampled with probability
proportional to their conditional Weibull failure probability over the
window, and failure times are drawn from the truncated conditional Weibull
distribution. The full fleet is returned: selected units are labelled
"Failure" and the remaining units are labelled "Suspension".
sim_failures(n, runtimes, replace = FALSE, window = NULL, beta = 1, eta = NULL)
n |
Positive integer. Number of failures to simulate. |
runtimes |
Numeric vector of positive values. The current operating runtime of each unit in the non-failed population. |
replace |
Logical scalar. If |
window |
|
beta |
Positive numeric scalar. Weibull shape parameter used to model
the age-dependent hazard. Defaults to |
eta |
|
When window = NULL, the function returns the current fleet state at the
supplied runtimes. In this case, failing units are selected using relative
Weibull hazard weights implied by beta.
A data frame with length(runtimes) rows sorted ascending by
runtime, containing:
index |
Integer index of the unit in |
runtime |
Simulated event time. |
type |
Character; |
The returned object also carries attributes weibull_beta and
weibull_eta describing the Weibull parameters used for the simulation.
Other data preparation:
weibull_to_rga()
set.seed(42)
runtimes <- c(100, 500, 200, 800, 300)
result <- sim_failures(2, runtimes, beta = 1.5)
print(result)
# With an observation window
set.seed(42)
result_w <- sim_failures(2, runtimes, window = 50, beta = 1.5)
print(result_w)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.