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 {rMCHSPTT}


Type: Package
Title: Modified Chain Sampling Inspection Plan for Time-Truncated Life Tests
Version: 0.1.0
Description: Designing and comparing modified chain sampling inspection plan (MChSP). This package implements ChSP-1, MChSP-1, Multiple Dependent State Sampling (MDS), and Modified Chain Sampling plans (MChSP). The plans use user-supplied failure probabilities and determine the minimum sample size subject to consumer's risk constraints. Functions are provided to compare the required sample sizes of the four plans and visualize their performance. The distribution-free formulation allows the methods to be used with different lifetime distributions. Luca (2018) <doi:10.1080/02664763.2017.1375084>; Tripathi et al. (2021) <doi:10.32604/csse.2021.015624>; Tripathi et al. (2023) <doi:10.1007/s41872-023-00215-9>; Rao et al. (2025) <doi:10.1080/27684520.2025.2531810>; Tripathi and Saha (2023) <doi:10.1007/s13198-023-02221-7>.
License: GPL-3
Encoding: UTF-8
Config/roxygen2/version: 8.0.0
Suggests: testthat (≥ 3.0.0)
Config/testthat/edition: 3
NeedsCompilation: no
Packaged: 2026-09-28 18:05:16 UTC; Admin
Author: Harsh Tripathi [aut, cre]
Maintainer: Harsh Tripathi <rsearchstat21@gmail.com>
Repository: CRAN
Date/Publication: 2026-10-08 17:30:02 UTC

Chain Sampling Inspection Plan (ChSP-1)

Description

Calculates the minimum required sample size for a Chain Sampling Inspection Plan (ChSP-1) under a time-truncated life test.

Usage

chsp1_asip(p, a, b, i = 1, beta = 0.25, n_max = 10000)

Arguments

p

User-defined probability of failure before the termination time. It must lie strictly between 0 and 1.

a

Termination ratio, defined as a = t/theta0. It must be a positive numeric value.

b

Quality ratio, defined as b = theta/theta0. It must be a positive numeric value.

i

Number of preceding samples considered in the chain. It must be a positive integer.

beta

Consumer's risk. It must be a value between 0 and 1.

n_max

Maximum sample size to be searched. It must be a positive integer.

Details

The probability of failure before the termination time is supplied directly by the user through 'p'. Therefore, the function is distribution-free and can be used with different lifetime distributions.

For a sample of size 'n', let 'P0' denote the probability of observing zero defective units and 'P1' denote the probability of observing exactly one defective unit:

P_0=(1-p)^n

and

P_1=np(1-p)^{n-1}.

According to the attribute-case ChSP-1 plan, the probability of acceptance is

P_a=P_0+P_1P_0^i.

where 'i' is the number of preceding samples considered in the chain.

The function determines the minimum sample size 'n' satisfying the consumer's risk condition

P_a\leq\beta.

The lifetime distribution is not embedded in the function. The user calculates the failure probability 'p' from the required lifetime distribution and supplies it to the function.

Value

A data frame containing 'a', 'b', 'p', 'i', 'beta', the probabilities 'P0' and 'P1', the required sample size 'n', and the probability of acceptance 'Pa'.

Examples


# ----------------------------------------------------------
# Example 1: User-defined failure probabilities
# ----------------------------------------------------------

p <- c(0.05, 0.10, 0.15, 0.20)

chsp1_asip(
  p = p,
  a = c(0.5, 1, 1.5, 2),
  b = 1,
  i = 3,
  beta = 0.25
)


# ----------------------------------------------------------
# Example 2: Weibull distribution
# ----------------------------------------------------------

shape <- 2
b <- 1

a <- c(
  0.5, 0.75, 1, 1.25,
  1.5, 1.75, 2
)

p <- 1 - exp(
  -((a / b)^shape)
)

chsp1_asip(
  p = p,
  a = a,
  b = b,
  i = 3,
  beta = 0.25
)


# ----------------------------------------------------------
# Example 3: Generalized Exponential distribution
# Scale parameterization
# ----------------------------------------------------------

alpha <- 2
b <- 1

