R Under development (unstable) (2023-08-27 r85021 ucrt) -- "Unsuffered Consequences" Copyright (C) 2023 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(mbbefd) Loading required package: fitdistrplus Loading required package: MASS Loading required package: survival Loading required package: alabama Loading required package: numDeriv Loading required package: Rcpp Package: mbbefd Version: 0.8.11 Date: BugReport: https://github.com/spedygiorgio/mbbefd/issues > > #test of shifted truncated pareto distribution > n <- 1e1 > > x <- rstpareto(n, 2)+0.01 > y <- rstpareto(n, 2) > > #test CDF > z <- 0:4/4 > ecdf(x)(z) [1] 0.0 0.6 0.9 1.0 1.0 > > #test EC > f <- function(d) + mean(pmin(x, d))/mean(x) > rval <- Vectorize(f, "d") > > cbind(eecf(x)(x), rval(x)) [,1] [,2] [1,] 0.4684651 0.4684651 [2,] 0.7329646 0.7329646 [3,] 0.9175180 0.9175180 [4,] 0.6706209 0.6706209 [5,] 0.4494321 0.4494321 [6,] 0.1973738 0.1973738 [7,] 0.9407556 0.9407556 [8,] 0.4419607 0.4419607 [9,] 1.0000000 1.0000000 [10,] 0.3530941 0.3530941 > cbind(eecf(x)(z), rval(z)) [,1] [,2] [1,] 0.0000000 0.0000000 [2,] 0.7030013 0.7030013 [3,] 0.9610419 0.9610419 [4,] 1.0000000 1.0000000 [5,] 1.0000000 1.0000000 > > class(eecf(x)) [1] "eecf" "function" > class(ecdf(x)) [1] "ecdf" "stepfun" "function" > > print(eecf(x)) Empirical Exposure Curve Function Call: eecf(x) x[1:10] = 0.048897, 0.091761, 0.11928, ..., 0.44974, 0.59651 > print(ecdf(x)) Empirical CDF Call: ecdf(x) x[1:10] = 0.048897, 0.091761, 0.11928, ..., 0.44974, 0.59651 > > cbind(eecf(x)(sort(x)), + environment(eecf(x))$"Gx") [,1] [,2] [1,] 0.1973738 0.1973738 [2,] 0.3530941 0.3530941 [3,] 0.4419607 0.4419607 [4,] 0.4494321 0.4494321 [5,] 0.4684651 0.4684651 [6,] 0.6706209 0.6706209 [7,] 0.7329646 0.7329646 [8,] 0.9175180 0.9175180 [9,] 0.9407556 0.9407556 [10,] 1.0000000 1.0000000 > > print(summary(eecf(x))) Empirical Exposure Curve Function: 10 unique values with summary Min. 1st Qu. Median Mean 3rd Qu. Max. 0.0489 0.1199 0.1799 0.2477 0.3829 0.5965 > print(summary(ecdf(x))) Empirical CDF: 10 unique values with summary Min. 1st Qu. Median Mean 3rd Qu. Max. 0.0489 0.1199 0.1799 0.2477 0.3829 0.5965 > > plot(eecf(x)) > plot(ecdf(x)) > > > plot(eecf(x)) > plot(eecf(y), add=TRUE, col="red") > lines(eecf(y[1:5]), col="green") > > ?plot.eecf > ?summary.eecf > > proc.time() user system elapsed 1.06 0.29 1.37