Fit a Subsampled Bootstrap to Integer Values and Summarise Distribution Parameters
Source:R/estimate_delay.R
bootstrapped_dist_fit.Rd
Fits an integer adjusted distribution to a subsampled bootstrap of data and then integrates the posterior samples into a single set of summary statistics. Can be used to generate a robust reporting delay that accounts for the fact the underlying delay likely varies over time or that the size of the available reporting delay sample may not be representative of the current case load.
Usage
bootstrapped_dist_fit(
values,
dist = "lognormal",
samples = 2000,
bootstraps = 10,
bootstrap_samples = 250,
max_value,
verbose = FALSE
)
Arguments
- values
Integer vector of values.
- dist
Character string, which distribution to fit. Defaults to lognormal (
"lognormal"
) but gamma ("gamma"
) is also supported.- samples
Numeric, number of samples to take overall from the bootstrapped posteriors.
- bootstraps
Numeric, defaults to 1. The number of bootstrap samples (with replacement) of the delay distribution to take.
- bootstrap_samples
Numeric, defaults to 100. The number of samples to take in each bootstrap. When the sample size of the supplied delay distribution is less than 100 this is used instead.
- max_value
Numeric, defaults to the maximum value in the observed data. Maximum delay to allow (added to output but does impact fitting).
- verbose
Logical, defaults to
FALSE
. Should progress messages be printed.
Examples
# \donttest{
# lognormal
delays <- rlnorm(500, log(5), 1)
out <- bootstrapped_dist_fit(delays,
samples = 1000, bootstraps = 10,
dist = "lognormal"
)
#> Warning: `samples` must be at least 1000. Now setting it to 1000 internally.
#> Warning: `samples` must be at least 1000. Now setting it to 1000 internally.
#> Warning: `samples` must be at least 1000. Now setting it to 1000 internally.
#> Warning: `samples` must be at least 1000. Now setting it to 1000 internally.
#> Warning: `samples` must be at least 1000. Now setting it to 1000 internally.
#> Warning: `samples` must be at least 1000. Now setting it to 1000 internally.
#> Warning: `samples` must be at least 1000. Now setting it to 1000 internally.
#> Warning: `samples` must be at least 1000. Now setting it to 1000 internally.
#> Warning: `samples` must be at least 1000. Now setting it to 1000 internally.
#> Warning: `samples` must be at least 1000. Now setting it to 1000 internally.
#> Warning: `dist_spec()` was deprecated in EpiNow2 1.5.0.
#> ℹ Please use distribution functions such as `Gamma()` or `Lognormal()` instead.
#> ℹ The function will become internal only in version 2.0.0.
#> ℹ The deprecated feature was likely used in the EpiNow2 package.
#> Please report the issue at <https://github.com/epiforecasts/EpiNow2/issues>.
out
#> - lognormal distribution (max: 180):
#> meanlog:
#> - normal distribution:
#> mean:
#> 1.4
#> sd:
#> 0.076
#> sdlog:
#> - normal distribution:
#> mean:
#> 1.1
#> sd:
#> 0.073
# }