a <- c(
  0.5, 0.75, 1, 1.25,
  1.5, 1.75, 2
)

p <- (
  1 - exp(-a / b)
)^alpha

chsp1_asip(
  p = p,
  a = a,
  b = b,
  i = 3,
  beta = 0.25
)


Compare ChSP-1, MChSP-1, MDS and MChSP

Description

Compares the minimum required sample sizes of four attribute sampling inspection plans: ChSP-1, MChSP-1, MDS and MChSP under a time-truncated life test.

Usage

compare_chain_plans(
  p,
  a,
  b,
  i_ChSP1 = 1,
  i_MChSP1 = 1,
  i_MDS = 1,
  i_MChSP = 1,
  beta = 0.25,
  c1 = 0,
  c2 = 1,
  c = 1,
  n_max = 10000
)

Arguments

p

User-defined probability of failure before the termination time. It must lie strictly between 0 and 1.

a

Termination ratio, defined as a = t/theta0. It must be a positive numeric value.

b

Quality ratio, defined as b = theta/theta0. It must be a positive numeric value.

i_ChSP1

Number of preceding samples or lots considered in the chain for ChSP-1. It must be a positive integer.

i_MChSP1

Number of preceding samples or lots considered in the chain for MChSP-1. It must be a positive integer.

i_MDS

Number of preceding samples or lots considered in the chain for MDS. It must be a positive integer.

i_MChSP

Number of preceding samples or lots considered in the chain for MChSP. It must be a positive integer.

beta

Consumer's risk. It must be a value between 0 and 1.

c1

First acceptance number for the MDS plan. It must be a non-negative integer.

c2

Second acceptance number for the MDS plan. It must be an integer greater than or equal to 'c1'.

c

Acceptance number for the MChSP plan. It must be a non-negative integer.

n_max

Maximum sample size to be searched. It must be a positive integer.

Details

The probability of failure before the termination time is supplied directly by the user through 'p'. Therefore, the sampling-plan calculations are distribution-free and can be used with different lifetime distributions.

All four plans are designed using the single consumer's risk constraint

P_a\leq\beta.

For ChSP-1, the probability of acceptance is

P_a=P_0+P_1P_0^i,

where

P_0=(1-p)^n

and

P_1=np(1-p)^{n-1}.

For MChSP-1, the probability of acceptance is

P_a=P_0^{i+1}+iP_0^iP_1.

For MDS, define

A=P(D\leq c_1)

and

B=P(c_1<D\leq c_2).

The probability of acceptance satisfies

P_a=A+B(P_a)^i.

For MChSP, let

m=P(D\leq c).

The probability of acceptance is

P_a=m[m^i+i m^{i-1}(1-m)].

The function searches for the minimum sample size satisfying the consumer's risk constraint for each plan.

Value

A data frame containing the design parameters, the user-specified chain lengths, minimum sample sizes and probabilities of acceptance for ChSP-1, MChSP-1, MDS and MChSP.

Examples


# ----------------------------------------------------------
# Example 1: User-defined failure probabilities
# ----------------------------------------------------------

p <- c(
  0.02, 0.04, 0.06, 0.08,
  0.10, 0.12, 0.14, 0.16
)

compare_chain_plans(
  p = p,
  a = c(
    0.5, 0.75, 1, 1.25,
    1.5, 1.75, 2, 2.25
  ),
  b = 1,
  i_ChSP1 = 1,
  i_MChSP1 = 2,
  i_MDS = 3,
  i_MChSP = 4,
  beta = 0.25,
  c1 = 0,
  c2 = 1,
  c = 1
)


# ----------------------------------------------------------
# Example 2: Weibull distribution
# ----------------------------------------------------------

shape <- 2
b <- 1

a <- c(
  0.5, 0.75, 1, 1.25,
  1.5, 1.75, 2
)

p <- 1 - exp(
  -((a / b)^shape)
)

compare_chain_plans(
  p = p,
  a = a,
  b = b,
  i_ChSP1 = 1,
  i_MChSP1 = 2,
  i_MDS = 3,
  i_MChSP = 4,
  beta = 0.25,
  c1 = 0,
  c2 = 1,
  c = 1
)


