Package {rMDSPTT}


Type: Package
Title: Multiple Dependent State Sampling Inspection Plan for Time Truncated Life Test
Version: 0.1.0
Description: Provides functions for designing multiple dependent state sampling inspection plans for time-truncated life tests. The package determines the minimum sample size required to satisfy a specified consumer's risk constraint and evaluates the probability of acceptance under different quality and termination ratios. Users can directly provide failure probabilities, allowing the sampling plan to be applied to different lifetime distributions without requiring distribution-specific functions. Provide operating characteristic analysis, sample size analysis, and graphical comparison with single sampling inspection plans. Aslam et al. (2016) <doi:10.1080/08982112.2015.1068331>; Rao et al. (2020) <doi:10.1080/25742558.2020.1857915>; Balamurali et al. (2017) <doi:10.1080/07474946.2016.1275459>; Saha et al. (2021) <doi:10.1080/21681015.2021.1893843>; Tripathi et al. (2020) <doi:10.1007/s40745-020-00267-z>; Tripathi et al. (2023) <doi:10.1007/s41872-023-00221-x>.
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-22 17:04:49 UTC; Admin
Author: Harsh Tripathi [aut, cre]
Maintainer: Harsh Tripathi <rsearchstat21@gmail.com>
Repository: CRAN
Date/Publication: 2026-10-02 10:00:13 UTC

Compare MDS and Single Sampling Plans

Description

Compares the minimum sample size required by an MDS plan and a corresponding single sampling plan (SSP).

Usage

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

Arguments

p

User-defined failure probability.

a

Termination ratio.

b

Quality ratio.

i

Number of preceding lots in the MDS plan.

beta

Consumer's risk.

c1

MDS first acceptance number and SSP acceptance number.

c2

MDS second acceptance number.

n_max

Maximum sample size searched.

Details

The SSP uses acceptance number 'c1', while the MDS plan uses '(c1, c2, i)'. Both plans use the same failure probability ‘p' and consumer’s risk 'beta'.

The MDS sample size is determined from

P_a=A+B A^i\leq\beta.

The SSP sample size is determined from

P(D\leq c_1)\leq\beta.

Since the sample size is fixed for each inspected lot under both plans, ASN is equal to sample size for both plans.

Value

A data frame containing the sample sizes required by the MDS and SSP plans.

Examples


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

p <- c(0.05, 0.10, 0.15, 0.20)
a <- c(0.5, 1, 1.5, 2)

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

# ----------------------------------------------------------
# Example 2: Generalized Exponential distribution
# ----------------------------------------------------------

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_mds_ssp(
  p = p,
  a = a,
  b = 1,
  i = 3,
  beta = 0.25,
  c1 = 0,
  c2 = 1
)

Multiple Dependent State Sampling Plan (MDS)

Description

