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 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.0149 0.014 [3,] 0.0559 0.052 [4,] 0.1155 0.108 [5,] 0.1835 0.176 [6,] 0.2567 0.250 [7,] 0.3277 0.324 [8,] 0.3913 0.392 [9,] 0.4414 0.448 [10,] 0.4809 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.0162 0.01957655 [3,] 0.0510 0.05040106 [4,] 0.0878 0.08860249 [5,] 0.1365 0.13345987 [6,] 0.1872 0.18505291 [7,] 0.2435 0.24405801 [8,] 0.3086 0.31194233 [9,] 0.3854 0.39172367 [10,] 0.4873 0.49092356 [11,] 1.0000 1.00000000 > > #total loss > c(etl(x), tloibeta(2, 2, 1/2)) [1] 0.5043 0.5000 > c(etl(y), tloibeta(4/3, 2/3, 1/3)) [1] 0.3287000 0.3333333 > > #mean > c(mean(x), moibeta(1, 2, 2, 1/2)) [1] 0.7483879 0.7500000 > c(mean(y), moibeta(1, 4/3, 2/3, 1/3)) [1] 0.7789391 0.7777778 > > > #test EC > cbind(eecf(x)(z), ecoibeta(z, 2, 2, 1/2)) [,1] [,2] [1,] 0.0000000 0.0000000 [2,] 0.1329332 0.1327000 [3,] 0.2620736 0.2618667 [4,] 0.3845003 0.3847000 [5,] 0.4982509 0.4992000 [6,] 0.6023633 0.6041667 [7,] 0.6967706 0.6992000 [8,] 0.7822163 0.7847000 [9,] 0.8601319 0.8618667 [10,] 0.9319097 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.1275339 0.1274992 [3,] 0.2518207 0.2516596 [4,] 0.3714068 0.3713682 [5,] 0.4855541 0.4857347 [6,] 0.5931829 0.5939049 [7,] 0.6940733 0.6949759 [8,] 0.7870337 0.7879114 [9,] 0.8710967 0.8714003 [10,] 0.9437139 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.06 0.14 1.18