# Vectors:
cycles <- alloy$cycles
status <- alloy$status
# Determining the optimal loglikelihood value:
## Range of threshold parameter must be smaller than the first failure:
threshold <- seq(
0,
min(cycles[status == 1]) - 0.1,
length.out = 50
)
## loglikelihood value with respect to threshold values:
profile_logL <- loglik_profiling(
x = cycles,
status = status,
thres = threshold,
distribution = "weibull3"
)
## Threshold value (among the candidates) that maximizes the
## loglikelihood:
threshold[which.max(profile_logL)]
## plot:
plot(
threshold,
profile_logL,
type = "l"
)
abline(
v = threshold[which.max(profile_logL)],
h = max(profile_logL),
col = "red"
)
Run the code above in your browser using DataLab