# ----------------------------------------------------------
# Example 3: Generalized Exponential distribution
# Scale parameterization
# ----------------------------------------------------------

alpha <- 2
b <- 1

a <- c(
  0.5, 0.75, 1, 1.25,
  1.5, 1.75, 2
)

p <- (
  1 - exp(-a / b)
)^alpha

compare_chain_plans(
  p = p,
  a = a,
  b = b,
  i_ChSP1 = 1,
  i_MChSP1 = 2,
  i_MDS = 3,
  i_MChSP = 4,
  beta = 0.25,
  c1 = 0,
  c2 = 1,
  c = 1
)


Modified Chain Sampling Inspection Plan (MChSP-1)

Description

Calculates the minimum required sample size for a Modified Chain Sampling Inspection Plan (MChSP-1) under a time-truncated life test.

Usage

mchsp1_asip(p, a, b, i = 1, beta = 0.25, n_max = 10000)

Arguments

p

User-defined probability of failure before the termination time. It must lie strictly between 0 and 1.

a

Termination ratio, defined as a = t/theta0. It must be a positive numeric value.

b

Quality ratio, defined as b = theta/theta0. It must be a positive numeric value.

i

Number of preceding samples considered in the chain. It must be a positive integer.

beta

Consumer's risk. It must be a value between 0 and 1.

n_max

Maximum sample size to be searched. It must be a positive integer.

Details

The probability of failure before the termination time is supplied directly by the user through 'p'. Therefore, the function is distribution-free.

Let

P_0=(1-p)^n

denote the probability of observing zero defective units and

P_1=np(1-p)^{n-1}

denote the probability of observing exactly one defective unit.

For the attribute-case MChSP-1 plan, the probability of acceptance is

P_a=P_0^{i+1}+iP_0^iP_1.

where 'i' is the number of preceding samples considered in the chain.

The function determines the minimum sample size 'n' satisfying

P_a\leq\beta.

Value

A data frame containing 'a', 'b', 'p', 'i', 'beta', the probabilities 'P0' and 'P1', the required sample size 'n', and the probability of acceptance 'Pa'.

Examples


# ----------------------------------------------------------
# Example 1: User-defined failure probabilities
# ----------------------------------------------------------

p <- c(0.05, 0.10, 0.15, 0.20)

mchsp1_asip(
  p = p,
  a = c(0.5, 1, 1.5, 2),
  b = 1,
  i = 3,
  beta = 0.25
)


# ----------------------------------------------------------
# Example 2: Weibull distribution
# ----------------------------------------------------------

shape <- 2
b <- 1

a <- c(
  0.5, 0.75, 1, 1.25,
  1.5, 1.75, 2
)

p <- 1 - exp(
  -((a / b)^shape)
)

mchsp1_asip(
  p = p,
  a = a,
  b = b,
  i = 3,
  beta = 0.25
)


# ----------------------------------------------------------
# Example 3: Generalized Exponential distribution
# Scale parameterization
# ----------------------------------------------------------

alpha <- 2
b <- 1

a <- c(
  0.5, 0.75, 1, 1.25,
  1.5, 1.75, 2
)

p <- (
  1 - exp(-a / b)
)^alpha

mchsp1_asip(
  p = p,
  a = a,
  b = b,
  i = 3,
  beta = 0.25
)


Modified Chain Sampling Inspection Plan (MChSP)

Description

Calculates the minimum required sample size for a Modified Chain Sampling Inspection Plan (MChSP) for inspection by attributes under a time-truncated life test.

Usage

mchsp_asip(p, a, b, i = 1, beta = 0.25, c = 0, n_max = 10000)

Arguments

p

User-defined probability of failure before the termination time. It must lie strictly between 0 and 1.

a

Termination ratio, defined as a = t/theta0. It must be a positive numeric value.

b

Quality ratio, defined as b = theta/theta0. It must be a positive numeric value.

i

Number of preceding lots considered in the chain. It must be a positive integer.

beta

Consumer's risk. It must be a value between 0 and 1.

c

Acceptance criterion. It must be a non-negative integer.

n_max

Maximum sample size to be searched. It must be a positive integer.

