The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

Package {gpciProgTyIIImpSam}


Type: Package
Title: Generalized Process Capability Indices for Progressive Type-II Censored Data using Importance Sampling
Version: 0.1.0
Maintainer: Shikhar Tyagi <shikhar1093tyagi@gmail.com>
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>.
License: GPL-2 | GPL-3 [expanded from: GPL (≥ 2)]
Encoding: UTF-8
RoxygenNote: 7.3.3
Imports: stats, graphics
Suggests: testthat (≥ 3.0.0), knitr, rmarkdown
VignetteBuilder: knitr
NeedsCompilation: no
Packaged: 2026-07-31 01:45:46 UTC; shikhar tyagi
Author: Shikhar Tyagi ORCID iD [aut, cre], Sumit Kumar [aut], Arvind Pandey [aut], Bhupendra Singh [aut], Vrijesh Tripathi [aut]
Repository: CRAN
Date/Publication: 2026-08-07 21:00:02 UTC

gpciProgTyIIImpSam: 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

Author(s)

Maintainer: Shikhar Tyagi shikhar1093tyagi@gmail.com (ORCID)

Authors:


Compute Process Capability Indices (GPCIs)

Description

Evaluates classical and generalized Process Capability Indices for specified process parameters and specification limits.

Usage

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
)

Arguments

distribution

A gpci_dist object containing model parameters.

USL

Upper Specification Limit.

LSL

Lower Specification Limit.

target

Target process value (defaults to midpoint (USL + LSL) / 2).

indices

Character vector of GPCI names to evaluate. Default computes all supported indices.

u

Parameter u for Vännman's Cp(u,v) family (default 1).

v

Parameter v for Vännman's Cp(u,v) family (default 1).

mode

Mode of computation: "moments" (default) or "quantile".

C0, C1, C2

Parameters for tolerance loss function C_M(t) = C0 + C1 * exp(-C2 * t) (defaults: 1, 0, 1).

tolerance_t

Process tolerance span (defaults to USL - LSL).

P0

Baseline expected yield (default 0.9973002).

Value

A named numeric vector of computed GPCI values.

Examples

dist_norm <- dist_normal(mean = 10, sd = 1.5)
capability(
  distribution = dist_norm,
  USL = 15, LSL = 5, target = 10
)

Compute Theoretical Moments of a Distribution

Description

Estimates theoretical mean and variance of a distribution object using numerical integration.

Usage

compute_theoretical_moments(distribution)

Arguments

distribution

A gpci_dist object.

Value

A list containing mean and var.


Define a Custom Distribution Object

Description

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.

Usage

define_distribution(
  name = "Custom",
  pdf = NULL,
  cdf = NULL,
  sf = NULL,
  quantile = NULL,
  param_names = NULL,
  default_params = list(),
  support = c(-Inf, Inf)
)

Arguments

name

Character string naming the distribution.

pdf

Function function(x, ...) computing density.

cdf

Function function(q, ...) computing CDF.

sf

Optional function function(q, ...) computing survival function 1 - CDF.

quantile

Optional function function(p, ...) computing quantiles.

param_names

Character vector of parameter names. If NULL, auto-detected from pdf.

default_params

Named list of default parameter values.

support

Numeric vector of length 2 specifying distribution support (e.g. c(0, Inf)).

Value

An object of class "gpci_dist".

Examples

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

Description

Exponential Distribution Object Constructor

Usage

dist_exponential(rate = 1)

Arguments

rate

Rate parameter (default 1).

Value

A gpci_dist object.


Gamma Distribution Object Constructor

Description

Gamma Distribution Object Constructor

Usage

dist_gamma(shape = 1, rate = 1)

Arguments

shape

Shape parameter (default 1).

rate

Rate parameter (default 1).

Value

A gpci_dist object.


Logistic-Exponential Distribution Object Constructor

Description

Logistic-Exponential Distribution Object Constructor

Usage

dist_logistic_exp(alpha = 1, lambda = 1)

Arguments

alpha

Shape parameter (default 1).

lambda

Scale parameter (default 1).

Value

A gpci_dist object.


Normal Distribution Object Constructor

Description

Normal Distribution Object Constructor

Usage

dist_normal(mean = 0, sd = 1)

Arguments

mean

Mean parameter (default 0).

sd

Standard deviation parameter (default 1).

Value

A gpci_dist object.


Weibull Distribution Object Constructor

Description

Weibull Distribution Object Constructor

Usage

