Skip to contents

The disparity surface varies east-west and expected total events north-south. Their lattice correlation is zero by construction. Counts are Poisson events, then unknown ethnicity is generated by binomial thinning. MCAR has a common probability, MAR varies by synthetic force, and MNAR varies by ethnicity. True latent rate ratios and complete realised event ratios are distinct.

Usage

sl_simulate(
  side = 6,
  surface = c("smooth", "discontinuous", "small"),
  population = c(White = 5000, Black = 1000),
  rate = 0.025,
  missingness = c("none", "mcar", "mar", "mnar"),
  missing_rate = 0.2,
  months = 12,
  seed = 1
)

Arguments

side

Lattice width and height, at least three.

surface

Smooth, discontinuous, or small comparison-population setting.

population

Resident reference/comparison populations per area.

rate

Mean total annual event rate per resident.

missingness

Missing-ethnicity mechanism.

missing_rate

Baseline missing probability.

months

Number of submitted months, between one and twelve.

seed

Reproducible seed, restored on exit.

Value

A list of counts, complete_counts, population, boundaries, truth and settings. Counts carry a clearly synthetic ingestion contract.

Examples

s <- sl_simulate(side = 3, missingness = "mnar", missing_rate = 0.3)
s$truth
#> # A tibble: 9 × 8
#>   geography_code force_id          x     y ratio annual_intensity rate_reference
#>   <chr>          <chr>         <int> <int> <dbl>            <dbl>          <dbl>
#> 1 SIM0001        synthetic-we…     1     1 0.899             82.3        0.0140 
#> 2 SIM0002        synthetic-ea…     2     1 2                 82.3        0.0118 
#> 3 SIM0003        synthetic-ea…     3     1 4.45              82.3        0.00871
#> 4 SIM0004        synthetic-we…     1     2 0.899            150          0.0254 
#> 5 SIM0005        synthetic-ea…     2     2 2                150          0.0214 
#> 6 SIM0006        synthetic-ea…     3     2 4.45             150          0.0159 
#> 7 SIM0007        synthetic-we…     1     3 0.899            273.         0.0463 
#> 8 SIM0008        synthetic-ea…     2     3 2                273.         0.0390 
#> 9 SIM0009        synthetic-ea…     3     3 4.45             273.         0.0289 
#> # ℹ 1 more variable: rate_comparison <dbl>
sl_missing_ethnicity_bounds(s$counts, s$population,
  scenarios = c("all_to_reference", "all_to_comparison")
)
#> sampling uncertainty: SIM0002 [0.449, 2.18]; SIM0003 [1.76, 5.37]; SIM0005
#> [0.584, 1.58]; ... see table for remaining areas
#> baseline exact Poisson intervals conditional on recorded ethnicity
#> assumption range: SIM0002 [0.714, 3.37]; SIM0003 [1.72, 7.16]; SIM0005 [0.682,
#> 3.18]; ... see table for remaining areas
#> lower_bound and upper_bound allocate all Unknown between the two groups
#> # A tibble: 18 × 15
#>    force_id       geography_code scenario      ratio unknown allocated_reference
#>    <chr>          <chr>          <chr>         <dbl>   <int>               <dbl>
#>  1 synthetic-east SIM0002        all_to_refer… 0.714      20                  20
#>  2 synthetic-east SIM0002        all_to_compa… 3.37       20                   0
#>  3 synthetic-east SIM0003        all_to_refer… 1.72       30                  30
#>  4 synthetic-east SIM0003        all_to_compa… 7.16       30                   0
#>  5 synthetic-east SIM0005        all_to_refer… 0.682      47                  47
#>  6 synthetic-east SIM0005        all_to_compa… 3.18       47                   0
#>  7 synthetic-east SIM0006        all_to_refer… 1.35       48                  48
#>  8 synthetic-east SIM0006        all_to_compa… 5.90       48                   0
#>  9 synthetic-east SIM0008        all_to_refer… 0.745      62                  62
#> 10 synthetic-east SIM0008        all_to_compa… 2.80       62                   0
#> 11 synthetic-east SIM0009        all_to_refer… 1.43       96                  96
#> 12 synthetic-east SIM0009        all_to_compa… 6.98       96                   0
#> 13 synthetic-west SIM0001        all_to_refer… 0.132      18                  18
#> 14 synthetic-west SIM0001        all_to_compa… 1.72       18                   0
#> 15 synthetic-west SIM0004        all_to_refer… 0.442      30                  30
#> 16 synthetic-west SIM0004        all_to_compa… 1.84       30                   0
#> 17 synthetic-west SIM0007        all_to_refer… 0.391      52                  52
#> 18 synthetic-west SIM0007        all_to_compa… 1.76       52                   0
#> # ℹ 9 more variables: allocated_comparison <dbl>, lower_bound <dbl>,
#> #   upper_bound <dbl>, tipping_allocation <dbl>, available <lgl>,
#> #   tipping_feasible <lgl>, observed_ratio <dbl>, conf_low <dbl>,
#> #   conf_high <dbl>