In the previous tutorial we looked at multivariate distributions and how to use the d/p/q/r functions to evaluate multiple points of these. This tutorial concludes the ‘Basic’ set of tutorials with the use of ‘listing’ in distr6.
Currently distr6 includes 5 listing functions:
listDistributions(), listDecorators(), listWrappers(), listKernels(), listSpecialSets(). These are essentially ways of listing the R6 classes implemented in the R6 API. We will only discuss the
listDistributions() function here as the others cover classes that we haven’t discussed yet, but hopefully are intuitive to you and have a similar interface to
listDistributions() is used to list every implemented probability distribution in distr6. The default parameters return a data.table of every implemented distribution including their traits and the package that their d/p/q/r methods are implemented in. For example a distribution with package
stats means that the d/p/q/r methods interface the R stats functions whereas a distribution with package
distr6 means the methods are written in distr6. We’ve added the
head() method just to save space.
head(listDistributions()) #> ShortName ClassName Type ValueSupport VariateForm Package Tags #> 1: Arc Arcsine ℝ continuous univariate - limits #> 2: Bern Bernoulli ℕ0 discrete univariate stats #> 3: Beta Beta ℝ+ continuous univariate stats #> 4: BetaNC BetaNoncentral ℝ+ continuous univariate stats #> 5: Binom Binomial ℕ0 discrete univariate stats limits #> 6: Cat Categorical V discrete univariate -
To see a simplified version of the list, add the
simplify = TRUE argument
head(listDistributions(simplify = TRUE)) #>  "Arcsine" "Bernoulli" "Beta" "BetaNoncentral" #>  "Binomial" "Categorical"
Finally this list can be filtered to help you find a distribution with specific traits, for example for a multivariate distribution
head(listDistributions(filter = list(variateform = "multivariate"))) #> ShortName ClassName Type ValueSupport VariateForm Package #> 1: Diri Dirichlet [0,1]^K continuous multivariate extraDistr #> 2: EmpMV EmpiricalMV ℝ discrete multivariate - #> 3: Multinom Multinomial ℕ0^K discrete multivariate extraDistr #> 4: MultiNorm MultivariateNormal ℝ^K continuous multivariate - #> Tags #> 1: #> 2: #> 3: limits #> 4: locscale # The trait name is case-insensitive head(listDistributions(filter = list(VaRiAtEfORm = "multivariate"))) #> ShortName ClassName Type ValueSupport VariateForm Package #> 1: Diri Dirichlet [0,1]^K continuous multivariate extraDistr #> 2: EmpMV EmpiricalMV ℝ discrete multivariate - #> 3: Multinom Multinomial ℕ0^K discrete multivariate extraDistr #> 4: MultiNorm MultivariateNormal ℝ^K continuous multivariate - #> Tags #> 1: #> 2: #> 3: limits #> 4: locscale
Or for multiple filters:
In this tutorial we looked at the
listDistributions() function so that you don’t have to remember which are implemented in distr6. In this set of tutorials we covered the basics of constructing a (univariate) distribution, getting and setting parameters, evaluating statistical results and extending all this to multivariate distributions. The next set of tutorials cover more advanced functionality including decorators for numeric results, wrappers for composite distributions, custom distributions, S3 functionality, and symbolic sets.