R Under development (unstable) (2024-12-17 r87446 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.13 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.0157 0.014 [3,] 0.0559 0.052 [4,] 0.1098 0.108 [5,] 0.1780 0.176 [6,] 0.2499 0.250 [7,] 0.3245 0.324 [8,] 0.3969 0.392 [9,] 0.4501 0.448 [10,] 0.4870 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.0213 0.01957655 [3,] 0.0512 0.05040106 [4,] 0.0905 0.08860249 [5,] 0.1352 0.13345987 [6,] 0.1864 0.18505291 [7,] 0.2433 0.24405801 [8,] 0.3139 0.31194233 [9,] 0.3893 0.39172367 [10,] 0.4897 0.49092356 [11,] 1.0000 1.00000000 > > #total loss > c(etl(x), tloibeta(2, 2, 1/2)) [1] 0.4982 0.5000 > c(etl(y), tloibeta(4/3, 2/3, 1/3)) [1] 0.3313000 0.3333333 > > #mean > c(mean(x), moibeta(1, 2, 2, 1/2)) [1] 0.7481531 0.7500000 > c(mean(y), moibeta(1, 4/3, 2/3, 1/3)) [1] 0.7770828 0.7777778 > > > #test EC > cbind(eecf(x)(z), ecoibeta(z, 2, 2, 1/2)) [,1] [,2] [1,] 0.0000000 0.0000000 [2,] 0.1329888 0.1327000 [3,] 0.2622242 0.2618667 [4,] 0.3848592 0.3847000 [5,] 0.4995128 0.4992000 [6,] 0.6045948 0.6041667 [7,] 0.6998106 0.6992000 [8,] 0.7851015 0.7847000 [9,] 0.8619484 0.8618667 [10,] 0.9327702 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.1276068 0.1274992 [3,] 0.2517843 0.2516596 [4,] 0.3713672 0.3713682 [5,] 0.4855470 0.4857347 [6,] 0.5936830 0.5939049 [7,] 0.6946895 0.6949759 [8,] 0.7875740 0.7879114 [9,] 0.8710923 0.8714003 [10,] 0.9435667 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.53 0.42 1.95