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.7267 -0.0720 0.0347 0.0296 0.4235 0.9743
#> 2 Cp 0.2553 -0.0101 0.0165 0.0164 0.0540 0.5376
#> 3 Cpk 0.1268 -0.0706 0.0350 0.0301 -0.1504 0.3333
#> 4 Cpm 0.2382 -0.0218 0.0145 0.0141 0.0740 0.4679
#> 5 CNpmc 0.2113 -0.0249 0.0084 0.0078 0.0775 0.3686
#> 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.1914652 -0.007558266 0.009263195 0.009224517 0.04861269
#> HPD_90_Upper HPD_95_Lower HPD_95_Upper HPD_99_Lower HPD_99_Upper HW_Stat
#> 1 0.3217912 0.04050443 0.4032326 0.03893146 0.4455496 0.08688201
#> 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.7267080 -0.07196828 0.03467797 0.029557649 0.48452096
#> 2 Cp 0.2552869 -0.01007769 0.01646790 0.016399141 0.06481692
#> 3 Cpk 0.1267932 -0.07060260 0.03504495 0.030120468 -0.11329193
#> 4 Cpm 0.2381709 -0.02184335 0.01450207 0.014053046 0.05047659
#> 5 CNpmc 0.2112692 -0.02490033 0.00835838 0.007753861 0.09465742
#> HPD_90_Upper HPD_95_Lower HPD_95_Upper HPD_99_Lower HPD_99_Upper HW_Stat
#> 1 0.9743164 0.42352318 0.9743164 0.26834146 0.9743164 0.15867759
#> 2 0.4290549 0.05400590 0.5376435 0.05190861 0.5940662 0.08688198
#> 3 0.3333333 -0.15038712 0.3333333 -0.22951611 0.3333333 0.15237804
#> 4 0.4123882 0.07403715 0.4679232 0.03966306 0.4679232 0.10042807
#> 5 0.3686470 0.07752096 0.3686470 0.04234584 0.3686470 0.11818107
#> 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.3067
# Extract 95% HPD credible intervals for capability indices
confint(fit, what = "indices", level = 0.95)
#> 2.5% 97.5%
#> Cpy 0.42352318 0.9743164
#> Cp 0.05400590 0.5376435
#> Cpk -0.15038712 0.3333333
#> Cpm 0.07403715 0.4679232
#> CNpmc 0.07752096 0.3686470Goodness-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
Need a high-speed mirror for your open-source project?
Contact our mirror admin team at info@clientvps.com.
This archive is provided as a free public service to the community.
Proudly supported by infrastructure from VPSPulse , RxServers , BuyNumber , UnitVPS , OffshoreName and secure payment technology by ArionPay.