Calculates the minimum sample size for a Multiple Dependent State Sampling (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 contain positive values.

b

Quality ratio, defined as 'b = theta/theta0'. It must contain positive values. It is included to identify the design condition associated with 'p'.

i

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

beta

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

c1

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

c2

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

n_max

Maximum sample size to be searched.

Details

The failure probability before the termination time is supplied directly by the user through 'p'. Thus, the function 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 probability of acceptance of the MDS plan is obtained from

P_a=A+B A^i.

The minimum sample size is the smallest 'n' satisfying

P_a\leq\beta.

For this MDS plan, the sample size of every inspected lot is fixed at 'n'. Therefore, the average sample number (ASN) is exactly equal to 'n'.

Value

A data frame containing the design values, minimum sample size 'n', ASN, probabilities 'A' and 'B', and the probability of acceptance 'Pa'.

Examples


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

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

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

mds_asip(
  p = p,
  a = a,
  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
# ----------------------------------------------------------

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
)


Operating Characteristic Values for an MDS Plan

Description

Calculates the operating characteristic (OC) values for a Multiple Dependent State Sampling (MDS) plan.

Usage

mds_oc(
  p_design,
  a,
  p_oc,
  b_oc,
  i = 1,
  beta = 0.25,
  c1 = 0,
  c2 = 1,
  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 MDS plan.

beta

Consumer's risk.

c1

First acceptance number.

c2

Second acceptance number.

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'. This sample size is then kept fixed while the failure probabilities in 'p_oc' are used to calculate the probability of acceptance for the quality ratios in 'b_oc'.

Let

A=P(D\leq c_1)

and

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

The MDS probability of acceptance satisfies

P_a=A+B A^i.

The resulting 'Pa' values are the OC values for the specified quality ratios in 'b_oc', using 'Pa = A + B A^i'.

Value

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

Examples


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

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

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

b_oc <- 2:12

# User-defined probabilities for OC calculation.
# Rows correspond to a and columns correspond to b.
p_oc <- outer(
  a,
  b_oc,
  function(a, b) pmin(0.95, a / (10 * b))
)

# The n values are determined using p_design and then
# kept fixed for all b values.
#
# The Pa values represent the OC values.

mds_oc(
  p_design = p_design,
  a = a,
  p_oc = p_oc,
  b_oc = b_oc,
  i = 3,
  beta = 0.25,
  c1 = 0,
  c2 = 1
)


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

shape <- 2

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

# Design quality ratio
b_design <- 1

# Failure probabilities at b = 1
p_design <- 1 - exp(
  -((a / b_design)^shape)
)

# Quality ratios for OC calculation
b_oc <- 2:12

# Failure probabilities for each a and b
p_oc <- sapply(
  b_oc,
  function(b)
    1 - exp(-((a / b)^shape))
)

mds_oc(
  p_design = p_design,
  a = a,
  p_oc = p_oc,
  b_oc = b_oc,
  i = 3,
  beta = 0.25,
  c1 = 0,
  c2 = 1
)


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

alpha <- 2

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

# Design quality ratio
b_design <- 1

# Failure probabilities at b = 1
p_design <- (
  1 - exp(-a / b_design)
)^alpha

# Quality ratios for OC calculation
b_oc <- 2:12

# Failure probabilities for each a and b
p_oc <- sapply(
  b_oc,
  function(b)
    (1 - exp(-a / b))^alpha
)

mds_oc(
  p_design = p_design,
  a = a,
  p_oc = p_oc,
  b_oc = b_oc,
  i = 3,
  beta = 0.25,
  c1 = 0,
  c2 = 1
)


Plot MDS and SSP Sample Size Comparison

Description

Produces a base R plot comparing MDS and SSP sample sizes against the termination ratio.

Usage

plot_compare_mds_ssp(x, ...)

Arguments

x

Output from 'compare_mds_ssp()'.

...

Additional graphical arguments passed to 'plot()'.

Details

Since ASN equals sample size for both plans, the same plot also represents the ASN comparison.

Value

Invisibly returns the supplied data frame.

Examples


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

p <- c(0.05, 0.10, 0.15, 0.20)
a <- c(0.5, 1, 1.5, 2)

result <- compare_mds_ssp(
  p = p,
  a = a,
  b = 1,
  i = 3,
  beta = 0.25,
  c1 = 0,
  c2 = 1
)

plot_compare_mds_ssp(result)

# ----------------------------------------------------------
# Example 2: Generalized Exponential distribution
# ----------------------------------------------------------

alpha <- 2
b <- 1
a <- c(0.5, 0.75, 1, 1.25, 1.5, 1.75, 2)
p <- (1- exp(-a / b))^alpha
result <- compare_mds_ssp(
 p = p,
 a = a,
 b = 1,
 i = 3,
 beta = 0.25,
 c1 = 0,
 c2 = 1
)
plot_compare_mds_ssp(result)

Plot MDS Sample Size Against Termination Ratio

Description

Produces a base R plot of the minimum sample size against the termination ratio 'a'.

Usage

plot_mds_n(x, ...)

Arguments

x

Output from 'mds_asip()'.

...

Additional graphical arguments passed to 'plot()'.

Details

For the MDS plan considered here, ASN is exactly equal to the sample size 'n'. Therefore, the plot can also be interpreted as ASN against the termination ratio.

Value

Invisibly returns the supplied data frame.

Examples


# ----------------------------------------------------------
# Example 1: User-defined failure probabilities
# ----------------------------------------------------------
a <- c(0.5, 1, 1.5, 2)
p <- c(0.05, 0.10, 0.15, 0.20)

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

plot_mds_n(result)


# ----------------------------------------------------------
# Example 2: Generalized Exponential distribution
# ----------------------------------------------------------

alpha <- 2
b <- 1
a <- c(0.5, 0.75, 1, 1.25, 1.5, 1.75, 2)
p <- ( 1- exp(-a / b))^alpha

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


Plot OC Values for an MDS Plan

Description

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

Usage

plot_mds_oc(x, ...)

Arguments

x

Output from 'mds_oc()'.

...

Additional graphical arguments passed to 'plot()'.

Details

Different termination ratios 'a' are distinguished using different plotting symbols ('pch') and line types ('lty').

Value

Invisibly returns the supplied data frame.

Examples


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

p_design <- 1 - exp(-(a / 1)^shape)

b_oc <- 2:12

p_oc <- sapply(
  b_oc,
  function(b)
    1 - exp(-((a / b)^shape))
)

result <- mds_oc(
  p_design = p_design,
  a = a,
  p_oc = p_oc,
  b_oc = b_oc,
  i = 3,
  beta = 0.25,
  c1 = 0,
  c2 = 1
)

plot_mds_oc(result)