| Title: | Generalized Process Capability Indices for Progressive Type-II Censored Data using Importance Sampling |
|---|---|
| Description: | Implements Importance Sampling (Sampling Importance Resampling, SIR) for Bayesian parameter estimation and Generalized Process Capability Indices (GPCIs) under progressive Type-II censored data. Evaluates classical and generalized capability indices including Cpy, Cp, Cpk, Cpu, Cpl, Cpm, Cpmk, Spmk, CpTk, Cpc, CNp, CNpk, CNpm, CNpmk, CNpmc, CNpmkc, and Vannman's Cp(u,v) family. Computes initial uncensored estimates, parameter MCMC chains, GPCI posterior chains, point estimates, posterior means, bias, mean squared error (MSE), Bayes risk under loss functions, Highest Posterior Density (HPD) credible intervals at 90%, 95%, and 99% levels, Heidelberger and Welch's MCMC convergence diagnostics, and convergence probabilities. Accommodates user-defined probability density/mass functions, cumulative distribution functions, and survival functions. Methods based on Balakrishnan and Aggarwala (2000) <doi:10.1007/978-1-4612-1186-0>, Maiti et al. (2010) <doi:10.1080/16843703.2010.11673233>, Dey and Saha (2019) <doi:10.1007/s41872-019-00081-4>, Alotaibi et al. (2022) <doi:10.1155/2022/3135264>, Saha et al. (2022) <doi:10.1080/02664763.2021.1971632>, and Saha et al. (2024) <doi:10.1142/S021853932450013X>. |
| Authors: | Shikhar Tyagi [aut, cre] (ORCID: <https://orcid.org/0000-0003-1606-0844>), Sumit Kumar [aut], Arvind Pandey [aut], Bhupendra Singh [aut], Vrijesh Tripathi [aut] |
| Maintainer: | Shikhar Tyagi <[email protected]> |
| License: | GPL (>= 2) |
| Version: | 0.1.0 |
| Built: | 2026-10-07 11:20:36 UTC |
| Source: | https://github.com/cran/gpciProgTyIIImpSam |
Evaluates classical and generalized Process Capability Indices for specified process parameters and specification limits.
capability( distribution, USL, LSL, target = (USL + LSL)/2, indices = NULL, u = 1, v = 1, mode = c("moments", "quantile"), C0 = 1, C1 = 0, C2 = 1, tolerance_t = USL - LSL, P0 = 0.9973002 )capability( distribution, USL, LSL, target = (USL + LSL)/2, indices = NULL, u = 1, v = 1, mode = c("moments", "quantile"), C0 = 1, C1 = 0, C2 = 1, tolerance_t = USL - LSL, P0 = 0.9973002 )
distribution |
A |
USL |
Upper Specification Limit. |
LSL |
Lower Specification Limit. |
target |
Target process value (defaults to midpoint |
indices |
Character vector of GPCI names to evaluate. Default computes all supported indices. |
u |
Parameter |
v |
Parameter |
mode |
Mode of computation: |
C0, C1, C2
|
Parameters for tolerance loss function |
tolerance_t |
Process tolerance span (defaults to |
P0 |
Baseline expected yield (default 0.9973002). |
A named numeric vector of computed GPCI values.
dist_norm <- dist_normal(mean = 10, sd = 1.5) capability( distribution = dist_norm, USL = 15, LSL = 5, target = 10 )dist_norm <- dist_normal(mean = 10, sd = 1.5) capability( distribution = dist_norm, USL = 15, LSL = 5, target = 10 )
Creates a gpci_dist distribution object containing probability density/mass function (PDF/PMF),
cumulative distribution function (CDF), survival function (SF), quantile function, parameter names,
and support boundaries.
define_distribution( name = "Custom", pdf = NULL, cdf = NULL, sf = NULL, quantile = NULL, param_names = NULL, default_params = list(), support = c(-Inf, Inf) )define_distribution( name = "Custom", pdf = NULL, cdf = NULL, sf = NULL, quantile = NULL, param_names = NULL, default_params = list(), support = c(-Inf, Inf) )
name |
Character string naming the distribution. |
pdf |
Function |
cdf |
Function |
sf |
Optional function |
quantile |
Optional function |
param_names |
Character vector of parameter names. If NULL, auto-detected from |
default_params |
Named list of default parameter values. |
support |
Numeric vector of length 2 specifying distribution support (e.g. |
An object of class "gpci_dist".
dist_custom <- define_distribution( name = "ExpCustom", pdf = function(x, rate = 1) dexp(x, rate = rate), cdf = function(q, rate = 1) pexp(q, rate = rate), sf = function(q, rate = 1) pexp(q, rate = rate, lower.tail = FALSE), param_names = "rate", default_params = list(rate = 1), support = c(0, Inf) )dist_custom <- define_distribution( name = "ExpCustom", pdf = function(x, rate = 1) dexp(x, rate = rate), cdf = function(q, rate = 1) pexp(q, rate = rate), sf = function(q, rate = 1) pexp(q, rate = rate, lower.tail = FALSE), param_names = "rate", default_params = list(rate = 1), support = c(0, Inf) )
Exponential Distribution Object Constructor
dist_exponential(rate = 1)dist_exponential(rate = 1)
rate |
Rate parameter (default 1). |
A gpci_dist object.
Gamma Distribution Object Constructor
dist_gamma(shape = 1, rate = 1)dist_gamma(shape = 1, rate = 1)
shape |
Shape parameter (default 1). |
rate |
Rate parameter (default 1). |
A gpci_dist object.
Logistic-Exponential Distribution Object Constructor
dist_logistic_exp(alpha = 1, lambda = 1)dist_logistic_exp(alpha = 1, lambda = 1)
alpha |
Shape parameter (default 1). |
lambda |
Scale parameter (default 1). |
A gpci_dist object.
Normal Distribution Object Constructor
dist_normal(mean = 0, sd = 1)dist_normal(mean = 0, sd = 1)
mean |
Mean parameter (default 0). |
sd |
Standard deviation parameter (default 1). |
A gpci_dist object.
Weibull Distribution Object Constructor
dist_weibull(shape = 1, scale = 1)dist_weibull(shape = 1, scale = 1)
shape |
Shape parameter (default 1). |
scale |
Scale parameter (default 1). |
A gpci_dist object.
Main high-level user interface function to compute Generalized Process Capability Indices (GPCIs) under Progressive Type-II Censored Data using Importance Sampling (Sampling Importance Resampling, SIR). Fits parameter estimates under uncensored and progressive censoring, generates parameter and GPCI chains, and evaluates point estimates, posterior means, bias, MSE, Linex/SEL Bayes risk, 90 percent, 95 percent, and 99 percent HPD credible intervals, Heidelberger and Welch MCMC convergence diagnostics, and convergence probabilities.
gpci_prog_ty2_impsam( x, r_removals = NULL, distribution = NULL, pdf = NULL, cdf = NULL, surv = NULL, quantile = NULL, param_names = NULL, start = NULL, prior = NULL, chain_length = 1000, burn_in = 200, thinning = 1, USL, LSL, target = (USL + LSL)/2, indices = NULL, u = 1, v = 1, C0 = 1, C1 = 0, C2 = 1, P0 = 0.9973002 )gpci_prog_ty2_impsam( x, r_removals = NULL, distribution = NULL, pdf = NULL, cdf = NULL, surv = NULL, quantile = NULL, param_names = NULL, start = NULL, prior = NULL, chain_length = 1000, burn_in = 200, thinning = 1, USL, LSL, target = (USL + LSL)/2, indices = NULL, u = 1, v = 1, C0 = 1, C1 = 0, C2 = 1, P0 = 0.9973002 )
x |
Numeric vector of observed process failure times. |
r_removals |
Progressive removal scheme (vector of integer counts). Default 0s if uncensored. |
distribution |
Optional |
pdf |
Custom PDF/PMF function |
cdf |
Custom CDF function |
surv |
Custom Survival function |
quantile |
Optional custom Quantile function |
param_names |
Character vector of parameter names. |
start |
Named vector or list of initial parameter values. |
prior |
Prior distribution hyperparameters list or log-prior function. |
chain_length |
Desired MCMC chain length after burn-in and thinning. Default 1000. |
burn_in |
Number of burn-in iterations. Default 200. |
thinning |
Thinning interval. Default 1. |
USL |
Upper Specification Limit. |
LSL |
Lower Specification Limit. |
target |
Process target value (defaults to midpoint of USL and LSL). |
indices |
Character vector of GPCI names to evaluate. Default computes all supported indices. |
u, v
|
Vännman's parameters for |
C0, C1, C2
|
Parameters for tolerance loss function (defaults: 1, 0, 1). |
P0 |
Expected yield baseline (default 0.9973002). |
An object of class "gpciProgTyIIImpSam" containing fit details and diagnostic metrics.
# Example using custom functions for Exponential distribution my_pdf <- function(x, rate = 1) dexp(x, rate = rate) my_cdf <- function(q, rate = 1) pexp(q, rate = rate) my_surv <- function(q, rate = 1) pexp(q, rate = rate, lower.tail = FALSE) data_x <- c(0.8, 1.5, 2.3, 3.1, 4.2) removals <- c(1, 0, 1, 0, 1) fit <- gpci_prog_ty2_impsam( x = data_x, r_removals = removals, pdf = my_pdf, cdf = my_cdf, surv = my_surv, start = c(rate = 0.5), chain_length = 500, burn_in = 100, thinning = 1, USL = 8, LSL = 0 ) print(fit)# Example using custom functions for Exponential distribution my_pdf <- function(x, rate = 1) dexp(x, rate = rate) my_cdf <- function(q, rate = 1) pexp(q, rate = rate) my_surv <- function(q, rate = 1) pexp(q, rate = rate, lower.tail = FALSE) data_x <- c(0.8, 1.5, 2.3, 3.1, 4.2) removals <- c(1, 0, 1, 0, 1) fit <- gpci_prog_ty2_impsam( x = data_x, r_removals = removals, pdf = my_pdf, cdf = my_cdf, surv = my_surv, start = c(rate = 0.5), chain_length = 500, burn_in = 100, thinning = 1, USL = 8, LSL = 0 ) print(fit)
Conducts stationarity and relative half-width tests under Heidelberger and Welch's MCMC convergence diagnostic, returning test statistics, status, and convergence probability.
heidelberger_welch(x, alpha = 0.05, eps = 0.1)heidelberger_welch(x, alpha = 0.05, eps = 0.1)
x |
Numeric vector representing an MCMC chain. |
alpha |
Significance level for the test (default is 0.05). |
eps |
Target maximum ratio of half-width to sample mean (default is 0.1). |
A list containing Cramér-von Mises statistic (stat), p-value (pvalue),
stationarity test status (passed), half-width test status (hw_passed),
half-width statistic (hw_stat), and convergence probability (convergence_prob).
samples <- rnorm(1000) heidelberger_welch(samples)samples <- rnorm(1000) heidelberger_welch(samples)
Computes Highest Posterior Density (HPD) credible interval for posterior draws at specified confidence / significance levels (e.g., 90 percent, 95 percent, 99 percent).
hpd_interval(x, prob = 0.95)hpd_interval(x, prob = 0.95)
x |
Numeric vector of sample draws. |
prob |
Credibility level (1 - significance level). Default is 0.95. |
A named numeric vector of length 2 containing lower and upper bounds.
samples <- rnorm(1000, mean = 5, sd = 1) hpd_interval(samples, prob = 0.95)samples <- rnorm(1000, mean = 5, sd = 1) hpd_interval(samples, prob = 0.95)
Generates posterior parameter draws and Generalized Process Capability Index (GPCI) chains using Importance Sampling (Sampling Importance Resampling, SIR) for progressive Type-II censored data.
impsam_prog_ty2( x, r_removals = NULL, distribution, start = NULL, prior = NULL, chain_length = 1000, burn_in = 200, thinning = 1, USL, LSL, target = (USL + LSL)/2, indices = NULL, u = 1, v = 1, C0 = 1, C1 = 0, C2 = 1, P0 = 0.9973002 )impsam_prog_ty2( x, r_removals = NULL, distribution, start = NULL, prior = NULL, chain_length = 1000, burn_in = 200, thinning = 1, USL, LSL, target = (USL + LSL)/2, indices = NULL, u = 1, v = 1, C0 = 1, C1 = 0, C2 = 1, P0 = 0.9973002 )
x |
Numeric vector of observed failure times. |
r_removals |
Progressive removal scheme (vector of integer counts). Default 0s if uncensored. |
distribution |
A |
start |
Named vector or list of initial parameter values. |
prior |
Function or list of prior specifications/hyperparameters. |
chain_length |
Desired length of final retained MCMC chain after burn-in and thinning. Default 1000. |
burn_in |
Number of initial burn-in samples to discard. Default 200. |
thinning |
Thinning interval for sampling. Default 1. |
USL |
Upper Specification Limit. |
LSL |
Lower Specification Limit. |
target |
Process target value (defaults to midpoint of USL and LSL). |
indices |
Character vector of GPCI names to evaluate. Default computes all supported indices. |
u, v
|
Vännman's parameters for |
C0, C1, C2
|
Parameters for tolerance loss function (defaults: 1, 0, 1). |
P0 |
Expected yield baseline (default 0.9973002). |
A list of class "gpciProgTyIIImpSam" containing parameter chain, GPCI chain, and point estimates.
dist_exp <- dist_exponential(rate = 0.5) x <- c(0.5, 1.2, 2.1, 3.4, 4.8) r <- c(1, 0, 2, 0, 1) fit <- impsam_prog_ty2( x = x, r_removals = r, distribution = dist_exp, chain_length = 500, burn_in = 100, thinning = 1, USL = 8, LSL = 0 )dist_exp <- dist_exponential(rate = 0.5) x <- c(0.5, 1.2, 2.1, 3.4, 4.8) r <- c(1, 0, 2, 0, 1) fit <- impsam_prog_ty2( x = x, r_removals = r, distribution = dist_exp, chain_length = 500, burn_in = 100, thinning = 1, USL = 8, LSL = 0 )
Visualizes diagnostic traceplots, posterior probability density functions, and Highest Posterior Density (HPD) credibility intervals for evaluated Generalized Process Capability Indices (GPCIs).
## S3 method for class 'gpciProgTyIIImpSam' plot(x, type = c("density", "trace", "hpd"), indices = NULL, ...)## S3 method for class 'gpciProgTyIIImpSam' plot(x, type = c("density", "trace", "hpd"), indices = NULL, ...)
x |
An object of class |
type |
Character string indicating plot type: |
indices |
Optional character vector of index names to plot. Defaults to first 4 evaluated GPCIs. |
... |
Additional graphical parameters. |
No return value, called for side effects.
dist_exp <- dist_exponential(rate = 0.5) x <- c(0.5, 1.2, 2.1, 3.4, 4.8) r <- c(1, 0, 2, 0, 1) fit <- impsam_prog_ty2(x = x, r_removals = r, distribution = dist_exp, USL = 8, LSL = 0) plot(fit, type = "density")dist_exp <- dist_exponential(rate = 0.5) x <- c(0.5, 1.2, 2.1, 3.4, 4.8) r <- c(1, 0, 2, 0, 1) fit <- impsam_prog_ty2(x = x, r_removals = r, distribution = dist_exp, USL = 8, LSL = 0) plot(fit, type = "density")
Print Method for gpciProgTyIIImpSam Objects
## S3 method for class 'gpciProgTyIIImpSam' print(x, ...)## S3 method for class 'gpciProgTyIIImpSam' print(x, ...)
x |
An object of class |
... |
Additional arguments. |
Invisibly returns x.
Computes estimated value, bias, MSE, Risk value, HPD intervals at 90 percent, 95 percent, and 99 percent significance levels, Heidelberger and Welch MCMC convergence diagnostics, and convergence probabilities for each evaluated GPCI.
## S3 method for class 'gpciProgTyIIImpSam' summary(object, ...)## S3 method for class 'gpciProgTyIIImpSam' summary(object, ...)
object |
An object of class |
... |
Additional arguments. |
A data frame containing diagnostic metrics for each evaluated GPCI.
dist_exp <- dist_exponential(rate = 0.5) x <- c(0.5, 1.2, 2.1, 3.4, 4.8) r <- c(1, 0, 2, 0, 1) fit <- impsam_prog_ty2(x = x, r_removals = r, distribution = dist_exp, USL = 8, LSL = 0) summary(fit)dist_exp <- dist_exponential(rate = 0.5) x <- c(0.5, 1.2, 2.1, 3.4, 4.8) r <- c(1, 0, 2, 0, 1) fit <- impsam_prog_ty2(x = x, r_removals = r, distribution = dist_exp, USL = 8, LSL = 0) summary(fit)