Details

The probability of failure before the termination time is supplied directly by the user through 'p'. Therefore, the function is distribution-free.

The MChSP plan for attributes is specified by the three integers '(n, c, i)', where 'n' is the sample size, 'c' is the acceptance criterion and 'i' is the number of preceding lots considered.

Let 'D' denote the number of defective units in a sample. Under a binomial model,

D\sim Binomial(n,p).

Define

m=P(D\leq c).

The acceptance probability of the MChSP plan is

P_a=m\left[m^i+i m^{i-1}(1-m)\right].

The function determines the minimum sample size 'n' satisfying

P_a\leq\beta.

For 'c = 0', the MChSP plan is related to the MChSP-1 plan.

Value

A data frame containing 'a', 'b', 'p', 'i', 'beta', 'c', 'm', the required sample size 'n', and the probability of acceptance 'Pa'.

Examples


# ----------------------------------------------------------
# Example 1: User-defined failure probabilities
# ----------------------------------------------------------

p <- c(0.05, 0.10, 0.15, 0.20)

mchsp_asip(
  p = p,
  a = c(0.5, 1, 1.5, 2),
  b = 1,
  i = 3,
  beta = 0.25,
  c = 0
)


# ----------------------------------------------------------
# Example 2: MChSP with c = 1
# ----------------------------------------------------------

mchsp_asip(
  p = p,
  a = c(0.5, 1, 1.5, 2),
  b = 1,
  i = 3,
  beta = 0.25,
  c = 1
)


# ----------------------------------------------------------
# Example 3: Weibull distribution
# ----------------------------------------------------------

shape <- 2
b <- 1

a <- c(
  0.5, 0.75, 1, 1.25,
  1.5, 1.75, 2
)

p <- 1 - exp(
  -((a / b)^shape)
)

mchsp_asip(
  p = p,
  a = a,
  b = b,
  i = 3,
  beta = 0.25,
  c = 1
)


# ----------------------------------------------------------
# Example 4: Generalized Exponential distribution
# Scale parameterization
# ----------------------------------------------------------

alpha <- 2
b <- 1

a <- c(
  0.5, 0.75, 1, 1.25,
  1.5, 1.75, 2
)

p <- (
  1 - exp(-a / b)
)^alpha

mchsp_asip(
  p = p,
  a = a,
  b = b,
  i = 3,
  beta = 0.25,
  c = 1
)


Operating Characteristic Values for an MChSP Plan

Description

Calculates operating characteristic (OC) values for a Modified Chain Sampling Inspection Plan (MChSP).

Usage

mchsp_oc(p_design, a, p_oc, b_oc, i = 1, beta = 0.25, c = 0, n_max = 10000)

Arguments

p_design

Failure probability at the design condition. It must lie strictly between 0 and 1.

a

Termination ratio, defined as 'a = t/theta0'.

p_oc

Matrix or data frame of failure probabilities used for OC calculation. Rows correspond to 'a' and columns correspond to 'b_oc'.

b_oc

Quality ratios used for OC calculation.

i

Number of preceding lots considered in the MChSP plan.

beta

Consumer's risk. It must be between 0 and 1.

c

Acceptance criterion. It must be a non-negative integer.

n_max

Maximum sample size searched at the design condition.

Details

The sample size is first determined at the design condition using 'p_design' and the constraint 'Pa <= beta'. The resulting sample size is then kept fixed while 'p_oc' is used to calculate the probability of acceptance for the quality ratios in 'b_oc'.

Let

m=P(D\leq c)

P_a=m[m^i+i m^{i-1}(1-m)].

The resulting 'Pa' values are the OC values for the specified quality ratios.

Value

A data frame containing 'a', 'b', 'p', 'i', 'beta', 'c', fixed 'n', 'ASN', 'm', and 'Pa'. The 'Pa' values are the OC values.

Examples

a <- c(0.5, 1, 1.5, 2)

p_design <- c(0.05, 0.10, 0.15, 0.20)

b_oc <- 2:12

p_oc <- outer(
  a, b_oc,
  function(a, b) pmin(0.95, a / (10 * b))
)

