---
title: "Generalized Process Capability Indices for Interval-Censored Data"
author: "Shikhar Tyagi, Sumit Kumar, Arvind Pandey, Bhupendra Singh, Vrijesh Tripathi"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Generalized Process Capability Indices for Interval-Censored Data}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

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

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

## Introduction

The `gpciIntCensor` package provides a unified, comprehensive framework for evaluating Generalized Process Capability Indices (GPCIs) under interval-censored data using Maximum Likelihood Estimation (MLE) via `MleCensoR` and bootstrap confidence intervals.

Supported capability indices include:
* $C_{py}$ (Maiti et al., 2010)
* $S_{pmk}$ (Dey & Saha, 2019)
* $C_{pTk}$ (Saha et al., 2019)
* $C_{pc}$ (Saha et al., 2022)
* $C_{Npmc}$ (Alotaibi et al., 2022)
* $C_{Npmkc}$ (Saha et al., 2024)
* $C_{Npk}$ (Saha et al., 2018)
* Vännman's $C_p(u,v)$ family and quantile analogs.

## Workflow Example

### 1. Define Distribution and Generate Interval-Censored Data

```{r data_prep}
# Define normal distribution
dist_norm <- dist_normal(mean = 10, sd = 1.5)

# Simulate interval-censored data
set.seed(123)
true_vals <- rnorm(30, mean = 10, sd = 1.5)
data_left <- true_vals - 0.25
data_right <- true_vals + 0.25
```

### 2. Fit Parameters via MLE for Interval-Censored Data

```{r fit_dist}
dist_fitted <- fit_distribution_censor(data_left, data_right, dist_norm)
print(dist_fitted$params)
```

### 3. Compute Capability Indices

```{r capability_calc}
fit_cap <- capability_censor(
  data_left = data_left,
  data_right = data_right,
  distribution = dist_norm,
  USL = 14,
  LSL = 6,
  target = 10,
  indices = c("Cpy", "Cp", "Cpk", "Cpm", "Cpmk", "Spmk", "CpTk", "CNpmc"),
  mode = "moments"
)

print(fit_cap)
```

### 4. Bootstrap Confidence Intervals (90%, 95%, 99%)

```{r boot_ci_example}
ci_res <- boot_ci_censor(
  fit = fit_cap,
  B = 100,
  alpha = c(0.10, 0.05, 0.01),
  method = "percentile",
  type = "nonparametric"
)

print(ci_res)
```

### 5. Diagnostics: SE, MSE, and Coverage Probabilities

```{r diagnostics_example}
diag_res <- compute_diagnostics_censor(
  fit = fit_cap,
  true_params = list(mean = 10, sd = 1.5),
  true_indices = c(Cpy = 1.0, Cp = 1.33),
  B = 50
)

print(diag_res)
```

### 6. Visualization

```{r plot_example, fig.width=7, fig.height=4}
plot(fit_cap)
```

## References

* Maiti, S. S., Saha, M., & Nanda, A. K. (2010). On Generalizing Process Capability Indices. *Quality Technology & Quantitative Management*, 7(3), 279-300.
* 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.
* Dey, S., & Saha, M. (2019). Assessing the process capability index Spmk using improved estimators. *Life Cycle Reliability and Safety Engineering*, 8(3), 253-264.
* 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*, 10(4), 861-872.
* 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.
* 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.
* Saha, M., Tripathi, H., & 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.
