knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" ) library(tidyverse)
The goal of Distributacalcul is to simplify the life of students and scientists by offering premade functions for various functions of probability distributions. Functions calculate moments of the distribution (mean, variance, kth moment) as well as the expected value of functions of the distribution (truncated mean, stop-loss, mean excess loss, etc.). In addition, the package includes some risk measures (Value-at-Risk and Tail Value-at-Risk).
In addition, this package has recently added probability functions for various bivariate copulas. Functions calculate the density associated with the copula, the distribution function and also simulations.
This package depends primarily the stats package.
You can install the released version of Distributacalcul from CRAN with:
install.packages("Distributacalcul")
And the development version from GitHub with:
# install.packages("devtools") devtools::install_github("alec42/Distributacalcul_Package")
This is a basic example which shows you the typical use of the functions:
library(Distributacalcul) ## Various moments: expValBeta(shape1 = 2, shape2 = 4) # E[X] varBeta(shape1 = 2, shape2 = 4) # V(X) kthMomentBeta(k = 3, shape1 = 2, shape2 = 4) # E[X^k] ## Expected value of functions: expValLimBeta(d = 0.3, shape1 = 2, shape2 = 4) # E[min(X; d)] expValTruncBeta(d = .3, shape1 = 2, shape2 = 4, less.than.d = TRUE) # E[X * 1_{X <= d}] expValTruncBeta(d = .3, shape1 = 2, shape2 = 4, less.than.d = FALSE) # E[X * 1_{X > d}] meanExcessBeta(d = .3, shape1 = 2, shape2 = 4) # E[(X - d | X > d)] stopLossBeta(d = .3, shape1 = 2, shape2 = 4) # E[max(X - d, 0)] ## Risk measures: TVatRBeta(kap = 0.99, shape1 = 2, shape2 = 4) # TVaR_{k}(X) VatRBeta(kap = 0.99, shape1 = 2, shape2 = 4) # VaR_{k}(X) = F_X^(-1)(k)
| Function | Syntax | | --------------------------- | ---------------------- | | Mean | expValDistribution | | K-th moment | kthMomentDistribution | | Truncated mean | expValTruncDistribution | | Limited expected value | expValLimDistribution | | Variance | varDistribution | | Stop-loss | stopLossDistribution | | Excess of mean | meanExcessDistribution | | Moment Generating Function | mgfDistribution | | Probability Generating Function | pgfDistribution | | Density | dDistribution | | Cumulative density function | pDistribution | | Value-at-Risk (percentile) | VatRDistribution | | Tail Value-at-Risk | TVatRDistribution | | Copula Density | cdCopula | | Copula Distribution Function | cCopula | | Copula Simulation Function | crCopula |
cont.distr.support <- cbind( Erlang = list(`Mean` = T, `kth moment` = T, `Variance` = T, `Truncated mean` = T, `Limited mean` = T, `Stop-loss` = T, `Excess of mean` = T, `Moment Generating Function` = T, `Probability Density Function` = T, `Cumulative Probability Density Function` = T, `Value-at-Risk` = T, `Tail Value-at-Risk` = T ), `Inverse Gaussian` = list(`Mean` = T, `kth moment` = F, `Variance` = T, `Truncated mean` = T, `Limited mean` = T, `Stop-loss` = T, `Excess of mean` = T, `Moment Generating Function` = T, `Probability Density Function` = F, `Cumulative Probability Density Function` = F, `Value-at-Risk` = T, `Tail Value-at-Risk` = T ), `Weibull` = list(`Mean` = T, `kth moment` = T, `Variance` = T, `Truncated mean` = T, `Limited mean` = T, `Stop-loss` = T, `Excess of mean` = T, `Moment Generating Function` = F, `Probability Density Function` = F, `Cumulative Probability Density Function` = F, `Value-at-Risk` = T, `Tail Value-at-Risk` = T ), `Burr` = list(`Mean` = T, `kth moment` = T, `Variance` = T, `Truncated mean` = T, `Limited mean` = T, `Stop-loss` = T, `Excess of mean` = T, `Moment Generating Function` = F, `Probability Density Function` = F, `Cumulative Probability Density Function` = F, `Value-at-Risk` = T, `Tail Value-at-Risk` = T ), `Log-logistic` = list(`Mean` = T, `kth moment` = T, `Variance` = T, `Truncated mean` = T, `Limited mean` = T, `Stop-loss` = T, `Excess of mean` = T, `Moment Generating Function` = F, `Probability Density Function` = T, `Cumulative Probability Density Function` = T, `Value-at-Risk` = T, `Tail Value-at-Risk` = T ), `Beta` = list(`Mean` = T, `kth moment` = T, `Variance` = T, `Truncated mean` = T, `Limited mean` = T, `Stop-loss` = T, `Excess of mean` = T, `Moment Generating Function` = T, `Probability Density Function` = F, `Cumulative Probability Density Function` = F, `Value-at-Risk` = T, `Tail Value-at-Risk` = T ), `Gamma` = list(`Mean` = T, `kth moment` = T, `Variance` = T, `Truncated mean` = T, `Limited mean` = T, `Stop-loss` = T, `Excess of mean` = T, `Moment Generating Function` = T, `Probability Density Function` = F, `Cumulative Probability Density Function` = F, `Value-at-Risk` = T, `Tail Value-at-Risk` = T ), `Pareto` = list(`Mean` = T, `kth moment` = T, `Variance` = T, `Truncated mean` = T, `Limited mean` = T, `Stop-loss` = T, `Excess of mean` = T, `Moment Generating Function` = F, `Probability Density Function` = T, `Cumulative Probability Density Function` = T, `Value-at-Risk` = T, `Tail Value-at-Risk` = T ), # `Generalized F-distribution` = list(`Mean` = F, `kth moment` = F, `Variance` = F, # `Truncated mean` = F, `Limited mean` = F, `Stop-loss` = F, `Excess of mean` = F, # `Moment Generating Function` = F, # `Probability Density Function` = F, `Cumulative Probability Density Function` = T, # `Value-at-Risk` = T, `Tail Value-at-Risk` = F # ), `Lognormal` = list(`Mean` = T, `kth moment` = T, `Variance` = T, `Truncated mean` = T, `Limited mean` = T, `Stop-loss` = T, `Excess of mean` = T, `Moment Generating Function` = F, `Probability Density Function` = F, `Cumulative Probability Density Function` = F, `Value-at-Risk` = T, `Tail Value-at-Risk` = T ), `Exponential` = list(`Mean` = T, `kth moment` = T, `Variance` = T, `Truncated mean` = T, `Limited mean` = T, `Stop-loss` = T, `Excess of mean` = T, `Moment Generating Function` = T, `Probability Density Function` = F, `Cumulative Probability Density Function` = F, `Value-at-Risk` = T, `Tail Value-at-Risk` = T ), `Uniform` = list(`Mean` = T, `kth moment` = T, `Variance` = T, `Truncated mean` = T, `Limited mean` = T, `Stop-loss` = T, `Excess of mean` = T, `Moment Generating Function` = T, `Probability Density Function` = F, `Cumulative Probability Density Function` = F, `Value-at-Risk` = T, `Tail Value-at-Risk` = T ), `Normal` = list(`Mean` = T, `kth moment` = F, `Variance` = T, `Truncated mean` = T, `Limited mean` = T, `Stop-loss` = T, `Excess of mean` = T, `Moment Generating Function` = T, `Probability Density Function` = F, `Cumulative Probability Density Function` = F, `Value-at-Risk` = T, `Tail Value-at-Risk` = T ) )
cont.distr.support %>% as.data.frame() %>% rownames_to_column('names') %>% mutate_if(is.list, ~ifelse(. == T, "X", "")) %>% column_to_rownames('names') %>% pander::pander()
discr.distr.support <- cbind( `Binomial` = list(`Mean` = T, `kth moment` = F, `Variance` = T, `Truncated mean` = T, `Limited mean` = F, `Stop-loss` = F, `Excess of mean` = F, `Moment Generating Function` = T, `Probability Generating Function` = T, `Probability Density Function` = F, `Cumulative Probability Density Function` = F, `Value-at-Risk` = T, `Tail Value-at-Risk` = T ), `Negative Binomial` = list(`Mean` = T, `kth moment` = F, `Variance` = T, `Truncated mean` = T, `Limited mean` = F, `Stop-loss` = F, `Excess of mean` = F, `Moment Generating Function` = T, `Probability Generating Function` = T, `Probability Density Function` = F, `Cumulative Probability Density Function` = F, `Value-at-Risk` = F, `Tail Value-at-Risk` = T ), `Poisson` = list(`Mean` = T, `kth moment` = F, `Variance` = T, `Truncated mean` = T, `Limited mean` = F, `Stop-loss` = F, `Excess of mean` = F, `Moment Generating Function` = T, `Probability Generating Function` = T, `Probability Density Function` = F, `Cumulative Probability Density Function` = F, `Value-at-Risk` = F, `Tail Value-at-Risk` = T ), `Uniform` = list(`Mean` = T, `kth moment` = F, `Variance` = T, `Truncated mean` = F, `Limited mean` = F, `Stop-loss` = F, `Excess of mean` = F, `Moment Generating Function` = F, `Probability Generating Function` = F, `Probability Density Function` = T, `Cumulative Probability Density Function` = T, `Value-at-Risk` = F, `Tail Value-at-Risk` = F ), `Logarithmic` = list(`Mean` = T, `kth moment` = F, `Variance` = T, `Truncated mean` = F, `Limited mean` = F, `Stop-loss` = F, `Excess of mean` = F, `Moment Generating Function` = T, `Probability Generating Function` = T, `Probability Density Function` = F, `Cumulative Probability Density Function` = F, `Value-at-Risk` = T, `Tail Value-at-Risk` = F ), `Hypergeometric` = list(`Mean` = T, `kth moment` = F, `Variance` = T, `Truncated mean` = F, `Limited mean` = F, `Stop-loss` = F, `Excess of mean` = F, `Moment Generating Function` = F, `Probability Generating Function` = F, `Probability Density Function` = F, `Cumulative Probability Density Function` = F, `Value-at-Risk` = F, `Tail Value-at-Risk` = F ) )
discr.distr.support %>% as.data.frame() %>% rownames_to_column('names') %>% mutate_if(is.list, ~ifelse(. == T, "X", "")) %>% column_to_rownames('names') %>% pander::pander()
| Date | Modifications | |:----------:|:-----------------------------------------------------------:| | 26/07/2019 | Initial creation of package | | 12/09/2019 | Completion of creation of all necessary function files | | 17/11/2019 | Merger of tvarPackage, beginning of documentation creation. | | 20/05/2020 | Addition of Shiny component. | | 02/06/2020 | Completion of documentation, first attempt of a submission to CRAN. | | 02/07/2020 | Modifications according to CRAN's notes, version 0.2.0. | | 02/13/2020 | Small fixes, version 0.2.2. | | 31/08/2020 | Significant changes and additions, version 0.3.0. | | 31/12/2023 | Removal of shiny components and vignettes, version 0.4.0. |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.