---
title: "Lindley Approximation Method for Generalized Process Capability Indices"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Lindley Approximation Method for Generalized Process Capability Indices}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
```

```{r setup}
library(gpciLindleyApprox)
```

## Introduction

The `gpciLindleyApprox` package provides a generalized framework for computing, estimating, and validating Generalized Process Capability Indices (GPCIs) using the **Lindley Approximation Method** for uncensored process data under Bayesian inference.

Supported GPCIs include:
- $C_{py}$ (Process Capability Index based on Yield; Maiti, Saha & Nanda, 2010)
- $C_p, C_{pk}, C_{pu}, C_{pl}, C_{pm}, C_{pmk}$
- $C_{pTk}$ (Saha, Dey & Maiti, 2019)
- $S_{pmk}$ (Dey & Saha, 2019)
- $C_{pc}$ (Saha, Dey & Nadarajah, 2022)
- $CN_{pk}$ (Saha, Dey & Maiti, 2018)
- $CN_{pmc}$ (Alotaibi, Dey & Saha, 2022)
- $CN_{pmkc}$ (Saha, Tripathi & Dey, 2024)
- $C_p(u,v)$ Vännman's family (1995)

## Basic Example with Custom PDF/CDF

Below is an example estimating GPCIs for uncensored data generated from a normal process using the high-level user interface function `gpci_lindley()`:

```{r example-custom}
set.seed(42)
data_obs <- rnorm(50, mean = 10, sd = 1)

# Fit GPCIs using Lindley approximation and Bootstrap CIs
fit_res <- gpci_lindley(
  data = data_obs,
  pdf = function(x, mean = 0, sd = 1) dnorm(x, mean = mean, sd = sd),
  cdf = function(x, mean = 0, sd = 1) pnorm(x, mean = mean, sd = sd),
  chain_length = 300,
  burn_in = 50,
  thinning = 1,
  USL = 13,
  LSL = 7,
  B = 100
)

# Display Summary Diagnostics Table
summary(fit_res)
```

## Using Built-in Distribution Objects

The package provides pre-defined distribution objects such as `dist_normal()`, `dist_weibull()`, `dist_gamma()`, `dist_logistic_exponential()`, and `dist_exponentiated_exponential()`:

```{r example-builtin}
dist_weib <- dist_weibull()

fit_weib <- lindley_gpci(
  data = rweibull(50, shape = 2, scale = 5),
  distribution = dist_weib,
  chain_length = 300,
  burn_in = 50,
  thinning = 1,
  USL = 8,
  LSL = 1,
  B = 100
)

summary(fit_weib)
```

## References

1. Lindley, D. V. (1980). Approximate Bayesian methods. *Trabajos de Estadística y de Investigación Operativa*, 31(1), 223-245.
2. Maiti, S. S., Saha, M., & Nanda, A. K. (2010). On generalizing process capability indices. *Quality Technology & Quantitative Management*, 7(3), 279-289.
3. Saha, M., Dey, S., & Maiti, S. S. (2018). Parametric and non-parametric bootstrap confidence intervals of CNpk for exponential power distribution. *Journal of Industrial and Production Engineering*, 35(3), 160-169.
4. Dey, S., & Saha, M. (2019). Assessing the process capability index Spmk using improved estimators. *Life Cycle Reliability and Safety Engineering*, 8, 81-88.
5. Saha, M., Dey, S., & Maiti, S. S. (2019). Bootstrap confidence intervals of CpTk for two parameter logistic exponential distribution with applications. *International Journal of System Assurance Engineering and Management*.
6. Alotaibi, R., Dey, S., & Saha, M. (2022). Estimation and confidence intervals of a new PCI CNpmc for logistic-exponential process distribution. *Journal of Mathematics*, 2022, 3135264.
7. Saha, M., Dey, S., & Nadarajah, S. (2022). Parametric inference of the process capability index Cpc for exponentiated exponential distribution. *Journal of Applied Statistics*, 49(16), 4097-4121.
8. Saha, M., Tripathi, V., & Dey, S. (2024). Classical inference of a new PCI CNpmkc for logistic-exponential process distribution. *International Journal of Reliability, Quality and Safety Engineering*, 31(3), 2450013.
