R Under development (unstable) (2024-10-16 r87241 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 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.12 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.5 0.8 0.8 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,] 1.0000000 1.0000000 [2,] 0.9470364 0.9470364 [3,] 0.5150777 0.5150777 [4,] 0.6711407 0.6711407 [5,] 0.1048102 0.1048102 [6,] 0.7523371 0.7523371 [7,] 0.1866845 0.1866845 [8,] 0.2254057 0.2254057 [9,] 0.6368639 0.6368639 [10,] 0.5318189 0.5318189 > cbind(eecf(x)(z), rval(z)) [,1] [,2] [1,] 0.0000000 0.0000000 [2,] 0.5521161 0.5521161 [3,] 0.7924679 0.7924679 [4,] 0.9377673 0.9377673 [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.036067, 0.067372, 0.084028, ..., 0.76595, 0.94821 > print(ecdf(x)) Empirical CDF Call: ecdf(x) x[1:10] = 0.036067, 0.067372, 0.084028, ..., 0.76595, 0.94821 > > cbind(eecf(x)(sort(x)), + environment(eecf(x))$"Gx") [,1] [,2] [1,] 0.1048102 0.1048102 [2,] 0.1866845 0.1866845 [3,] 0.2254057 0.2254057 [4,] 0.5150777 0.5150777 [5,] 0.5318189 0.5318189 [6,] 0.6368639 0.6368639 [7,] 0.6711407 0.6711407 [8,] 0.7523371 0.7523371 [9,] 0.9470364 0.9470364 [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.03607 0.11960 0.27220 0.34410 0.40770 0.94820 > print(summary(ecdf(x))) Empirical CDF: 10 unique values with summary Min. 1st Qu. Median Mean 3rd Qu. Max. 0.03607 0.11963 0.27218 0.34412 0.40767 0.94821 > > 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.96 0.40 2.36