Skip to contents

This function returns a summary statistics tibble. It will use the y column from the tidy_ distribution function.

Usage

tidy_distribution_summary_tbl(.data, ...)

Arguments

.data

The data that is going to be passed from a a tidy_ distribution function.

...

This is the grouping variable that gets passed to dplyr::group_by() and dplyr::select().

Value

A summary stats tibble

Details

This function takes in a tidy_ distribution table and will return a tibble of the following information:

  • sim_number

  • mean_val

  • median_val

  • std_val

  • min_val

  • max_val

  • skewness

  • kurtosis

  • range

  • iqr

  • variance

  • ci_hi

  • ci_lo

The kurtosis and skewness come from the package healthyR.ai

Author

Steven P. Sanderson II, MPH

Examples

library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union

tn <- tidy_normal(.num_sims = 5)
tb <- tidy_beta(.num_sims = 5)

tidy_distribution_summary_tbl(tn)
#> # A tibble: 1 × 12
#>   mean_val median_val std_val min_val max_val skewness kurtosis range   iqr
#>      <dbl>      <dbl>   <dbl>   <dbl>   <dbl>    <dbl>    <dbl> <dbl> <dbl>
#> 1   0.0462     0.0747   0.966   -2.82    2.80   0.0744     3.12  5.61  1.29
#> # ℹ 3 more variables: variance <dbl>, ci_low <dbl>, ci_high <dbl>
tidy_distribution_summary_tbl(tn, sim_number)
#> # A tibble: 5 × 13
#>   sim_number mean_val median_val std_val min_val max_val skewness kurtosis range
#>   <fct>         <dbl>      <dbl>   <dbl>   <dbl>   <dbl>    <dbl>    <dbl> <dbl>
#> 1 1            0.200      0.120    0.928   -2.29    2.38    0.142     3.21  4.67
#> 2 2           -0.0698    -0.0932   0.868   -2.82    1.53   -0.422     3.55  4.35
#> 3 3           -0.0250     0.0539   0.869   -2.25    1.97   -0.141     2.92  4.22
#> 4 4           -0.0324    -0.120    1.17    -2.13    2.80    0.542     2.93  4.93
#> 5 5            0.158      0.299    0.969   -1.93    2.29   -0.264     2.58  4.22
#> # ℹ 4 more variables: iqr <dbl>, variance <dbl>, ci_low <dbl>, ci_high <dbl>

data_tbl <- tidy_combine_distributions(tn, tb)

tidy_distribution_summary_tbl(data_tbl)
#> # A tibble: 1 × 12
#>   mean_val median_val std_val min_val max_val skewness kurtosis range   iqr
#>      <dbl>      <dbl>   <dbl>   <dbl>   <dbl>    <dbl>    <dbl> <dbl> <dbl>
#> 1    0.294      0.393   0.754   -2.82    2.80   -0.662     4.67  5.61 0.757
#> # ℹ 3 more variables: variance <dbl>, ci_low <dbl>, ci_high <dbl>
tidy_distribution_summary_tbl(data_tbl, dist_type)
#> # A tibble: 2 × 13
#>   dist_type mean_val median_val std_val  min_val max_val skewness kurtosis range
#>   <fct>        <dbl>      <dbl>   <dbl>    <dbl>   <dbl>    <dbl>    <dbl> <dbl>
#> 1 Gaussian…   0.0462     0.0747   0.966 -2.82      2.80    0.0744     3.12 5.61 
#> 2 Beta c(1…   0.543      0.577    0.290  0.00230   0.999  -0.190      1.75 0.996
#> # ℹ 4 more variables: iqr <dbl>, variance <dbl>, ci_low <dbl>, ci_high <dbl>