The gpcihybridIIImpSam package provides
a comprehensive, generalized Bayesian framework for evaluating
Generalized Process Capability Indices (GPCIs) under
Hybrid Type-II Censored Lifetime Data using
Importance Sampling (Sampling Importance Resampling,
SIR).
Under Hybrid Type-II censoring, \(n\) identical units are placed on life test. The experiment terminates at: \[T^* = \max(x_r, T_c)\] where \(r \le n\) is the target number of failures and \(T_c > 0\) is the pre-fixed censoring time. The likelihood function is: \[L(\theta \mid \mathbf{x}, r, T_c, n) = \left[ \prod_{i=1}^d f(x_i; \theta) \right] [S(T^*; \theta)]^{n - d}\] where \(d \ge r\) is the number of observed failures up to time \(T^*\).
library(gpcihybridIIImpSam)
# 1. User-supplied custom probability density, CDF, and survival functions
my_pdf <- function(x, rate) stats::dexp(x, rate = rate)
my_cdf <- function(q, rate) stats::pexp(q, rate = rate)
my_surv <- function(q, rate) stats::pexp(q, rate = rate, lower.tail = FALSE)
# 2. Observed Hybrid Type-II Censored Data
# n = 10 units placed on test, target r = 3, fixed censoring time Tc = 2.5
x_data <- c(0.4, 0.9, 1.5, 2.3)
# 3. Fit Importance Sampling Model
fit <- gpci_hybrid2_impsam(
x = x_data,
r = 3,
tc = 2.5,
n = 10,
pdf = my_pdf,
cdf = my_cdf,
surv = my_surv,
param_names = "rate",
start = c(rate = 0.5),
chain_length = 500,
burn_in = 100,
thinning = 1,
USL = 8,
LSL = 0,
target = 4,
indices = c("Cpy", "Cp", "Cpk", "Cpm", "CNpmc")
)
# 4. Print Summary
print(fit)
#> --- Bayesian Importance Sampling of GPCIs under Hybrid Type-II Censoring ---
#> Distribution: Custom
#> Observed Failures (d): 4 | Target (r): 3 | Total (n): 10
#> Censoring Time (Tc): 2.5 | Effective Termination (T*): 2.5
#> Specification Limits: LSL = 0 | Target = 4 | USL = 8
#>
#> Initial Parameter MLEs (under Hybrid Type-II Censoring):
#> rate
#> 0.199
#>
#> Point Estimates of GPCIs (at Initial Estimates):
#> Cpy Cp Cpk Cpm CNpmc
#> 0.7987 0.2654 0.1974 0.2600 0.2362
#>
#> Posterior GPCI Summary (Importance Sampling Chain):
#> Variable Estimate Bias MSE Bayes_Risk HPD_95_Lower HPD_95_Upper
#> 1 Cpy 0.7170 -0.0817 0.0339 0.0273 0.4111 0.9556
#> 2 Cp 0.2410 -0.0243 0.0126 0.0121 0.0855 0.4961
#> 3 Cpk 0.1166 -0.0808 0.0343 0.0279 -0.1574 0.3333
#> 4 Cpm 0.2280 -0.0321 0.0130 0.0120 0.0686 0.4458
#> 5 CNpmc 0.2045 -0.0317 0.0078 0.0068 0.0721 0.3523
#> HW_Passed
#> 1 TRUE
#> 2 TRUE
#> 3 TRUE
#> 4 TRUE
#> 5 TRUEThe package automatically reports: - Posterior point estimate (posterior mean) - Bias and Mean Squared Error (MSE) - Bayes risk under squared error loss (posterior variance) - Highest Posterior Density (HPD) credible intervals at 90%, 95%, and 99% levels - Heidelberger and Welch’s MCMC convergence diagnostics (stationarity test and half-width test) - Convergence probability and empirical coverage probability
# Full posterior summary
summary(fit)
#> ======================================================================
#> Bayesian Importance Sampling of GPCIs under Hybrid Type-II Censoring
#> ======================================================================
#>
#> --- Parameter Posterior Summary ---
#> Variable Estimate Bias MSE Bayes_Risk HPD_90_Lower
#> 1 rate 0.1807836 -0.01823986 0.007115577 0.006796477 0.06281003
#> HPD_90_Upper HPD_95_Lower HPD_95_Upper HPD_99_Lower HPD_99_Upper HW_Stat
#> 1 0.3242011 0.06413243 0.372092 0.03093259 0.372092 0.03926216
#> HW_PValue HW_Passed Convergence_Prob Coverage_Prob
#> 1 0.5 TRUE 0.5 1
#>
#> --- GPCI Posterior Summary ---
#> Variable Estimate Bias MSE Bayes_Risk HPD_90_Lower
#> 1 Cpy 0.7170128 -0.08166349 0.03389204 0.027277675 0.48025647
#> 2 Cp 0.2410448 -0.02431982 0.01264991 0.012082626 0.08374671
#> 3 Cpk 0.1165777 -0.08081813 0.03433746 0.027861612 -0.11602393
#> 4 Cpm 0.2279546 -0.03205961 0.01303366 0.012029900 0.06703725
#> 5 CNpmc 0.2045042 -0.03166537 0.00778791 0.006798812 0.09338460
#> HPD_90_Upper HPD_95_Lower HPD_95_Upper HPD_99_Lower HPD_99_Upper HW_Stat
#> 1 0.9555643 0.41112084 0.9555643 0.23131056 0.9555643 0.02623310
#> 2 0.4322682 0.08550991 0.4961227 0.04124345 0.4961227 0.03926216
#> 3 0.3333333 -0.15744960 0.3333333 -0.24591462 0.3333333 0.02946424
#> 4 0.4144005 0.06862241 0.4458004 0.03101934 0.4458004 0.03716081
#> 5 0.3553280 0.07208756 0.3522998 0.03326190 0.3522998 0.03285368
#> HW_PValue HW_Passed Convergence_Prob Coverage_Prob
#> 1 0.5 TRUE 0.5 1
#> 2 0.5 TRUE 0.5 1
#> 3 0.5 TRUE 0.5 1
#> 4 0.5 TRUE 0.5 1
#> 5 0.5 TRUE 0.5 1
#>
#> --- Effective Sample Ratio / Acceptance Rates ---
#> rate
#> 0.4416
# Extract 95% HPD credible intervals for capability indices
confint(fit, what = "indices", level = 0.95)
#> 2.5% 97.5%
#> Cpy 0.41112084 0.9555643
#> Cp 0.08550991 0.4961227
#> Cpk -0.15744960 0.3333333
#> Cpm 0.06862241 0.4458004
#> CNpmc 0.07208756 0.3522998Goodness-of-fit testing for Hybrid Type-II censored data is supported
via gofPHCS:
dist_exp <- dist_exponential(rate = 0.5)
gof_res <- gof_test_hybrid2(
fit = fit,
statistic = "auto",
p.method = "montecarlo",
nsim = 50
)
print(gof_res)
#> --- Goodness-of-Fit Test (Hybrid Type-II Censored Data) ---
#> Distribution: Custom
#> Test Method: Monte Carlo Test (50 replicates) (KSII for hybridII scheme)
#> Statistic: KSII = 1.0361
#> p-value: 0.70588