The Gofpt2 package provides a generalized goodness-of-fit test based on spacings for general progressive Type-II censored data. The test statistic is based on the methodology proposed by Qin et al. (2022), extending the foundational work of Balakrishnan et al. (2003).
In life testing and reliability studies, failure data are often progressively Type-II censored. Under general progressive Type-II censoring: - \(n\) total units are placed on test. - The first \(r\) failures are not observed. - Starting from the \((r+1)\)-th failure, \(m - r\) failure times are recorded: \(X_{r+1:m:n} < X_{r+2:m:n} < \dots < X_{m:m:n}\). - At each observed failure time \(X_{r+j:m:n}\), \(R_{r+j}\) surviving units are randomly withdrawn from the test.
The Gofpt2 package allows users to test whether observed
censored failure times follow any hypothesized continuous distribution
by providing custom probability density (pdf_func),
cumulative distribution (cdf_func), and survival functions
(survival_func).
We illustrate the basic workflow using the insulating fluid failure dataset from Example 6.1 of Qin et al. (2022).
In this experiment: - Total sample size: \(n = 19\) - Total failures: \(m = 11\) - Initial unobserved failures: \(r = 2\) - Removals scheme: \(R = (0, 0, 2, 0, 0, 2, 0, 0, 4)\) for the 9 observed failure times.
library(Gofpt2)
# Define censoring scheme
scheme <- list(
n = 19,
m = 11,
r = 2,
R = c(0, 0, 2, 0, 0, 2, 0, 0, 4)
)
# Observed breakdown times (length m - r = 9)
obs_data <- c(3.16, 4.15, 4.67, 7.35, 8.01, 8.27, 32.52, 33.91, 36.71)
# Perform goodness-of-fit test against Exponential distribution using Normal Approximation
test_res <- gof_test_censored(
data = obs_data,
censoring_scheme = scheme,
method = "normal"
)
# Display results
print(test_res)
summary(test_res)The test statistic \(T = 0.35463\) lies well within the critical bounds \([0.41463, 0.86290]\) (with \(p\)-value \(\approx 0.4095\)), indicating no evidence to reject the exponential null hypothesis.
The package supports both analytical normal approximation (Theorem 4.1, Qin et al. 2022) and Monte Carlo simulation.
# Test using Monte Carlo Simulation (10,000 replicates)
test_sim <- gof_test_censored(
data = obs_data,
censoring_scheme = scheme,
method = "simulation",
n_sim = 10000
)
# Print comparison
cat("Normal Approx p-value:", test_res$p_value, "\n")
cat("Simulation p-value :", test_sim$p_value, "\n")Users can test data against any custom distribution by providing its CDF and Survival function.
# Define custom Weibull distribution parameters (shape = 1.5, scale = 10)
weibull_cdf <- function(x, shape, scale) pweibull(x, shape = shape, scale = scale)
weibull_surv <- function(x, shape, scale) 1 - pweibull(x, shape = shape, scale = scale)
# Generate synthetic data from Weibull distribution
set.seed(42)
weibull_data <- generate_progressive_censored(
censoring_scheme = scheme,
cdf_func = weibull_cdf,
parameters = list(shape = 1.5, scale = 10)
)
# Test whether data fits the hypothesized Weibull distribution
fit_weibull <- gof_test_censored(
data = weibull_data,
censoring_scheme = scheme,
cdf_func = weibull_cdf,
survival_func = weibull_surv,
parameters = list(shape = 1.5, scale = 10),
method = "normal"
)
print(fit_weibull)The plot() method displays the null distribution of the
test statistic \(T\) with vertical
indicators for the observed test statistic and critical bounds: