---
title: "Goodness-of-Fit Testing for Location-Scale Distributions via Lorenz Curve"
author: "Shikhar Tyagi, Arvind Pandey, Bhupendra Singh, Vrijesh Tripathi"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Goodness-of-Fit Testing for Location-Scale Distributions via Lorenz Curve}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

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

## Introduction

The **`gofLorenz`** package implements goodness-of-fit (GoF) test statistics and graphical methods for location-scale distributions under progressive Type-II censoring, based on the research by **Lee (2024)**. The testing approach uses the modified Lorenz curve ($mLC$) and ratio modified sample Lorenz curve ($rLC$) to assess how effectively observed failure times align with a target theoretical location-scale distribution.

In addition to Lee (2024)'s test statistics ($L^+, L^-, L^{(1)}, L^{(2)}, L^{(3)}, L^{(4)}$), the package computes order statistics distance test statistics ($C^+, C^-, C_m, K_m, T^{(1)}, T^{(2)}$) proposed by **Pakyari and Balakrishnan (2013)** for comparison.

## Progressive Type-II Censoring Scheme

In progressive Type-II censoring, $n$ units are placed on test. Upon observing the 1st failure ($X_{1:m:n}$), $R_1$ surviving units are randomly removed. Upon observing the 2nd failure ($X_{2:m:n}$), $R_2$ surviving units are randomly removed. Finally, upon observing the $m$-th failure ($X_{m:m:n}$), all remaining $R_m = n - m - \sum_{i=1}^{m-1} R_i$ units are removed.

## Example 1: Breaking Strength Data (Normal Distribution)

Consider the breaking strength data ($n = 20$, $m = 8$) with progressive censoring scheme $R = (0, 4, 1, 3, 0, 2, 0, 2)$:

```{r example1}
library(gofLorenz)

data(breaking_strength)
x1 <- breaking_strength$x
n1 <- breaking_strength$n
m1 <- breaking_strength$m
R1 <- breaking_strength$R

# Perform Goodness-of-Fit Test for Normal Distribution
fit1 <- gof_lorenz(x = x1, n = n1, m = m1, R = R1, dist = "norm", mc_rep = 200)
print(fit1)
```

### Visual Diagnostic: L-plot

The `lorenz_plot()` function graphs $L\text{-plot}(p_{j:m:n}) = |1 - rLC(p_{j:m:n})|$ versus $p_{j:m:n}$. Convergence near 0 supports the hypothesized distribution.

```{r lplot1, fig.width = 6, fig.height = 4}
plot(fit1)
```

## Example 2: Insulating Fluid Data (Gumbel Distribution)

Consider log-transformed insulating fluid test data ($n = 19$, $m = 8$) with scheme $R = (0, 0, 3, 0, 3, 0, 0, 5)$:

```{r example2}
data(insulating_fluid)
x2 <- insulating_fluid$x
n2 <- insulating_fluid$n
m2 <- insulating_fluid$m
R2 <- insulating_fluid$R

# Perform Goodness-of-Fit Test for Gumbel Distribution
fit2 <- gof_lorenz(x = x2, n = n2, m = m2, R = R2, dist = "gumbel", mc_rep = 200)
summary(fit2)
```

## References

- Lee, K. (2024). A New Test Statistic to Assess the Goodness of Fit of Location-Scale Distribution Based on Progressive Censored Data. *Symmetry*, 16(2), 202. <https://doi.org/10.3390/sym16020202>
- Pakyari, R., & Balakrishnan, N. (2013). Goodness-of-fit tests for progressively Type II censored data from location-scale distribution. *Journal of Statistical Computation and Simulation*, 83(1), 167–178. <https://doi.org/10.1080/00949655.2011.625424>
