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 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.2343 0.2314050 [3,] 0.4133 0.4074074 [4,] 0.5489 0.5443787 [5,] 0.6545 0.6530612 [6,] 0.7401 0.7407407 [7,] 0.8066 0.8125000 [8,] 0.8682 0.8719723 [9,] 0.9194 0.9218107 [10,] 0.9631 0.9639889 [11,] 1.0000 1.0000000 > > cbind(ecdf(y)(z), pstpareto(z, 1/2)) [,1] [,2] [1,] 0.0000 0.0000000 [2,] 0.1549 0.1588887 [3,] 0.2971 0.2974773 [4,] 0.4174 0.4197502 [5,] 0.5312 0.5286764 [6,] 0.6314 0.6265199 [7,] 0.7217 0.7150407 [8,] 0.7995 0.7956313 [9,] 0.8692 0.8694090 [10,] 0.9364 0.9372827 [11,] 1.0000 1.0000000 > > #mean > c(mean(x), mstpareto(1, 2)) [1] 0.3332951 0.3333333 > c(mean(y), mstpareto(1, 1/2)) [1] 0.4129868 0.4142136 > > #test EC > cbind(eecf(x)(z), ecstpareto(z, 2)) [,1] [,2] [1,] 0.0000000 0.0000000 [2,] 0.2630328 0.2636364 [3,] 0.4648078 0.4666667 [4,] 0.6194245 0.6230769 [5,] 0.7383262 0.7428571 [6,] 0.8288908 0.8333333 [7,] 0.8967521 0.9000000 [8,] 0.9453426 0.9470588 [9,] 0.9768947 0.9777778 [10,] 0.9945073 0.9947368 [11,] 1.0000000 1.0000000 > > cbind(eecf(y)(z), ecstpareto(z, 1/2)) [,1] [,2] [1,] 0.0000000 0.0000000 [2,] 0.2228848 0.2217849 [3,] 0.4096499 0.4077542 [4,] 0.5650085 0.5623032 [5,] 0.6921562 0.6889957 [6,] 0.7930004 0.7907689 [7,] 0.8710494 0.8700772 [8,] 0.9287420 0.9289968 [9,] 0.9685202 0.9693028 [10,] 0.9921899 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 2.34 0.34 2.61