| Title: | Goodness-of-Fit Tests for Type-II Censored Samples via the Malmquist Transformation |
|---|---|
| Description: | Goodness-of-fit tests for an arbitrary user-specified continuous distribution under Type-II right- or left-censoring. Implements the transformation-based method of Lin, Huang and Balakrishnan (2008) <doi:10.1109/TR.2008.2005860>, which uses a property of order statistics due to Malmquist (1950) to convert an r-out-of-n Type-II censored uniform sample into a complete sample of size r, alongside the earlier transformation of Michael and Schucany (1979) <doi:10.1080/00401706.1979.10489813>. Also implements the direct (untransformed) censored-sample statistics of Barr and Davidson (1973) <doi:10.1080/00401706.1973.10489108> and Pettitt and Stephens (1976) <doi:10.1093/biomet/63.2.291>, and the modified-statistic maximum-likelihood procedure of Chen and Balakrishnan (1995) for testing composite hypotheses. General background on empirical-distribution-function goodness-of-fit methods follows D'Agostino and Stephens (1986, ISBN:982-0-8247-7487-5). |
| Authors: | Shikhar Tyagi [aut, cre] (ORCID: <https://orcid.org/0000-0003-1606-0844>), Arvind Pandey [aut], Bhupendra Singh [aut], Vrijesh Tripathi [aut] |
| Maintainer: | Shikhar Tyagi <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-09-29 10:32:12 UTC |
| Source: | https://github.com/cran/gofmalm |
Estimates distribution parameters under Type-II right- or left-censoring.
fit_mle( data, n, pdf, cdf, sf = NULL, params, censoring = c("right", "left"), optim_control = list() )fit_mle( data, n, pdf, cdf, sf = NULL, params, censoring = c("right", "left"), optim_control = list() )
data |
Numeric vector of length |
n |
Total sample size ( |
pdf |
Probability density function. |
cdf |
Cumulative distribution function. |
sf |
Survival function. If |
params |
Named list or vector of starting parameter values. |
censoring |
Type of censoring: |
optim_control |
Optional control list passed to |
A list containing par (estimated parameters), value (negative log-likelihood),
convergence status code, and message.
data_exp <- c(0.1, 0.2, 0.3, 0.4, 0.7, 1.0, 1.4) fit <- fit_mle( data = data_exp, n = 20, pdf = function(x, p) dexp(x, rate = p$rate), cdf = function(x, p) pexp(x, rate = p$rate), params = list(rate = 0.1), censoring = "right" ) fit$pardata_exp <- c(0.1, 0.2, 0.3, 0.4, 0.7, 1.0, 1.4) fit <- fit_mle( data = data_exp, n = 20, pdf = function(x, p) dexp(x, rate = p$rate), cdf = function(x, p) pexp(x, rate = p$rate), params = list(rate = 0.1), censoring = "right" ) fit$par
Performs goodness-of-fit tests for arbitrary user-specified continuous parametric distributions under Type-II right- or left-censoring using the Malmquist and Michael-Schucany transformations.
gof_censored( data, n, pdf, cdf, sf = NULL, params = NULL, estimate = TRUE, censoring = c("right", "left"), transform = c("both", "malmquist", "ms"), statistics = c("all", "direct7", "complete_ad", "composite_mle", "direct_censored"), pvalue_method = c("auto", "distribution_free", "parametric_bootstrap"), nsim = 2000, seed = NULL, optim_control = list() )gof_censored( data, n, pdf, cdf, sf = NULL, params = NULL, estimate = TRUE, censoring = c("right", "left"), transform = c("both", "malmquist", "ms"), statistics = c("all", "direct7", "complete_ad", "composite_mle", "direct_censored"), pvalue_method = c("auto", "distribution_free", "parametric_bootstrap"), nsim = 2000, seed = NULL, optim_control = list() )
data |
Numeric vector of observed order statistics, length r. |
n |
Total sample size (n >= length(data)). |
pdf |
Probability density function |
cdf |
Cumulative distribution function |
sf |
Survival function |
params |
Named list/vector of fixed parameter values (if |
estimate |
Logical; |
censoring |
Type of censoring: |
transform |
Transformations to compute: |
statistics |
Subset of statistics to compute: |
pvalue_method |
Method for p-values: |
nsim |
Number of Monte Carlo or bootstrap simulation replicates. |
seed |
Optional random seed. |
optim_control |
Optional control list passed to |
An S3 object of class "gofmalm".
# Simple hypothesis test on Uniform(0,1) with r=5, n=10 data_unif <- c(0.03, 0.06, 0.10, 0.11, 0.13) res <- gof_censored( data = data_unif, n = 10, pdf = dunif, cdf = punif, estimate = FALSE, pvalue_method = "distribution_free", nsim = 500, seed = 123 ) print(res)# Simple hypothesis test on Uniform(0,1) with r=5, n=10 data_unif <- c(0.03, 0.06, 0.10, 0.11, 0.13) res <- gof_censored( data = data_unif, n = 10, pdf = dunif, cdf = punif, estimate = FALSE, pvalue_method = "distribution_free", nsim = 500, seed = 123 ) print(res)
Obtains p-values for EDF goodness-of-fit statistics via Monte Carlo simulation from Uniform(0,1) order statistics.
pvalue_distribution_free( u_obs, n, r, censoring = c("right", "left"), nsim = 2000, seed = NULL )pvalue_distribution_free( u_obs, n, r, censoring = c("right", "left"), nsim = 2000, seed = NULL )
u_obs |
Observed order statistics u_1:n < ... < u_r:n. |
n |
Total sample size. |
r |
Number of observed failures. |
censoring |
Type of censoring: |
nsim |
Number of Monte Carlo simulation replicates (default 2000). |
seed |
Optional random seed. |
Named numeric vector of empirical p-values for each statistic.
Obtains p-values for composite hypothesis tests where parameters are estimated from data.
pvalue_parametric_bootstrap( data, n, pdf, cdf, sf = NULL, params_hat, censoring = c("right", "left"), transform = c("both", "malmquist", "ms"), nsim = 2000, seed = NULL, optim_control = list() )pvalue_parametric_bootstrap( data, n, pdf, cdf, sf = NULL, params_hat, censoring = c("right", "left"), transform = c("both", "malmquist", "ms"), nsim = 2000, seed = NULL, optim_control = list() )
data |
Observed data vector of length r. |
n |
Total sample size. |
pdf |
Density function. |
cdf |
Distribution function. |
sf |
Survival function. |
params_hat |
Estimated parameter list from observed data. |
censoring |
Type of censoring. |
transform |
Transformation method ( |
nsim |
Number of bootstrap replicates (default 2000). |
seed |
Optional random seed. |
optim_control |
Optional control list passed to |
A list containing empirical p-values and number of valid replicates.
Evaluates goodness-of-fit under unknown parameters using MLE estimation, transformation to complete sample, normal residual standardization, and modified CvM/AD statistics.
stat_composite_mle( data, n, pdf, cdf, sf = NULL, params, censoring = c("right", "left"), transform = c("malmquist", "ms"), optim_control = list() )stat_composite_mle( data, n, pdf, cdf, sf = NULL, params, censoring = c("right", "left"), transform = c("malmquist", "ms"), optim_control = list() )
data |
Numeric vector of observed order statistics. |
n |
Total sample size (n >= length(data)). |
pdf |
Probability density function taking |
cdf |
Cumulative distribution function taking |
sf |
Survival function taking |
params |
Named list/vector of starting parameter values for MLE. |
censoring |
Type of censoring: |
transform |
Transformation method: |
optim_control |
Optional control list passed to |
A list containing:
stat_W2 |
Modified Cramér-von Mises statistic (_mW2 or _lW2). |
stat_A2 |
Modified Anderson-Darling statistic (_mA2 or _lA2). |
W2 |
Raw Cramér-von Mises statistic on standardized residuals. |
A2 |
Raw Anderson-Darling statistic on standardized residuals. |
theta_hat |
Estimated parameter values. |
convergence |
Optimization convergence code. |
data_exp <- c(0.1, 0.2, 0.3, 0.4, 0.7, 1.0, 1.4) stat_composite_mle( data = data_exp, n = 20, pdf = function(x, p) dexp(x, rate = p$rate), cdf = function(x, p) pexp(x, rate = p$rate), params = list(rate = 0.1), censoring = "right", transform = "malmquist" )data_exp <- c(0.1, 0.2, 0.3, 0.4, 0.7, 1.0, 1.4) stat_composite_mle( data = data_exp, n = 20, pdf = function(x, p) dexp(x, rate = p$rate), cdf = function(x, p) pexp(x, rate = p$rate), params = list(rate = 0.1), censoring = "right", transform = "malmquist" )
Computes the untransformed direct censored Cramér-von Mises and Anderson-Darling statistics.
stat_direct_censored(u_cens, n)stat_direct_censored(u_cens, n)
u_cens |
Numeric vector of order statistics u_1:n < ... < u_r:n in (0, 1). |
n |
Total sample size (n >= length(u_cens)). |
Named numeric vector containing W2_2_rn and A2_2_rn.
u <- c(0.03, 0.06, 0.10, 0.11, 0.13) stat_direct_censored(u, n = 10)u <- c(0.03, 0.06, 0.10, 0.11, 0.13) stat_direct_censored(u, n = 10)
Computes the nine EDF test statistics described in Lin, Huang & Balakrishnan (2008).
stat_edf_censored(u_cens, n, u_ms = NULL, u_malmquist = NULL)stat_edf_censored(u_cens, n, u_ms = NULL, u_malmquist = NULL)
u_cens |
Numeric vector of order statistics u_1:n < ... < u_r:n in (0, 1). |
n |
Total sample size (n >= length(u_cens)). |
u_ms |
Optional pre-computed Michael & Schucany transformed sample. |
u_malmquist |
Optional pre-computed Malmquist transformed sample. |
A named numeric vector of 9 statistics: D_rn, G_rn, T_rn,
W2_star_rn, W2_rn, A2_rn, U2_rn, TA2_r, and star_TA2_r.
u <- c(0.03, 0.06, 0.10, 0.11, 0.13) stat_edf_censored(u, n = 10)u <- c(0.03, 0.06, 0.10, 0.11, 0.13) stat_edf_censored(u, n = 10)
Converts an r-out-of-n Type-II right- or left-censored uniform sample into an independent complete Uniform(0,1) sample of size r (Lin, Huang & Balakrishnan, 2008).
transform_malmquist(u_cens, n, censoring = c("right", "left"))transform_malmquist(u_cens, n, censoring = c("right", "left"))
u_cens |
Numeric vector of length r containing PIT-transformed order statistics. |
n |
Total sample size (n >= length(u_cens)). |
censoring |
Type of censoring: |
A list containing:
W |
Sorted complete sample W_1:r < ... < W_r:r of size r. |
V |
Vector of intermediate Beta-distributed random variables V_n, ..., V_{n-r+1}. |
u <- c(0.03, 0.06, 0.10, 0.11, 0.13) transform_malmquist(u, n = 10, censoring = "right")u <- c(0.03, 0.06, 0.10, 0.11, 0.13) transform_malmquist(u, n = 10, censoring = "right")
Transforms an r-out-of-n Type-II right-censored uniform sample into a complete sample of size r.
transform_ms(u_cens, n)transform_ms(u_cens, n)
u_cens |
Numeric vector of order statistics u_1:n < ... < u_r:n in (0, 1). |
n |
Total sample size (n >= length(u_cens)). |
Numeric vector of length r representing the transformed complete sample Z_1:r < ... < Z_r:r.
u <- c(0.03, 0.06, 0.10, 0.11, 0.13) transform_ms(u, n = 10)u <- c(0.03, 0.06, 0.10, 0.11, 0.13) transform_ms(u, n = 10)