Some distributions (such as dist_inflated() and dist_transformed())
are defined in terms of another distribution, which returns a distribution
as one of their parameters. By default, this underlying distribution is
returned as-is in a column of the parameters() result. Setting
recursive = TRUE will recursively compute the parameters of these inner
distributions, returning a flat data frame of all parameters.
parameters(x, ...)
# S3 method for class 'distribution'
parameters(x, recursive = FALSE, ...)The distribution(s).
Additional arguments used by methods.
If TRUE, parameters which are themselves
distributions (such as the base distribution of a
dist_inflated() or dist_transformed()) are recursively expanded
into their own parameters instead of being returned as a distribution.
A data frame of parameters, with one row per distribution and one column per parameter. The result never contains data frame (or distribution) columns.
dist <- c(
dist_normal(1:2),
dist_poisson(3),
dist_multinomial(size = c(4, 3),
prob = list(c(0.3, 0.5, 0.2), c(0.1, 0.5, 0.4)))
)
parameters(dist)
#> mu sigma l s p
#> 1 1 1 NA NA NULL
#> 2 2 1 NA NA NULL
#> 3 NA NA 3 NA NULL
#> 4 NA NA NA 4 0.3, 0.5, 0.2
#> 5 NA NA NA 3 0.1, 0.5, 0.4
# Distribution-valued parameters (such as the inflated distribution
# below) are returned as-is by default.
infl_dist <- dist_inflated(dist_negative_binomial(10, 0.6), prob = 0.5)
parameters(infl_dist)
#> dist x p
#> 1 NB(10, 0.6) 0 0.5
# With recursive = TRUE, the inflated distribution's parameters are
# expanded into a flat data frame.
parameters(infl_dist, recursive = TRUE)
#> dist.n dist.p x p
#> 1 10 0.6 0 0.5