Skip to contents

Given a sample of intervals [lower_i, upper_i] (each interval containing an unobserved exact value), estimates the distribution function of that unobserved value – TDA's midf (undocumented beyond "calculates distribution function DM, and lower/upper bounds" in its own header, which also understates the command's arity: it lists three outputs, midf(XL,XU,DL,DU,DM), but m_midf actually returns four, midf(XL,XU,PT,DL,DU,DM) – the breakpoints themselves, PT, are a result too). Evaluated at every distinct interval endpoint (the “induced partition” breakpoints): lower_bound counts only intervals entirely below that point (a sure lower bound on the true CDF); upper_bound counts every interval that could be below it (a sure upper bound); cdf is a point estimate in between, assuming each interval's unobserved value is uniformly distributed within it. Every interval must have positive width (lower < upper, swapped automatically if given in the other order). Confirmed cell-for-cell by hand on a 3-interval example.

Usage

tda_midf(lower, upper, dir = tempfile("tda"))

Arguments

lower, upper

numeric vectors, the same length, with lower[i] != upper[i] for every i.

dir

working directory.

Value

A list: breakpoints, the sorted distinct interval endpoints; lower_bound, upper_bound, cdf, each the same length as breakpoints.

Examples

# five observations known only to intervals: [0,2], [1,3], [2,4], [3,5], [1,2]
lo <- c(0, 1, 2, 3, 1)
up <- c(2, 3, 4, 5, 2)
# at each endpoint: the share of intervals surely below it (lower
# bound), possibly below it (upper bound), and the estimate between
tda_midf(lo, up)
#> $breakpoints
#> [1] 0 1 2 3 4 5
#> 
#> $lower_bound
#> [1] 0.0 0.0 0.4 0.6 0.8 1.0
#> 
#> $upper_bound
#> [1] 0.2 0.6 0.8 1.0 1.0 1.0
#> 
#> $cdf
#> [1] 0.0 0.1 0.5 0.7 0.9 1.0
#>