| Title: | Kolmogorov-Smirnov Test for Dependently Double-Truncated Durations |
|---|---|
| Description: | Performs the Kolmogorov-Smirnov-type goodness-of-fit test for exponential duration models under independent or dependently double-truncated sampling scheme using Farlie-Gumbel-Morgenstern ('FGM') copulas, as proposed by Toparkus and Weissbach (2026) <doi:10.1007/s10985-026-09722-0>. Provides functions for profile maximum likelihood estimation / score equation solving, computation of the two-dimensional Kolmogorov-Smirnov test statistic over the double-truncation parallelogram, simulation of the asymptotic Gaussian process limit distribution for critical values and p-value calculation, and synthetic dataset generation. |
| 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: | GPL (>= 3) |
| Version: | 0.1.0 |
| Built: | 2026-10-11 12:30:54 UTC |
| Source: | https://github.com/cran/DepDoubleTruncKS |
Computes the observation probability alpha_theta and its gradient vector with respect to (theta, vtheta) for an exponentially distributed lifespan and uniformly distributed age under Farlie-Gumbel-Morgenstern (FGM) copula dependence.
calc_alpha_fgm(theta, vtheta, s, G)calc_alpha_fgm(theta, vtheta, s, G)
theta |
Rate parameter of the exponential lifespan distribution (theta > 0). |
vtheta |
FGM copula dependence parameter (vtheta in [-1, 1]). |
s |
Duration of the study (s > 0). |
G |
Upper bound of the foundation age distribution (G > 0). |
A list containing:
alpha |
Observation probability alpha_theta_vtheta. |
dalpha_theta |
Partial derivative of alpha with respect to theta. |
dalpha_vtheta |
Partial derivative of alpha with respect to vtheta. |
grad |
Gradient vector c(dalpha_theta, dalpha_vtheta). |
calc_alpha_fgm(theta = 0.082, vtheta = 0.103, s = 3, G = 24)calc_alpha_fgm(theta = 0.082, vtheta = 0.103, s = 3, G = 24)
Computes the observation probability alpha_theta and its derivative with respect to theta for an exponentially distributed lifespan and uniformly distributed age at study start under independent double truncation.
calc_alpha_ind(theta, s, G)calc_alpha_ind(theta, s, G)
theta |
Rate parameter of the exponential lifespan distribution (theta > 0). |
s |
Duration of the study (s > 0). |
G |
Upper bound of the foundation age distribution (G > 0). |
A list containing:
alpha |
Observation probability alpha_theta. |
dalpha |
Derivative of alpha_theta with respect to theta. |
calc_alpha_ind(theta = 0.082, s = 3, G = 24)calc_alpha_ind(theta = 0.082, s = 3, G = 24)
Implements Algorithm 2 from Toparkus & Weissbach (2026) to compute critical values (90 on a 2D grid over the double-truncation region D.
calc_critical_values( ks_stat, theta, vtheta = 0, s, G, model = c("fgm", "ind"), grid_dim = 25, n_sim = 500 )calc_critical_values( ks_stat, theta, vtheta = 0, s, G, model = c("fgm", "ind"), grid_dim = 25, n_sim = 500 )
ks_stat |
Observed Kolmogorov-Smirnov test statistic value. |
theta |
Rate parameter theta. |
vtheta |
Dependence parameter vtheta (0 for model="ind"). |
s |
Duration of the study (s > 0). |
G |
Upper bound of foundation age (G > 0). |
model |
Model type: '"fgm"' or '"ind"'. |
grid_dim |
Discretization grid dimension (default 25 x 25 grid). |
n_sim |
Number of Monte Carlo simulation repetitions (default 500). |
A list containing:
crit_90 |
Critical value at 10 percent significance level (alpha = 0.10). |
crit_95 |
Critical value at 5 percent significance level (alpha = 0.05). |
crit_99 |
Critical value at 1 percent significance level (alpha = 0.01). |
p_value |
Empirical p-value. |
sim_suprema |
Vector of simulated suprema. |
set.seed(123) res <- calc_critical_values(ks_stat = 1.2, theta = 0.08, vtheta = 0, s = 3, G = 24, model = "ind", grid_dim = 15, n_sim = 100) res$crit_95set.seed(123) res <- calc_critical_values(ks_stat = 1.2, theta = 0.08, vtheta = 0, s = 3, G = 24, model = "ind", grid_dim = 15, n_sim = 100) res$crit_95
Computes the expectation E_theta(g_x,t,D) = P_theta((X,T) in [0,x] x [0,t] intersect D) and its derivatives with respect to theta and vtheta under the FGM copula.
calc_E_fgm(x, t, s, G, theta, vtheta)calc_E_fgm(x, t, s, G, theta, vtheta)
x |
Vector of duration evaluation points (x > 0). |
t |
Vector of truncation evaluation points (0 <= t <= G). |
s |
Duration of the study. |
G |
Upper bound of foundation age. |
theta |
Exponential rate parameter. |
vtheta |
FGM copula dependence parameter. |
A list containing:
val |
Value of E_theta(g_x,t,D). |
dval_theta |
Partial derivative wrt theta. |
dval_vtheta |
Partial derivative wrt vtheta. |
Computes the expectation E_theta(g_x,t,D) = P_theta((X,T) in [0,x] x [0,t] intersect D) and its derivative with respect to theta for independent truncation.
calc_E_ind(x, t, s, G, theta)calc_E_ind(x, t, s, G, theta)
x |
Vector of duration evaluation points (x > 0). |
t |
Vector of truncation evaluation points (0 <= t <= G). |
s |
Duration of the study. |
G |
Upper bound of foundation age. |
theta |
Exponential rate parameter. |
A list containing:
val |
Value of E_theta(g_x,t,D). |
dval |
Derivative wrt theta. |
Implements Algorithm 1 from Toparkus & Weissbach (2026) to compute the 2D Kolmogorov-Smirnov test statistic comparing the empirical CDF and the parametric CDF over the double-truncation region D.
calc_ks_stat(x, t, s, G, theta, vtheta = 0, model = c("fgm", "ind"))calc_ks_stat(x, t, s, G, theta, vtheta = 0, model = c("fgm", "ind"))
x |
Vector of observed durations (x > 0). |
t |
Vector of observed ages at study start (0 <= t <= G). |
s |
Duration of the study (s > 0). |
G |
Upper bound of foundation age (G > 0). |
theta |
Estimated rate parameter theta. |
vtheta |
Estimated dependence parameter vtheta (0 for model="ind"). |
model |
Model type: '"fgm"' or '"ind"'. |
A list containing:
ks_stat |
Composite KS test statistic value. |
max_diff |
Maximum absolute difference between empirical and parametric CDFs. |
delta_plus |
Maximum positive difference delta_plus. |
delta_minus |
Maximum negative difference delta_minus. |
n_eval_points |
Total number of evaluated candidate points. |
set.seed(123) dat <- sim_double_trunc(n = 300, theta = 0.08, G = 24, s = 3, model = "ind") fit <- fit_double_trunc(dat$x, dat$t, s = 3, G = 24, model = "ind") ks_res <- calc_ks_stat(dat$x, dat$t, s = 3, G = 24, theta = fit$theta, model = "ind") ks_res$ks_statset.seed(123) dat <- sim_double_trunc(n = 300, theta = 0.08, G = 24, s = 3, model = "ind") fit <- fit_double_trunc(dat$x, dat$t, s = 3, G = 24, model = "ind") ks_res <- calc_ks_stat(dat$x, dat$t, s = 3, G = 24, theta = fit$theta, model = "ind") ks_res$ks_stat
A synthetic dataset containing 500 observed enterprise durations and age at study start under double truncation, constructed to mimic German enterprise lifespan data described in Toparkus & Weissbach (2026).
enterprise_dataenterprise_data
A data frame with 500 rows and 2 variables:
Observed enterprise duration (lifespan in years).
Observed age at study start (truncation age in years, between 0 and G=24).
Simulated based on parameters from Toparkus & Weissbach (2026).
Toparkus, A.-M. and Weissbach, R. (2026). Kolmogorov-Smirnov-type test for dependently double-truncated durations: A copula approach. *Lifetime Data Analysis*, 32, 41. doi:10.1007/s10985-026-09722-0.
data(enterprise_data) head(enterprise_data)data(enterprise_data) head(enterprise_data)
Estimates the parameters of an exponential duration model under independent or dependently double-truncated sampling using Z-estimation / maximum likelihood.
fit_double_trunc(x, t, s, G, model = c("fgm", "ind"))fit_double_trunc(x, t, s, G, model = c("fgm", "ind"))
x |
Vector of observed durations (x > 0). |
t |
Vector of observed ages at study start (0 <= t <= G). |
s |
Duration of the study (s > 0). |
G |
Upper bound of foundation age (G > 0). |
model |
Model specification: '"fgm"' for FGM copula dependent truncation or '"ind"' for independent truncation. |
A list of class '"fit_double_trunc"' containing:
theta |
Estimated exponential rate parameter theta. |
vtheta |
Estimated FGM dependence parameter vtheta (if model="fgm"). |
alpha |
Estimated observation probability alpha. |
model |
Model type ("ind" or "fgm"). |
s |
Study length. |
G |
Maximum truncation age. |
mn |
Number of observed units. |
n_hat |
Estimated latent sample size mn / alpha. |
set.seed(123) sim_dat <- sim_double_trunc(n = 500, theta = 0.08, G = 24, s = 3, model = "ind") fit <- fit_double_trunc(sim_dat$x, sim_dat$t, s = 3, G = 24, model = "ind") fit$thetaset.seed(123) sim_dat <- sim_double_trunc(n = 500, theta = 0.08, G = 24, s = 3, model = "ind") fit <- fit_double_trunc(sim_dat$x, sim_dat$t, s = 3, G = 24, model = "ind") fit$theta
Performs the 2D Kolmogorov-Smirnov goodness-of-fit test for exponential lifespan distributions under independent or Farlie-Gumbel-Morgenstern (FGM) copula dependent double truncation, as proposed by Toparkus & Weissbach (2026).
ks_dep_trunc(x, t, s, G, model = c("fgm", "ind"), grid_dim = 25, n_sim = 500)ks_dep_trunc(x, t, s, G, model = c("fgm", "ind"), grid_dim = 25, n_sim = 500)
x |
Vector of observed durations (x > 0). |
t |
Vector of observed ages at study start (0 <= t <= G). |
s |
Duration of the study (s > 0). |
G |
Upper bound of foundation age (G > 0). |
model |
Model specification: '"fgm"' for FGM copula dependent truncation (default) or '"ind"' for independent truncation. |
grid_dim |
Discretization grid dimension for critical value calculation (default 25). |
n_sim |
Number of Monte Carlo simulation repetitions for critical value calculation (default 500). |
An object of class "ks_dep_trunc" containing:
ks_stat |
Composite KS test statistic value. |
fit |
Parameter estimates object from fit_double_trunc. |
crit_values |
Critical values at 90, 95, 99 percent significance levels. |
p_value |
Empirical p-value of the test. |
decision |
Statistical decision at alpha = 0.05 ("Reject H0" or "Fail to reject H0"). |
x |
Observed durations. |
t |
Observed truncation ages. |
s |
Study length. |
G |
Maximum truncation age. |
model |
Model type. |
Toparkus, A.-M. and Weissbach, R. (2026). Kolmogorov-Smirnov-type test for dependently double-truncated durations: A copula approach. *Lifetime Data Analysis*, 32, 41. doi:10.1007/s10985-026-09722-0.
set.seed(42) dat <- sim_double_trunc(n = 300, theta = 0.082, G = 24, s = 3, model = "ind") res <- ks_dep_trunc(dat$x, dat$t, s = 3, G = 24, model = "ind", grid_dim = 15, n_sim = 100) print(res)set.seed(42) dat <- sim_double_trunc(n = 300, theta = 0.082, G = 24, s = 3, model = "ind") res <- ks_dep_trunc(dat$x, dat$t, s = 3, G = 24, model = "ind", grid_dim = 15, n_sim = 100) print(res)
Scatter plot of observed durations and truncation ages inside the truncation parallelogram D, along with theoretical boundaries.
## S3 method for class 'ks_dep_trunc' plot(x, ...)## S3 method for class 'ks_dep_trunc' plot(x, ...)
x |
Object of class '"ks_dep_trunc"'. |
... |
Additional graphical parameters. |
No return value, called for side effects.
Print S3 Method for ks_dep_trunc
## S3 method for class 'ks_dep_trunc' print(x, ...)## S3 method for class 'ks_dep_trunc' print(x, ...)
x |
Object of class '"ks_dep_trunc"'. |
... |
Additional arguments passed to print. |
Invisibly returns the input object x.
Generates double-truncated duration data (X, T) under independent or Farlie-Gumbel-Morgenstern (FGM) copula dependence according to Algorithms 4 & 5 from Toparkus & Weissbach (2026).
sim_double_trunc(n, theta, G, s, vtheta = 0, model = c("fgm", "ind"))sim_double_trunc(n, theta, G, s, vtheta = 0, model = c("fgm", "ind"))
n |
Latent sample size (n > 0). |
theta |
Rate parameter of the exponential lifespan distribution (theta > 0). |
G |
Upper bound of the foundation age distribution (G > 0). |
s |
Duration of the study (s > 0). |
vtheta |
FGM copula dependence parameter in [-1, 1] (0 for model="ind"). |
model |
Model specification: '"fgm"' or '"ind"'. |
A list containing:
x |
Vector of observed durations inside parallelogram D. |
t |
Vector of observed truncation ages inside parallelogram D. |
mn |
Number of observed units mn. |
n |
Latent sample size n. |
alpha_true |
True observation probability. |
model |
Model type. |
set.seed(123) dat <- sim_double_trunc(n = 1000, theta = 0.082, G = 24, s = 3, model = "ind") head(dat$x) dat$mnset.seed(123) dat <- sim_double_trunc(n = 1000, theta = 0.082, G = 24, s = 3, model = "ind") head(dat$x) dat$mn
Summary S3 Method for ks_dep_trunc
## S3 method for class 'ks_dep_trunc' summary(object, ...)## S3 method for class 'ks_dep_trunc' summary(object, ...)
object |
Object of class '"ks_dep_trunc"'. |
... |
Additional arguments passed to summary. |
Invisibly returns the input object object.