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 <- 1e4 > > x <- rstpareto(n, 2) > y <- rstpareto(n, 1/2) > > #test CDF > z <- 0:10/10 > cbind(ecdf(x)(z), pstpareto(z, 2)) [,1] [,2] [1,] 0.0000 0.0000000 [2,] 0.2346 0.2314050 [3,] 0.4072 0.4074074 [4,] 0.5432 0.5443787 [5,] 0.6527 0.6530612 [6,] 0.7458 0.7407407 [7,] 0.8134 0.8125000 [8,] 0.8715 0.8719723 [9,] 0.9234 0.9218107 [10,] 0.9640 0.9639889 [11,] 1.0000 1.0000000 > > cbind(ecdf(y)(z), pstpareto(z, 1/2)) [,1] [,2] [1,] 0.0000 0.0000000 [2,] 0.1563 0.1588887 [3,] 0.2929 0.2974773 [4,] 0.4207 0.4197502 [5,] 0.5321 0.5286764 [6,] 0.6239 0.6265199 [7,] 0.7120 0.7150407 [8,] 0.7962 0.7956313 [9,] 0.8696 0.8694090 [10,] 0.9380 0.9372827 [11,] 1.0000 1.0000000 > > #mean > c(mean(x), mstpareto(1, 2)) [1] 0.3325579 0.3333333 > c(mean(y), mstpareto(1, 1/2)) [1] 0.4148215 0.4142136 > > #test EC > cbind(eecf(x)(z), ecstpareto(z, 2)) [,1] [,2] [1,] 0.0000000 0.0000000 [2,] 0.2642134 0.2636364 [3,] 0.4678089 0.4666667 [4,] 0.6248555 0.6230769 [5,] 0.7448702 0.7428571 [6,] 0.8348593 0.8333333 [7,] 0.9005800 0.9000000 [8,] 0.9478743 0.9470588 [9,] 0.9783595 0.9777778 [10,] 0.9950416 0.9947368 [11,] 1.0000000 1.0000000 > > cbind(eecf(y)(z), ecstpareto(z, 1/2)) [,1] [,2] [1,] 0.0000000 0.0000000 [2,] 0.2219923 0.2217849 [3,] 0.4089794 0.4077542 [4,] 0.5633712 0.5623032 [5,] 0.6889825 0.6889957 [6,] 0.7904542 0.7907689 [7,] 0.8700344 0.8700772 [8,] 0.9292952 0.9289968 [9,] 0.9695191 0.9693028 [10,] 0.9928105 0.9925264 [11,] 1.0000000 1.0000000 > > > plot(eecf(x)) > v <- seq(0, 1, length=101) > lines(v, ecstpareto(v, 2), lty=3, col="red") > > > plot(eecf(y)) > v <- seq(0, 1, length=101) > lines(v, ecstpareto(v, 1/2), lty=3, col="red") > > > proc.time() user system elapsed 1.59 0.17 1.75