# Vectors:
cycles <- alloy$cycles
status <- alloy$status
# Probability estimation:
prob_tbl <- estimate_cdf(
x = cycles,
status = status,
method = "johnson"
)
# Determining the optimal coefficient of determination:
## Range of threshold parameter must be smaller than the first failure:
threshold <- seq(
0,
min(cycles[status == 1]) - 0.1,
length.out = 100
)
## Coefficient of determination with respect to threshold values:
profile_r2 <- r_squared_profiling(
x = prob_tbl$x[prob_tbl$status == 1],
y = prob_tbl$prob[prob_tbl$status == 1],
thres = threshold,
distribution = "weibull3"
)
## Threshold value (among the candidates) that maximizes the
## coefficient of determination:
threshold[which.max(profile_r2)]
## plot:
plot(
threshold,
profile_r2,
type = "l"
)
abline(
v = threshold[which.max(profile_r2)],
h = max(profile_r2),
col = "red"
)
Run the code above in your browser using DataLab