This package implements a non-iterative estimator for the cumulative distribution of a doubly truncated variable, see de Uña-Álvarez (2018). The package is restricted to interval sampling.
de Uña-Álvarez J. (2018) A Non-iterative Estimator for Interval Sampling and Doubly Truncated Data. In: Gil E., Gil E., Gil J., Gil M. (eds) The Mathematics of the Uncertain. Studies in Systems, Decision and Control, vol 142. Springer, Cham, pp. 387-400.
This function calculates the non-iterative estimator for the cumulative distribution of a doubly truncated variable proposed by de Uña-Álvarez (2018). The package works for interval sampling.
The function DTDAni is adapted to the presence of ties. It can be used to compute the direct \((Fd)\) and the reverse \((Fr)\) estimators; see the example below. Both curves are valid estimators for the cumulative distribution \((F)\) of the doubly truncated variable. Weighted estimators \(Fw = w*Fd + (1-w)*Fr\) with \(0<w<1\) are valid too, the choice \(w=1/2\) being recommended in practice (de Uña-Álvarez, 2018).
In order to use this package, install it and load the library with:
library(DTDA.ni)
# Loading the package:
library(DTDA.ni)
# Generating data which are doubly truncated:
<- 250
N <- runif(N) # Original data
x0 <- runif(N, -0.25, 0.5) # Left-truncation times
u0 <- 0.75 # Interval width
tau <- u0 + tau
v0
<- x0[u0 <= x0 & x0 <= v0]
x <- u0[u0 <= x0 & x0 <= v0]
u <- v0[u0 <= x0 & x0 <= v0]
v <- length(x) # Final sample size after the interval sampling
n
# Create an object wit DTDAni function
<- DTDAni(x, u, tau)
res #> Call:
#> DTDAni(x = x, u = u, tau = tau)
plot(res, ecdf = FALSE) # Plot without ecdf (Default)
abline(a = 0, b = 1, col = "green") # The true cumulative distribution
# Calculating the reverse estimator:
plot(res)
<- DTDAni(-x, -u - 0.75, 0.75)
res2 #> Call:
#> DTDAni(x = -x, u = -u - 0.75, tau = 0.75)
abline(a = 0, b = 1, col = "green")
lines(-res2$x, 1 - res2$cumprob, type = "s", col = "blue", lty = 2)
# Weigthed estimator (recommended):
<- 1/2
w
<- length(res$x)
k
<- w * res$cumprob + (1 - w) * (1 - res2$cumprob[k:1])
Fw
plot(res)
abline(a = 0, b = 1, col = "green")
lines(-res2$x, 1 - res2$cumprob, type = "s", col = "blue", lty = 2)
lines(res$x, Fw, type = "s", col = 2)
# Using res$P and res$L to compute the estimator:
<- length(res$x)
k <- rep(1, k)
F for (i in 2:k) {
<- (F[i - 1] - res$P[i - 1]) / res$L[i - 1] + res$P[i - 1]
F[i]
}
<- F / max(F) # This is equal to res$cumprob F0
Jacobo de Uña-Álvarez was supported by Grant MTM2014-55966-P, Spanish Ministry of Economy and Competitiveness .
José Carlos Soage was supported by Red Tecnológica de Matemática Industrial (Red TMATI), Cons. de Cultura, Educación e OU, Xunta de Galicia (ED341D R2016/051) and by Grupos de Referencia Competitiva, Consolidación y Estructuración de Unidades de Investigación Competitivas del SUG, Cons. de Cultura, Educación e OU, Xunta de Galicia (GRC ED431C 2016/040).
de Uña-Álvarez J. (2018) A Non-iterative Estimator for Interval Sampling and Doubly Truncated Data. In: Gil E., Gil E., Gil J., Gil M. (eds) The Mathematics of the Uncertain. Studies in Systems, Decision and Control, vol 142. Springer, Cham