---
title: "Generalized Process Capability Indices for Progressive Type-II Censored Data using Importance Sampling"
author: "Shikhar Tyagi"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Generalized Process Capability Indices for Progressive Type-II Censored Data using Importance Sampling}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

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

## Introduction

The `gpciProgTyIIImpSam` package provides Bayesian parameter estimation and Generalized Process Capability Indices (GPCIs) under **Progressive Type-II Censoring** using **Importance Sampling (Sampling Importance Resampling, SIR)**.

Supported capability indices include $C_{py}$, $C_p$, $C_{pk}$, $C_{pu}$, $C_{pl}$, $C_{pm}$, $C_{pmk}$, $S_{pmk}$, $C_{pTk}$, $C_{pc}$, $C_{Np}$, $C_{Npk}$, $C_{Npm}$, $C_{Npmk}$, $C_{Npmc}$, $C_{Npmkc}$, and Vännman's $C_p(u,v)$ family.

## Example: Custom Exponential Distribution

```r
library(gpciProgTyIIImpSam)

# 1. User-defined PDF, CDF, and Survival functions
my_pdf <- function(x, rate = 1) dexp(x, rate = rate)
my_cdf <- function(q, rate = 1) pexp(q, rate = rate)
my_surv <- function(q, rate = 1) pexp(q, rate = rate, lower.tail = FALSE)

# 2. Progressive Type-II Censored Failure Times and Removals
x_data <- c(0.8, 1.5, 2.3, 3.1, 4.2)
removals <- c(1, 0, 1, 0, 1)

# 3. Fit Importance Sampling GPCI Model
fit <- gpci_prog_ty2_impsam(
  x = x_data,
  r_removals = removals,
  pdf = my_pdf,
  cdf = my_cdf,
  surv = my_surv,
  start = c(rate = 0.5),
  chain_length = 500,
  burn_in = 100,
  thinning = 1,
  USL = 8,
  LSL = 0
)

# 4. View Results and Diagnostic Summary
print(fit)
summary(fit)
```
