Closed joshwlambert closed 1 month ago
The improvements in the PR have also fixed a previously unknown bug when discretising <epiparameter>
objects with a truncated lognormal distribution (I think the bug extended to any truncated probability distribution where the class name in the <distribution>
object does not match the distribution name in R).
Here is a reprex using code from the main
branch.
library(epiparameter)
ep = epiparameter(
disease = "Disease",
epi_name = "SI",
prob_distribution = create_prob_distribution(
prob_distribution = "lnorm",
prob_distribution_params = c(meanlog = 2, sdlog = 2),
truncation = 10)
)
#> Citation cannot be created as author, year, journal or title is missing
discretise(ep)
#> Warning: Discretising a truncated continuous distribution, returning
#> non-truncated discretised distribution
#> Error: Invalid parameterisation for lognormal distribution
Created on 2024-10-21 with reprex v2.1.0
Here is a reprex using code from the get_dist_class
branch.
library(epiparameter)
ep = epiparameter(
disease = "Disease",
epi_name = "SI",
prob_distribution = create_prob_distribution(
prob_distribution = "lnorm",
prob_distribution_params = c(meanlog = 2, sdlog = 2),
truncation = 10)
)
#> Citation cannot be created as author, year, journal or title is missing
discretise(ep)
#> Warning: Discretising a truncated continuous distribution, returning
#> non-truncated discretised distribution
#> Disease: Disease
#> Pathogen: NA
#> Epi Parameter: si
#> Study: (????). "No citation."
#> Distribution: discrete lnorm
#> Parameters:
#> meanlog: 2.000
#> sdlog: 2.000
Created on 2024-10-21 with reprex v2.1.0
This PR improves the access to distribution names in
<distribution>
objects from the {distributional} package by replacing the.get_mixture_dist()
function with the more general.distributional_family()
and enhancingfamily.epiparameter()
.Using the new version of the
<epiparameter>
family()
method, calls tostats::family()
have been removed from the package, andis_truncated()
has been simplified (#274).The PR improves functions that were manually extracting the information from
<distribution>
objects by having to subset objects several times (e.g.discretise.epiparameter()
) by now calling.distributional_family()
.New tests are added for
family.epiparameter()
and.distributional_family()
.