mchsp_oc(
  p_design = p_design,
  a = a,
  p_oc = p_oc,
  b_oc = b_oc,
  i = 3,
  beta = 0.25,
  c = 0
)


Multiple Dependent Sampling Plan (MDS) for Attributes

Description

Calculates the minimum required sample size for an MDS plan for inspection by attributes under a time-truncated life test.

Usage

mds_asip(p, a, b, i = 1, beta = 0.25, c1 = 0, c2 = 1, n_max = 10000)

Arguments

p

User-defined probability of failure before the termination time. It must lie strictly between 0 and 1.

a

Termination ratio, defined as a = t/theta0. It must be a positive numeric value.

b

Quality ratio, defined as b = theta/theta0. It must be a positive numeric value.

i

Number of preceding samples considered in the MDS plan. In the new formulation, 'i' represents the exponent 'm' in 'P_a=A+B A^m'.

beta

Consumer's risk. It must be a value between 0 and 1.

c1

First acceptance number. It must be a non-negative integer.

c2

Second acceptance number. It must be an integer greater than or equal to 'c1'.

n_max

Maximum sample size to be searched. It must be a positive integer.

Details

The probability of failure before the termination time is supplied directly by the user through 'p'. Therefore, the sampling-plan calculation is distribution-free.

The MDS plan is specified by '(n, c1, c2, i)'.

Let D denote the number of defective units in a sample. Under the binomial model,

D\sim Binomial(n,p).

Define

A=P(D\leq c_1)

and

B=P(c_1<D\leq c_2).

The new MDS acceptance probability is

P_a=A+B A^m,

where 'm' is the number of preceding samples. In this implementation, the existing argument 'i' is retained for compatibility and represents 'm'.

Equivalently,

P_a = \sum_{D=0}^{c_1}{n\choose D}p^D(1-p)^{n-D} + \left[ \sum_{D=c_1+1}^{c_2}{n\choose D}p^D(1-p)^{n-D} \right] \left[ \sum_{D=0}^{c_1}{n\choose D}p^D(1-p)^{n-D} \right]^m.

The function determines the minimum sample size 'n' satisfying

P_a\leq\beta.

Value

A data frame containing 'a', 'b', 'p', 'i', 'beta', 'c1', 'c2', the probabilities 'A' and 'B', the required sample size 'n', and the probability of acceptance 'Pa'.

Examples


# ----------------------------------------------------------
# Example 1: User-defined failure probabilities
# ----------------------------------------------------------

p <- c(0.05, 0.10, 0.15, 0.20)

mds_asip(
  p = p,
  a = c(0.5, 1, 1.5, 2),
  b = 1,
  i = 3,
  beta = 0.25,
  c1 = 0,
  c2 = 1
)


# ----------------------------------------------------------
# Example 2: Weibull distribution
# ----------------------------------------------------------

shape <- 2
b <- 1

a <- c(
  0.5, 0.75, 1, 1.25,
  1.5, 1.75, 2
)

p <- 1 - exp(
  -((a / b)^shape)
)

mds_asip(
  p = p,
  a = a,
  b = b,
  i = 3,
  beta = 0.25,
  c1 = 0,
  c2 = 1
)


# ----------------------------------------------------------
# Example 3: Generalized Exponential distribution
# Scale parameterization
# ----------------------------------------------------------

alpha <- 2
b <- 1

a <- c(
  0.5, 0.75, 1, 1.25,
  1.5, 1.75, 2
)

p <- (
  1 - exp(-a / b)
)^alpha

mds_asip(
  p = p,
  a = a,
  b = b,
  i = 3,
  beta = 0.25,
  c1 = 0,
  c2 = 1
)


Plot Comparison of ChSP-1, MChSP-1, MDS and MChSP

Description

Produces a comparison plot of the minimum sample sizes required by ChSP-1, MChSP-1, MDS and MChSP.

Usage

plot_chain_plans(
  p,
  a,
  b,
  i_ChSP1 = 1,
  i_MChSP1 = 1,
  i_MDS = 1,
  i_MChSP = 1,
  beta = 0.25,
  c1 = 0,
  c2 = 1,
  c = 1,
  n_max = 10000,
  ylim = NULL
)

