## ----setup, include = FALSE---------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(gofPHCS)

## ----complete-data------------------------------------------------------------
set.seed(123)
x_complete <- rexp(25, rate = 0.5)

# Create censored data container
cd_comp <- cens_data(x = x_complete, scheme = "complete")

# Define target exponential distribution
dist_exp <- make_distribution(
  cdf = function(x, rate) pexp(x, rate = rate),
  params = c(rate = 0.5),
  support = c(0, Inf)
)

# Perform KS test
test_ks <- gof_test(cd_comp, distribution = dist_exp, statistic = "KS", p.method = "montecarlo", nsim = 499)
print(test_ks)

## ----prog2-data---------------------------------------------------------------
# Example data: insulating fluid breakdown times (n = 19, m = 18)
x_prog <- c(0.19, 0.78, 0.96, 1.31, 2.78, 3.16, 4.15, 4.67, 4.85, 6.50,
            7.35, 8.01, 8.27, 12.06, 31.75, 32.52, 33.91, 36.71)
R_plan <- c(rep(0, 17), 1)

cd_prog <- cens_data(x = x_prog, scheme = "progtypeII", n = 19, R = R_plan)

# Test exponentiality using Spacings Test statistic T (Balakrishnan et al. 2002b)
test_T <- gof_test(cd_prog, distribution = dist_exp, statistic = "T", p.method = "asymptotic")
print(test_T)

## ----hybrid1-data-------------------------------------------------------------
set.seed(456)
x_hyb1 <- c(0.25, 0.48, 0.81, 1.05, 1.32)
cd_hyb1 <- cens_data(x = x_hyb1, scheme = "hybridI", n = 10, r = 7, T0 = 1.5)

test_ksi <- gof_test(cd_hyb1, distribution = dist_exp, statistic = "KSI", p.method = "montecarlo", nsim = 499)
print(test_ksi)

## ----hybrid2-data-------------------------------------------------------------
set.seed(789)
x_hyb2 <- c(0.31, 0.55, 0.92, 1.15, 1.60, 2.10)
cd_hyb2 <- cens_data(x = x_hyb2, scheme = "hybridII", n = 10, r = 5, T0 = 1.0)

test_ksii <- gof_test(cd_hyb2, distribution = dist_exp, statistic = "KSII", p.method = "montecarlo", nsim = 499)
print(test_ksii)

