Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alec42/Distributacalcul_Package
Package of probability functions, originally created for the Distributacalcul webapp
https://github.com/alec42/Distributacalcul_Package
Last synced: 3 months ago
JSON representation
Package of probability functions, originally created for the Distributacalcul webapp
- Host: GitHub
- URL: https://github.com/alec42/Distributacalcul_Package
- Owner: alec42
- License: other
- Created: 2019-07-27T01:29:30.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-01-12T20:59:14.000Z (10 months ago)
- Last Synced: 2024-07-22T06:47:33.183Z (4 months ago)
- Language: R
- Homepage: https://alec42.github.io/Distributacalcul_Package/
- Size: 1.24 MB
- Stars: 2
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - alec42/Distributacalcul_Package - Package of probability functions, originally created for the Distributacalcul webapp (R)
README
---
output:
md_document:
variant: gfm
---
[![](https://www.r-pkg.org/badges/version/Distributacalcul)](https://CRAN.R-project.org/package=Distributacalcul)
![](https://cranlogs.r-pkg.org/badges/grand-total/Distributacalcul)```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
library(tidyverse)
```# Distributacalcul
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.
## Installation
You can install the released version of Distributacalcul from [CRAN](https://CRAN.R-project.org) with:
``` r
install.packages("Distributacalcul")
```And the development version from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("alec42/Distributacalcul_Package")
```## Example
This is a basic example which shows you the typical use of the functions:
```{r beta-example}
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)
```## Syntax:
| 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 |# Included distributions and functions
## Continuous distributions
```{r Continuous-distr-table-create, include=FALSE}
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
)
)
``````{r Continuous-distr-table, echo=FALSE}
cont.distr.support %>%
as.data.frame() %>%
rownames_to_column('names') %>%
mutate_if(is.list, ~ifelse(. == T, "X", "")) %>%
column_to_rownames('names') %>%
pander::pander()
```## Discrete distributions
```{r Discrete-distr-table-create, include=FALSE}
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
)
)
``````{r Discrete-distr-table, echo=FALSE}
discr.distr.support %>%
as.data.frame() %>%
rownames_to_column('names') %>%
mutate_if(is.list, ~ifelse(. == T, "X", "")) %>%
column_to_rownames('names') %>%
pander::pander()
```## Copulas
1. Independence Copula
1. Fréchet Lower Bound Copula
1. Fréchet Upper Bound Copula
1. Fréchet Copula
1. Bivariate Gumbel Copula
1. Bivariate Clayton Copula
1. Bivariate Ali-Mikhail-Haq Copula
1. Bivariate Cuadras-Augé Copula
1. Bivariate Marshall-Olkin Copula
1. Bivariate Frank Copula
1. Bivariate Eyraud-Farlie-Gumbel-Morgenstern (EFGM) Copula# Updates
| 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. |