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 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.2349 0.2314050 [3,] 0.4069 0.4074074 [4,] 0.5427 0.5443787 [5,] 0.6528 0.6530612 [6,] 0.7380 0.7407407 [7,] 0.8082 0.8125000 [8,] 0.8698 0.8719723 [9,] 0.9238 0.9218107 [10,] 0.9638 0.9639889 [11,] 1.0000 1.0000000 > > cbind(ecdf(y)(z), pstpareto(z, 1/2)) [,1] [,2] [1,] 0.0000 0.0000000 [2,] 0.1608 0.1588887 [3,] 0.3012 0.2974773 [4,] 0.4262 0.4197502 [5,] 0.5329 0.5286764 [6,] 0.6323 0.6265199 [7,] 0.7207 0.7150407 [8,] 0.7987 0.7956313 [9,] 0.8670 0.8694090 [10,] 0.9384 0.9372827 [11,] 1.0000 1.0000000 > > #mean > c(mean(x), mstpareto(1, 2)) [1] 0.3341142 0.3333333 > c(mean(y), mstpareto(1, 1/2)) [1] 0.4113686 0.4142136 > > #test EC > cbind(eecf(x)(z), ecstpareto(z, 2)) [,1] [,2] [1,] 0.0000000 0.0000000 [2,] 0.2623365 0.2636364 [3,] 0.4643995 0.4666667 [4,] 0.6212337 0.6230769 [5,] 0.7415640 0.7428571 [6,] 0.8324021 0.8333333 [7,] 0.8997577 0.9000000 [8,] 0.9477907 0.9470588 [9,] 0.9782035 0.9777778 [10,] 0.9948101 0.9947368 [11,] 1.0000000 1.0000000 > > cbind(eecf(y)(z), ecstpareto(z, 1/2)) [,1] [,2] [1,] 0.0000000 0.0000000 [2,] 0.2230816 0.2217849 [3,] 0.4095800 0.4077542 [4,] 0.5643548 0.5623032 [5,] 0.6906726 0.6889957 [6,] 0.7917942 0.7907689 [7,] 0.8703997 0.8700772 [8,] 0.9286205 0.9289968 [9,] 0.9691092 0.9693028 [10,] 0.9926555 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.42 0.12 1.53