---
title: "Generalized Process Capability Indices under Hybrid Type-II Censoring"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Generalized Process Capability Indices under Hybrid Type-II Censoring}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

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

## Introduction

The **`gpcihybridII`** package provides a comprehensive, generalized framework for estimating, computing, and validating Generalized Process Capability Indices (GPCIs) under **Hybrid Type-II censored lifetime data**.

Under Hybrid Type-II censoring (Childs et al., 2003; Balakrishnan & Kundu, 2013), $n$ identical units are placed on life test with a pre-fixed target number of failures $r \in \{1, \dots, n\}$ and a pre-fixed censoring time $T_0$ ($t_c$). The experiment terminates at $T^* = \max(X_{r:n}, T_0)$.

The package:
1. Fits distribution parameters under Hybrid Type-II censored data using Maximum Likelihood Estimation via the `MleCensoR` package (`mle_hybrid_type2`).
2. Evaluates classical capability indices ($C_p, C_{pk}, C_{pm}, C_{pmk}, C_p(u, v)$) and generalized capability indices from literature ($C_{py}, S_{pmk}, C_{pTk}, C_{pc}, CN_{pmc}, CN_{pmkc}, CN_{pk}$).
3. Calculates parametric and non-parametric bootstrap confidence intervals (Percentile, Normal, Basic, BCp, BCa, Studentized) at 90 percent, 95 percent, and 99 percent confidence levels.
4. Computes performance metrics (Standard Errors, Bias, MSE) and Coverage Probabilities for model parameters and capability indices.
5. Integrates goodness-of-fit testing for Hybrid Type-II censored data via the `gofPHCS` package.

---

## Example 1: Analysis with Exponential Distribution

```{r example1}
library(gpcihybridII)

# 1. Define Exponential distribution
dist_exp <- dist_exponential(rate = 1)

# 2. Observed failure times under Hybrid Type-II censoring
# Total units n = 10, target failures r = 3, censoring time tc = 1.0
x_data <- c(0.18, 0.42, 0.75, 0.95)

# 3. Process Capability Analysis
fit <- capability_hybrid2(
  x = x_data, r = 3, tc = 1.0, n = 10,
  distribution = dist_exp,
  USL = 3.0, LSL = 0.0, target = 1.5,
  indices = c("Cpy", "Spmk", "CpTk", "Cpc", "CNpmc", "CNpmkc", "Cp", "Cpk", "Cpm", "Cpmk"),
  mode = "moments"
)
print(fit)
```

---

## Example 2: Bootstrap Confidence Intervals

```{r example2}
# Compute Bootstrap CIs at 90%, 95%, and 99% confidence levels
ci_res <- boot_ci_hybrid2(
  fit = fit,
  B = 50,
  alpha = c(0.10, 0.05, 0.01),
  method = "percentile",
  type = "parametric"
)
print(ci_res)
```

---

## Example 3: Diagnostics and Performance Evaluation

```{r example3}
diag_res <- compute_diagnostics_hybrid2(
  fit = fit,
  true_params = c(rate = 1),
  B = 30
)
print(diag_res)
```

---

## Example 4: Goodness-of-Fit Testing

```{r example4}
gof_res <- gof_test_hybrid2(
  fit = fit,
  p.method = "montecarlo",
  nsim = 30
)
print(gof_res)
```

---

## References

* Alotaibi, N., Dey, S., & Saha, M. (2022). Estimation and Confidence Intervals of a New PCI $CN_{pmc}$ for Logistic-Exponential Distribution. *Journal of Mathematics*, 2022, 3135264. <https://doi.org/10.1155/2022/3135264>
* Balakrishnan, N., & Kundu, D. (2013). Hybrid censoring: models, methods and applications. *Naval Research Logistics*, 60(5), 359-385. <https://doi.org/10.1002/nav.21545>
* Childs, A., Chandrasekar, B., Balakrishnan, N., & Kundu, D. (2003). Exact likelihood inference for Type-I and Type-II hybrid censored data from the exponential distribution. *Annals of the Institute of Statistical Mathematics*, 55(2), 319-330. <https://doi.org/10.1007/BF02517803>
* Dey, S., & Saha, M. (2019). Assessing the process capability index $S_{pmk}$ for Gompertz distribution. *Quality and Reliability Engineering International*, 35(8), 2639-2661. <https://doi.org/10.1007/s41872-019-00081-4>
* Maiti, S. S., Saha, M., & Nanda, A. K. (2010). On generalizing process capability indices. *International Journal of Quality & Reliability Management*, 27(6), 704-715. <https://doi.org/10.1080/16843703.2010.11673233>
* Saha, M., Dey, S., & Maiti, S. S. (2018). Classical and Bayesian inference of $C_{py}$ for Lindley distribution. *Quality Technology & Quantitative Management*, 15(6), 724-746. <https://doi.org/10.1080/21681015.2018.1437793>
* Saha, M., Dey, S., & Nadarajah, S. (2022). On generalizing process capability index $C_{pc}$. *Journal of Applied Statistics*, 49(14), 3624-3642. <https://doi.org/10.1080/02664763.2021.1971632>
* Saha, M., Tripathi, V., & Dey, S. (2024). A new generalized process capability index $CN_{pmkc}$ under non-normal processes. *Communications in Statistics - Simulation and Computation*. <https://doi.org/10.1142/S021853932450013X>
