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 1-infl beta distribution > n <- 1e4 > > x <- roibeta(n, 2, 2, p1=1/2) > y <- roibeta(n, 4/3, 2/3, p1=1/3) > > #test CDF > z <- 0:10/10 > cbind(ecdf(x)(z), poibeta(z, 2, 2, 1/2)) [,1] [,2] [1,] 0.0000 0.000 [2,] 0.0165 0.014 [3,] 0.0527 0.052 [4,] 0.1118 0.108 [5,] 0.1809 0.176 [6,] 0.2528 0.250 [7,] 0.3215 0.324 [8,] 0.3885 0.392 [9,] 0.4418 0.448 [10,] 0.4858 0.486 [11,] 1.0000 1.000 > > cbind(ecdf(y)(z), poibeta(z, 4/3, 2/3, 1/3)) [,1] [,2] [1,] 0.0000 0.00000000 [2,] 0.0201 0.01957655 [3,] 0.0516 0.05040106 [4,] 0.0857 0.08860249 [5,] 0.1280 0.13345987 [6,] 0.1833 0.18505291 [7,] 0.2443 0.24405801 [8,] 0.3109 0.31194233 [9,] 0.3903 0.39172367 [10,] 0.4891 0.49092356 [11,] 1.0000 1.00000000 > > #total loss > c(etl(x), tloibeta(2, 2, 1/2)) [1] 0.5008 0.5000 > c(etl(y), tloibeta(4/3, 2/3, 1/3)) [1] 0.3355000 0.3333333 > > #mean > c(mean(x), moibeta(1, 2, 2, 1/2)) [1] 0.7501909 0.7500000 > c(mean(y), moibeta(1, 4/3, 2/3, 1/3)) [1] 0.7793149 0.7777778 > > > #test EC > cbind(eecf(x)(z), ecoibeta(z, 2, 2, 1/2)) [,1] [,2] [1,] 0.0000000 0.0000000 [2,] 0.1325246 0.1327000 [3,] 0.2614707 0.2618667 [4,] 0.3841278 0.3847000 [5,] 0.4981545 0.4992000 [6,] 0.6024449 0.6041667 [7,] 0.6975441 0.6992000 [8,] 0.7835151 0.7847000 [9,] 0.8613992 0.8618667 [10,] 0.9326541 0.9327000 [11,] 1.0000000 1.0000000 > cbind(eecf(y)(z), ecoibeta(z, 4/3, 2/3, 1/3)) [,1] [,2] [1,] 0.0000000 0.0000000 [2,] 0.1272228 0.1274992 [3,] 0.2509505 0.2516596 [4,] 0.3707148 0.3713682 [5,] 0.4853287 0.4857347 [6,] 0.5937818 0.5939049 [7,] 0.6947391 0.6949759 [8,] 0.7874183 0.7879114 [9,] 0.8710748 0.8714003 [10,] 0.9430365 0.9435146 [11,] 1.0000000 1.0000000 > > > > #plots > n <- 1e2 > x <- roibeta(n, 2, 2, p1=1/2) > y <- roibeta(n, 4/3, 2/3, p1=1/3) > > > plot(eecf(x), do.points=FALSE) > v <- seq(0, 1, length=101) > lines(v, ecoibeta(v, 2, 2, 1/2), lty=3, col="red") > > > plot(eecf(y), do.points=FALSE) > v <- seq(0, 1, length=101) > lines(v, ecoibeta(v, 4/3, 2/3, 1/3), lty=3, col="red") > > > proc.time() user system elapsed 1.65 0.21 1.85