knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "README-" )
An R
package to calculate the $n$-fold convolution of Pareto distributions.
f(x)=a x1-a,
for x>0, a>1 using the techniques devised by Colin Ramsay in
'The Distribution of Sums of Certain I.I.D. Pareto Variates' (Communications in Statistics - Theory and Methods 35:395-405, 2006); and
'The Distribution of Sums of I.I.D. Pareto Random Variables with Arbitrary Shape Parameter' (Communications in Statistics - Theory and Methods 37:2177-2184, 2008).
The package contains only one function:
paretoconv (x, a, n, cdf=FALSE)
where n
specifies the number of convolutions. Both this and a
must be
single-valued, while x
can be a vector. cdf
generates the cumulative
distribution function, otherwise the probability density function is returned.
paretoconv
is not (yet) on CRAN, and can be installed with any of the
following options:
remotes::install_git("https://git.sr.ht/~mpadge/paretoconv") remotes::install_bitbucket("mpadge/paretoconv") remotes::install_gitlab("mpadge/paretoconv") remotes::install_github("mpadge/paretoconv")
devtools::load_all ('.') #devtools::load_all ('.', recompile=TRUE) #devtools::document ('.') #devtools::check ('.') #goodpractice::gp ('.') #testthat::test_package ('paretoconv')
options(width=120)
Solid lines in the figure below are a reproduction of Ramsay's (2006) Figure 2 of probability density functions for the first 5 convolutions of the Pareto pdf with shape parameter of a=5. Dashed lines are analogous values for the non-integer value of a=4.5.
x <- 1:50 / 10 n <- 1:5 yint <- lapply (n, function (i) paretoconv (x=x, a=5, n=i)) ynon <- lapply (n, function (i) paretoconv (x=x, a=4.5, n=i)) cols <- rainbow (length (n)) plot (NULL, NULL, xlim=range (x), ylim=range (yint, na.rm=TRUE), xlab='x', ylab='p') for (i in n) { lines (x, yint [[i]], col=cols [i]) lines (x, ynon [[i]], col=cols [i], lty=2) } legend ('topright', lwd=1, col=cols, bty='n', legend=sapply (seq (n), function (i) paste0 ('n=', i)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.