Skip to contents

`sim` is a single exported object that bundles several simulation generators useful for testing the package's estimators under MCAR / MAR missingness. Exposed as a list of closures so the manual is not flooded by individual function pages.

Available members:

- `sim$mcar(n, R, C, p, p_missing, seed = NULL)`: simulate an n x R matrix of integer ratings (categories `1..C`) with marginal distribution `p` (length C), then drop entries independently per cell with probability `p_missing` (scalar or length R). Returns the incomplete matrix with the underlying complete matrix as the `"complete"` attribute.

- `sim$mar_truth(n, R, C, p, pi_truth, seed = NULL)`: like `mcar` but the per-cell missingness probability depends on the unobserved truth category; `pi_truth` is a length-C vector of missing probabilities, one per category. MAR via the underlying truth.

- `sim$jsm(n, s, model, true_dist, guessing_dist)`: port of the legacy `simulate_jsm()` skill-difficulty guessing simulator. See the legacy docs for details. Returns the simulated rating matrix with `"kappa"` (true latent agreement) attached.

All generators accept a `seed` argument; if non-NULL it is passed to `set.seed()` before sampling.

Usage

sim

Examples

# Simulate MCAR categorical ratings (200 subjects, 3 raters, 4 categories,
# 15% missing per cell) and estimate kappa on the incomplete matrix.
x <- sim$mcar(n = 200, R = 3, C = 4, p = c(0.4, 0.3, 0.2, 0.1),
              p_missing = 0.15, seed = 1)
kappa(x, estimator = "ipw")
#> misskappa: estimator=ipw, weight=nominal
#>                  estimate     se   lower  upper
#> Conger             0.0025 0.0297 -0.0556 0.0606
#> Fleiss            -0.0022 0.0300 -0.0610 0.0565
#> Brennan-Prediger   0.0708 0.0307  0.0107 0.1310

# The underlying complete matrix is kept as an attribute for comparison.
dim(attr(x, "complete"))
#> [1] 200   3