A helper function when creating an <epiparameter>
object to
create a summary statistics list with sensible defaults, type checking
and arguments to help remember which summary statistics can be accepted in
the list.
Usage
create_summary_stats(
mean = NA_real_,
mean_ci_limits = c(NA_real_, NA_real_),
mean_ci = NA_real_,
sd = NA_real_,
sd_ci_limits = c(NA_real_, NA_real_),
sd_ci = NA_real_,
median = NA_real_,
median_ci_limits = c(NA_real_, NA_real_),
median_ci = NA_real_,
lower_range = NA_real_,
upper_range = NA_real_,
quantiles = NA_real_
)
Arguments
- mean
A
numeric
of the mean (expectation) of the probability distribution.- mean_ci_limits
A
numeric
vector of length two of the confidence interval around the mean.- mean_ci
A
numeric
specifying the confidence interval width, e.g. 95 would be the 95% CI- sd
A
numeric
of the standard deviation of the probability distribution.- sd_ci_limits
A
numeric
vector of length 2 of the confidence interval around the standard deviation.- sd_ci
A
numeric
specifying the confidence interval width, e.g. 95 would be 95% confidence interval.- median
A
numeric
of the median of the probability distribution.- median_ci_limits
A
numeric
vector of length two of the confidence interval around the median.- median_ci
A
numeric
specifying the confidence interval width of the median.- lower_range
The lower range of the data, used to infer the parameters of the distribution when not provided.
- upper_range
The upper range of the data, used to infer the parameters of the distribution when not provided.
- quantiles
A
numeric
vector of the quantiles for the distribution. If quantiles are not provided a default empty vector with the 2.5th, 5th, 25th, 75th, 95th, 97.5th quantiles are supplied.
Value
A nested list of summary statistics. The highest level are
$centre_spread
$quantiles
$range
$dispersion
Examples
# mean and standard deviation
create_summary_stats(mean = 5, sd = 2)
#> $mean
#> [1] 5
#>
#> $mean_ci_limits
#> [1] NA NA
#>
#> $mean_ci
#> [1] NA
#>
#> $sd
#> [1] 2
#>
#> $sd_ci_limits
#> [1] NA NA
#>
#> $sd_ci
#> [1] NA
#>
#> $median
#> [1] NA
#>
#> $median_ci_limits
#> [1] NA NA
#>
#> $median_ci
#> [1] NA
#>
#> $quantiles
#> [1] NA
#>
#> $range
#> [1] NA NA
#>
# mean and standard deviation with uncertainty
create_summary_stats(
mean = 4,
mean_ci_limits = c(2.1, 5.7),
mean_ci = 95,
sd = 0.7,
sd_ci_limits = c(0.3, 1.1),
sd_ci = 95
)
#> $mean
#> [1] 4
#>
#> $mean_ci_limits
#> [1] 2.1 5.7
#>
#> $mean_ci
#> [1] 95
#>
#> $sd
#> [1] 0.7
#>
#> $sd_ci_limits
#> [1] 0.3 1.1
#>
#> $sd_ci
#> [1] 95
#>
#> $median
#> [1] NA
#>
#> $median_ci_limits
#> [1] NA NA
#>
#> $median_ci
#> [1] NA
#>
#> $quantiles
#> [1] NA
#>
#> $range
#> [1] NA NA
#>
# median and range
create_summary_stats(
median = 5,
lower_range = 1,
upper_range = 13
)
#> $mean
#> [1] NA
#>
#> $mean_ci_limits
#> [1] NA NA
#>
#> $mean_ci
#> [1] NA
#>
#> $sd
#> [1] NA
#>
#> $sd_ci_limits
#> [1] NA NA
#>
#> $sd_ci
#> [1] NA
#>
#> $median
#> [1] 5
#>
#> $median_ci_limits
#> [1] NA NA
#>
#> $median_ci
#> [1] NA
#>
#> $quantiles
#> [1] NA
#>
#> $range
#> [1] 1 13
#>