Package {DepDoubleTruncKS}


Type: Package
Title: Kolmogorov-Smirnov Test for Dependently Double-Truncated Durations
Version: 0.1.0
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.
License: GPL (≥ 3)
Depends: R (≥ 3.5.0)
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.3.3
Imports: stats, graphics
Suggests: testthat (≥ 3.0.0), knitr, rmarkdown
VignetteBuilder: knitr
URL: https://doi.org/10.1007/s10985-026-09722-0
NeedsCompilation: no
Packaged: 2026-07-31 04:03:55 UTC; shikhar tyagi
Author: Shikhar Tyagi ORCID iD [aut, cre], Arvind Pandey [aut], Bhupendra Singh [aut], Vrijesh Tripathi [aut]
Maintainer: Shikhar Tyagi <shikhar1093tyagi@gmail.com>
Repository: CRAN
Date/Publication: 2026-08-07 20:10:03 UTC

Region Integral E_theta(g_x,t,D) for FGM-Dependent Model

Description

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.

Usage

calc_E_fgm(x, t, s, G, theta, vtheta)

Arguments

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.

Value

A list containing:

val

Value of E_theta(g_x,t,D).

dval_theta

Partial derivative wrt theta.

dval_vtheta

Partial derivative wrt vtheta.


Region Integral E_theta(g_x,t,D) for Independent Model

Description

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.

Usage

calc_E_ind(x, t, s, G, theta)

Arguments

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.

Value

A list containing:

val

Value of E_theta(g_x,t,D).

dval

Derivative wrt theta.


Calculate Observation Probability for FGM-Dependent Double Truncation

Description

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.

Usage

calc_alpha_fgm(theta, vtheta, s, G)

Arguments

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).

Value

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).

Examples

calc_alpha_fgm(theta = 0.082, vtheta = 0.103, s = 3, G = 24)

Calculate Observation Probability for Independent Double Truncation

Description

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.

Usage

calc_alpha_ind(theta, s, G)

Arguments

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).

Value

A list containing:

alpha

Observation probability alpha_theta.

dalpha

Derivative of alpha_theta with respect to theta.

Examples

calc_alpha_ind(theta = 0.082, s = 3, G = 24)

Calculate Asymptotic Critical Values and P-Value

Description

Implements Algorithm 2 from Toparkus & Weissbach (2026) to compute critical values (90 on a 2D grid over the double-truncation region D.

Usage

calc_critical_values(
  ks_stat,
  theta,
  vtheta = 0,
  s,
  G,
  model = c("fgm", "ind"),
  grid_dim = 25,
  n_sim = 500
)

Arguments

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).

Value

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.

Examples

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_95

Compute 2D Kolmogorov-Smirnov Test Statistic for Truncated Data

Description

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.

Usage

calc_ks_stat(x, t, s, G, theta, vtheta = 0, model = c("fgm", "ind"))

Arguments

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"'.

Value

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.

Examples

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_stat

Synthetic Enterprise Lifespans under Double Truncation

Description

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).

Usage

enterprise_data

Format

A data frame with 500 rows and 2 variables:

x

Observed enterprise duration (lifespan in years).

t

Observed age at study start (truncation age in years, between 0 and G=24).

Source

Simulated based on parameters from Toparkus & Weissbach (2026).

References

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.

Examples

data(enterprise_data)
head(enterprise_data)

Fit Double-Truncated Exponential Duration Model

Description

Estimates the parameters of an exponential duration model under independent or dependently double-truncated sampling using Z-estimation / maximum likelihood.

Usage

fit_double_trunc(x, t, s, G, model = c("fgm", "ind"))

Arguments

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.

Value

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.

Examples

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$theta

Kolmogorov-Smirnov-type Test for Dependently Double-Truncated Data

Description

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).

Usage

ks_dep_trunc(x, t, s, G, model = c("fgm", "ind"), grid_dim = 25, n_sim = 500)

Arguments

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).

Value

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.

References

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.

Examples

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)

Plot S3 Method for ks_dep_trunc

Description

Scatter plot of observed durations and truncation ages inside the truncation parallelogram D, along with theoretical boundaries.

Usage

## S3 method for class 'ks_dep_trunc'
plot(x, ...)

Arguments

x

Object of class '"ks_dep_trunc"'.

...

Additional graphical parameters.

Value

No return value, called for side effects.


Print S3 Method for ks_dep_trunc

Description

Print S3 Method for ks_dep_trunc

Usage

## S3 method for class 'ks_dep_trunc'
print(x, ...)

Arguments

x

Object of class '"ks_dep_trunc"'.

...

Additional arguments passed to print.

Value

Invisibly returns the input object x.


Simulate Double-Truncated Duration Data

Description

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).

Usage

sim_double_trunc(n, theta, G, s, vtheta = 0, model = c("fgm", "ind"))

Arguments

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"'.

Value

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.

Examples

set.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

Description

Summary S3 Method for ks_dep_trunc

Usage

## S3 method for class 'ks_dep_trunc'
summary(object, ...)

Arguments

object

Object of class '"ks_dep_trunc"'.

...

Additional arguments passed to summary.

Value

Invisibly returns the input object object.