Arguments

p

User-defined probability of failure before the termination time. It must lie strictly between 0 and 1.

a

Termination ratio, defined as a = t/theta0. It must be a positive numeric value.

b

Quality ratio, defined as b = theta/theta0. It must be a positive numeric value.

i_ChSP1

Number of preceding samples or lots considered in the chain for ChSP-1. It must be a positive integer.

i_MChSP1

Number of preceding samples or lots considered in the chain for MChSP-1. It must be a positive integer.

i_MDS

Number of preceding samples or lots considered in the chain for MDS. It must be a positive integer.

i_MChSP

Number of preceding samples or lots considered in the chain for MChSP. It must be a positive integer.

beta

Consumer's risk. It must be a value between 0 and 1.

c1

First acceptance number for MDS.

c2

Second acceptance number for MDS.

c

Acceptance number for MChSP.

n_max

Maximum sample size to be searched.

ylim

Numeric vector of length two specifying the limits of the y-axis. Default is 'NULL'.

Details

The probability of failure before the termination time is supplied by the user through 'p'.

The x-axis represents the termination ratio a=t/theta0 and the y-axis represents the minimum required sample size.

All plans satisfy the common consumer's risk constraint

P_a\leq\beta.

Value

The comparison data frame is returned invisibly. The function also produces the comparison plot.

Examples


# ----------------------------------------------------------
# Example 1: User-defined failure probabilities
# ----------------------------------------------------------

p <- c(
  0.02, 0.04, 0.06, 0.08,
  0.10, 0.12, 0.14, 0.16
)

a <- c(
  0.5, 0.75, 1, 1.25,
  1.5, 1.75, 2, 2.25
)

plot_chain_plans(
  p = p,
  a = a,
  b = 1,
  i_ChSP1 = 1,
  i_MChSP1 = 2,
  i_MDS = 3,
  i_MChSP = 4,
  beta = 0.25,
  c1 = 0,
  c2 = 1,
  c = 1
)


# ----------------------------------------------------------
# Example 2: Weibull distribution
# ----------------------------------------------------------

shape <- 2
b <- 1

a <- c(
  0.5, 0.75, 1, 1.25,
  1.5, 1.75, 2
)

p <- 1 - exp(
  -((a / b)^shape)
)

plot_chain_plans(
  p = p,
  a = a,
  b = b,
  i_ChSP1 = 1,
  i_MChSP1 = 2,
  i_MDS = 3,
  i_MChSP = 4,
  beta = 0.25,
  c1 = 0,
  c2 = 1,
  c = 1
)


# ----------------------------------------------------------
# Example 3: Generalized Exponential distribution
# Scale parameterization
# ----------------------------------------------------------

alpha <- 2
b <- 0.5

a <- c(
  0.5, 0.75, 1, 1.25,
  1.5, 1.75, 2
)

p <- (
  1 - exp(-a / b)
)^alpha

plot_chain_plans(
  p = p,
  a = a,
  b = b,
  i_ChSP1 = 1,
  i_MChSP1 = 2,
  i_MDS = 3,
  i_MChSP = 4,
  beta = 0.25,
  c1 = 0,
  c2 = 1,
  c = 1
)


Plot OC Values for an MChSP Plan

Description

Produces a base R OC curve using the 'Pa' values returned by 'mchsp_oc()'.

Usage

plot_mchsp_oc(x, ...)

Arguments

x

Output from 'mchsp_oc()'.

...

Additional graphical arguments passed to 'plot()'.

Details

Different termination ratios 'a' are distinguished using different plotting symbols and line types.

Value

Invisibly returns the supplied data frame.

Examples

a <- c(0.5, 1, 1.5, 2)
p_design <- c(0.05, 0.10, 0.15, 0.20)
b_oc <- 2:12

p_oc <- sapply(
  b_oc,
  function(b) a / (10 * b)
)

result <- mchsp_oc(
  p_design = p_design,
  a = a,
  p_oc = p_oc,
  b_oc = b_oc,
  i = 3,
  beta = 0.25,
  c = 0
)

plot_mchsp_oc(result)

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.