dist_weibull(shape = 1, scale = 1)

Arguments

shape

Shape parameter (default 1).

scale

Scale parameter (default 1).

Value

A gpci_dist object.


Importance Sampling Estimation of GPCIs under Progressive Type-II Censoring

Description

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.

Usage

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
)

Arguments

x

Numeric vector of observed process failure times.

r_removals

Progressive removal scheme (vector of integer counts). Default 0s if uncensored.

distribution

Optional gpci_dist object. If NULL, user must supply pdf and cdf.

pdf

Custom PDF/PMF function function(x, ...).

cdf

Custom CDF function function(q, ...).

surv

Custom Survival function function(q, ...).

quantile

Optional custom Quantile function function(p, ...).

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 Cp(u,v) family (default 1).

C0, C1, C2

Parameters for tolerance loss function (defaults: 1, 0, 1).

P0

Expected yield baseline (default 0.9973002).

Value

An object of class "gpciProgTyIIImpSam" containing fit details and diagnostic metrics.

Examples

# 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)

Heidelberger and Welch's MCMC Convergence Diagnostic

Description

Conducts stationarity and relative half-width tests under Heidelberger and Welch's MCMC convergence diagnostic, returning test statistics, status, and convergence probability.

Usage

heidelberger_welch(x, alpha = 0.05, eps = 0.1)

Arguments

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).

Value

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).

Examples

samples <- rnorm(1000)
heidelberger_welch(samples)

Highest Posterior Density (HPD) Interval Calculation

Description

Computes Highest Posterior Density (HPD) credible interval for posterior draws at specified confidence / significance levels (e.g., 90 percent, 95 percent, 99 percent).

Usage

hpd_interval(x, prob = 0.95)

Arguments

x

Numeric vector of sample draws.

prob

Credibility level (1 - significance level). Default is 0.95.

Value

A named numeric vector of length 2 containing lower and upper bounds.

Examples

samples <- rnorm(1000, mean = 5, sd = 1)
hpd_interval(samples, prob = 0.95)

Importance Sampling for Progressive Type-II Censored Data

Description

Generates posterior parameter draws and Generalized Process Capability Index (GPCI) chains using Importance Sampling (Sampling Importance Resampling, SIR) for progressive Type-II censored data.

Usage

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
)

Arguments

x

Numeric vector of observed failure times.

r_removals

Progressive removal scheme (vector of integer counts). Default 0s if uncensored.

distribution

A gpci_dist object.

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 Cp(u,v) family (default 1).

C0, C1, C2

Parameters for tolerance loss function (defaults: 1, 0, 1).

P0

Expected yield baseline (default 0.9973002).

Value

A list of class "gpciProgTyIIImpSam" containing parameter chain, GPCI chain, and point estimates.

Examples

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
)

Plot Method for gpciProgTyIIImpSam Objects

Description

Visualizes diagnostic traceplots, posterior probability density functions, and Highest Posterior Density (HPD) credibility intervals for evaluated Generalized Process Capability Indices (GPCIs).

Usage

## S3 method for class 'gpciProgTyIIImpSam'
plot(x, type = c("density", "trace", "hpd"), indices = NULL, ...)

Arguments

x

An object of class "gpciProgTyIIImpSam".

type

Character string indicating plot type: "trace" for MCMC traceplots, "density" for posterior density estimates, or "hpd" for HPD intervals.

indices

Optional character vector of index names to plot. Defaults to first 4 evaluated GPCIs.

...

Additional graphical parameters.

Value

No return value, called for side effects.

Examples

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

Description

Print Method for gpciProgTyIIImpSam Objects

Usage

## S3 method for class 'gpciProgTyIIImpSam'
print(x, ...)

Arguments

x

An object of class "gpciProgTyIIImpSam".

...

Additional arguments.

Value

Invisibly returns x.


Summary and Diagnostics for gpciProgTyIIImpSam Objects

Description

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.

Usage

## S3 method for class 'gpciProgTyIIImpSam'
summary(object, ...)

Arguments

object

An object of class "gpciProgTyIIImpSam".

...

Additional arguments.

Value

A data frame containing diagnostic metrics for each evaluated GPCI.

Examples

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)

Validate Progressive Type-II Censored Data

Description

Validate Progressive Type-II Censored Data

Usage

validate_prog_data(x, r_removals = NULL)

Arguments

x

Numeric vector of failure times.

r_removals

Progressive removal scheme vector.

Value

A list containing cleaned x and r_removals.

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.