Skip to contents

Run one implemented MORIE module against CPADS data

Usage

morie_run_morie_module(
  module_name,
  cpads_csv = .cpads_default_csv(),
  output_dir = NULL
)

Arguments

module_name

Module name.

cpads_csv

Path to the CPADS CSV.

output_dir

Optional directory for CSV outputs.

Value

Named list of data-frame outputs.

Examples

# \donttest{
if (requireNamespace("rmoriedata", quietly = TRUE)) withAutoprint({
# Dispatch one MORIE module against the canonical CPADS CSV. The CSV
# ships with a morie project tree, or is fetched via the CKAN endpoint
# (morie_load_dataset("ocp21")). Wrapped in tryCatch so the example
# documents usage even when the CSV is not checked out locally.
tryCatch(
  morie_run_morie_module("descriptive-statistics"),
  error = function(e) message(conditionMessage(e))
)
})
#> > tryCatch(morie_run_morie_module("descriptive-statistics"), error = function(e) message(conditionMessage(e)))
#> Loaded ocp21 from cache (40931 rows)
#> $binomial_summaries
#>             variable     n successes     p_hat ci_low_wald ci_high_wald
#> 1    alcohol_past12m 35346     32369 0.9157755   0.9128801    0.9186708
#> 2 heavy_drinking_30d 31719     15210 0.4795233   0.4740254    0.4850213
#> 3   cannabis_any_use 40485     17037 0.4208225   0.4160134    0.4256316
#> 4         ebac_legal 22329     15041 0.6736083   0.6674580    0.6797586
#> 
#> $binomial_summaries_survey_weighted
#>             variable     p_hat          se    ci_low   ci_high
#> 1    alcohol_past12m 0.9084816 0.001817783 0.9049188 0.9120445
#> 2 heavy_drinking_30d 0.4580988 0.003333749 0.4515647 0.4646330
#> 3   cannabis_any_use 0.4088843 0.002895223 0.4032097 0.4145590
#> 4         ebac_legal 0.6499161 0.003810359 0.6424478 0.6573844
#>   n_unweighted_nonmissing
#> 1                   35346
#> 2                   31719
#> 3                   40485
#> 4                   22329
#> 
#> $probability_estimates
#>                                       quantity  estimate  ci_lower  ci_upper
#> 1                        P(cannabis_any_use=1) 0.4088843 0.4032097 0.4145590
#> 2                      P(heavy_drinking_30d=1) 0.4580988 0.4515647 0.4646330
#> 3 P(heavy_drinking_30d=1 | cannabis_any_use=1) 0.6863381 0.6772486 0.6954277
#> 4 P(heavy_drinking_30d=1 | cannabis_any_use=0) 0.2702429 0.2623296 0.2781562
#> 
# }