---
title: "Modified Topp-Leone Distribution: Properties, Estimation, and Applications"
author: "Shikhar Tyagi, Abhishek Tyagi, Arvind Pandey, Bhupendra Singh, Vrijesh Tripathi"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Modified Topp-Leone Distribution: Properties, Estimation, and Applications}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r setup, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.width = 6,
  fig.height = 4
)
library(ModToppLeone)
```

## Introduction

The **`ModToppLeone`** package provides comprehensive tools for working with the Modified Topp-Leone (MTL) distribution, introduced by Singh, Tyagi, Singh, and Tyagi (2025). The MTL distribution is a flexible single-parameter lifetime model obtained via the transformation $Y = X / (1 - X)$ where $X$ follows the classical Topp-Leone distribution.

The probability density function (PDF) and cumulative distribution function (CDF) of the MTL distribution with shape parameter $\alpha > 0$ are given by:

$$f(y; \alpha) = 2 \alpha (1 + y)^{-(2\alpha + 1)} (2y + y^2)^{\alpha - 1}, \quad y > 0$$

$$F(y; \alpha) = \left( 1 - \frac{1}{(1 + y)^2} \right)^\alpha, \quad y > 0$$

## Core Distribution Functions

The package provides standard distribution functions: `dmtl`, `pmtl`, `qmtl`, `rmtl`, `smtl`, and `hmtl`.

```{r core_funcs}
# Density and CDF
dmtl(x = 1.0, alpha = 1.5)
pmtl(q = 1.0, alpha = 1.5)

# Quantile function and Random Generation
qmtl(p = c(0.25, 0.50, 0.75), alpha = 1.5)

set.seed(123)
sample_data <- rmtl(n = 10, alpha = 1.5)
sample_data

# Survival and Hazard Rate Functions
smtl(x = 1.0, alpha = 1.5)
hmtl(x = 1.0, alpha = 1.5)
```

## Statistical Properties

The package includes helper functions to derive theoretical statistical properties:

```{r properties}
# Mode and Mean
mode_mtl(alpha = 2.5)
mean_mtl(alpha = 1.5)

# Quantiles summary (Median, Skewness, Kurtosis)
quantiles_mtl(alpha = 1.5)

# Mean Deviations about mean and median
meandev_mtl(alpha = 1.5)

# Stress-Strength Reliability P(Y2 < Y1)
ssr_mtl(alpha1 = 2, alpha2 = 3)
```

## Classical Estimation Methods

The parameter $\alpha$ can be estimated using five classical point estimation procedures: Maximum Likelihood (MLE), Ordinary Least Squares (OLS), Weighted Least Squares (WLS), Cramér-von Mises (CVM), and Maximum Product of Spacings (MPS).

```{r classical_fit}
set.seed(42)
sim_data <- rmtl(n = 50, alpha = 2.0)

# Unified estimation wrapper
fit_results <- fit_mtl(x = sim_data, method = "all")
fit_results
```

## Bayesian Estimation

Bayesian estimation is supported under both informative (Gamma) and non-informative priors with symmetric (SELF) and asymmetric (ELF, PLF, GELF) loss functions, alongside Chen-Shao Highest Posterior Density (HPD) intervals.

```{r bayes_fit}
# Non-informative prior Bayesian estimation
bayes_res <- bayes_mtl(x = sim_data, prior = "noninformative", loss = "all")
bayes_res$estimates
bayes_res$hpd
```

## Censoring Schemes

The package supports sample generation and parameter estimation under various censoring schemes, including Random Right Censoring, Type-I, Type-II, and Progressive Type-II Censoring.

```{r censoring}
# Progressive Type-II Censoring example
R_scheme <- c(2, 0, 1, 0, 2)
prog_sample <- rcensor_mtl(n = 10, alpha = 2.0, scheme = "progressive2", m = 5, R = R_scheme)

mle_censor_mtl(x = prog_sample$x, scheme = "progressive2", R = R_scheme)
```

## Real Datasets

The package includes three benchmark real datasets analyzed in the research paper:

1. `dataset_air`: Air conditioning failure times of Boeing 720 jet airplanes.
2. `dataset_covid_india`: Daily new COVID-19 cases in India.
3. `dataset_covid_france`: Daily new COVID-19 cases in France.

```{r datasets}
data(dataset_air)
mle_mtl(dataset_air)
```

## References

- Singh, B., Tyagi, S., Singh, R. P., and Tyagi, A. (2025). Modified Topp-Leone Distribution: Properties, Classical and Bayesian Estimation with Application to COVID-19 and Reliability Data. *Thailand Statistician*, 23(1), 72-96.
