R-MORIE (Multi-domain Open Research and Inferential Estimation) is an R package for causal inference, sampling, psychometrics, point-process modeling, and criminological accountability analysis, with no Python dependencies.
Applied observational research on Canadian carceral, policing, and
oversight data usually means stitching together a dozen single-purpose
packages — one for difference-in-differences, one for propensity-score
matching, one for spatial scan statistics, one for self-exciting point
processes — each with its own data contract, and none aware of the
survey-weighting, provenance, and privacy constraints these data carry.
rmorie is for criminologists, quantitative social scientists, and
accountability researchers who need those estimators in one consistent,
provenance-preserving toolkit, with the MRM (Multilevel Reconciliation
Methodology) framework as its motivating application. Every public
function is prefixed morie_* so it composes safely alongside the
specialist packages it wraps, and results carry the labeling that keeps
synthetic development runs from being mistaken for inferential findings.
Primary methodological references for each estimator family are listed
in the package-level help (?rmorie).
morie_* functions, one searchable doc):
https://rootcoder007.r-universe.dev/rmorie/doc/manual.html
morie_llm_ask() and rmorie ask use the model you set up through rmoriebricklayer: a provider's key (OpenAI, Anthropic, Google Gemini, OpenRouter, Groq, Mistral and more, each from its usual variable), an OpenAI-compatible server of your own, or a local Ollama (ollama.com cloud models need an Ollama key). The model reads the help of rmorie, rmoriedata and rmoriebricklayer. rmorie config setup walks through it.With over 13,000 exported functions, the full reference is large — use the manual or the package site above rather than scrolling the function index. This README covers install + the most common workflows only.
rmorie is a self-contained research toolkit: every statistical algorithm in the package — matching (nearest-neighbour, Mahalanobis, exact, CEM, optimal, genetic, cardinality), design-based IPW and doubly-robust estimation, double machine learning, causal forests and meta-learners, causal DAGs with identification and refutation, the full quasi-experimental family (DiD incl. Callaway-Sant'Anna, event studies, synthetic control and synthetic DiD, RDD, interrupted time series, IV), item-response theory, geostatistics, digital signal processing, Hawkes processes, cryptographic hashing with post-quantum primitives, and the data-access parsers — is implemented natively in this package's R and C++. rmorie does not call MatchIt, survey, DoubleML, grf, dagitty, did, fixest, rdrobust, ivreg, psych, gstat, spdep, signal, wavelets, digest, or openssl at runtime. This means:
tests/cross/ against its reference package —
to machine precision where the estimand is deterministic (see the
table below) — and benchmarked in inst/benchmarks/.print(),
summary(), and reporting methods; the phase-17 composition test
runs DAG -> identification -> matching -> DML -> refutation ->
publication table end to end in one suite.morie_safe_recode(),
morie_safe_factor(), morie_audit_categories(), and
morie_crosstab_verify() make the silent category-mapping errors
that have corrupted published disparity analyses structurally
impossible in an rmorie workflow.Packages in Suggests play three roles, and no others:
tests/cross/. The packages the
native engines replace (table below) are loaded only by the
cross-validation tests; an installed copy never changes a result.morie_geostat_variogram() / morie_geostat_krige() (gstat),
morie_copula_*() (copula), morie_kernel_pca() /
morie_spectral_cluster() (kernlab), morie_meta_rma() (metafor),
morie_mvnorm_*() (mvtnorm), morie_causal_impact() (CausalImpact),
and morie_causal_weighting() for a weighting method without a
native engine (WeightIt). The native counterparts are
morie_spatial_variogram(), morie_spatial_krige(),
morie_meta_random_effects(), morie_weight_*() and so on..xls
workbooks (readxl). A function
that needs one says which, and how to install it, when it is
missing.| Family | Replaces | Validation |
|---|---|---|
| Matching (10 methods: nearest, variable ratio, exact, CEM, Mahalanobis, optimal pair, optimal full, subclass, genetic, cardinality) | MatchIt, optmatch, Matching, designmatch | pair-identical (nearest, variable ratio, subclass) or the optimum itself (optimal, full) |
| IPW / design-based mean + GLM (strata, clusters, fpc) | survey | svymean / svyglm estimates + SEs to 1e-12 |
| DML (PLR + IRM) | DoubleML/mlr3 | CI-overlap agreement; 40-60x faster |
| Causal forest / meta-learners | grf | CATE agreement; 1.5-2.9x faster |
| DAG identify/estimate/refute | dagitty, DoWhy | adjustment sets == dagitty on every graph tested |
| DiD family (TWFE/event/CS/DR/Bacon/DID-M/feTR) | fixest, did, DRDID, bacondecomp, DIDmultiplegt, TwoWayFEWeights | coefficients, SEs, and influence functions to 1e-8-1e-10 |
| Synth control + SDID | Synth/coresynth | recovers simulated truths; placebo inference built in |
| RDD (IK bw, sharp/fuzzy/kink, McCrary) | rdrobust, rdd | point estimates == rdrobust at fixed h to 1e-8 |
| IV (2SLS/LIML/GMM) + ITS | AER, ivreg, gmm | 2SLS == ivreg + sandwich HC1 to 1e-8 |
| IRT (2PL/GRM/EAP) + psychometrics | psych, mirt | KMO == psych to 1e-8; 2PL vs mirt within 0.1 |
| Geostatistics (variogram/kriging) | gstat, spdep | kriging == gstat to 1e-6; Moran variance == spdep |
| DSP (Butterworth/FIR/Welch/DWT) | signal, wavelets | butter coefficients == signal to 1e-8; DWT perfect reconstruction |
| Hawkes MLE | hawkes | exponential-kernel loglik == hawkes |
| SHA-256/HMAC/PBKDF2 + PQC | digest, openssl | NIST FIPS + RFC vectors bit-for-bit; ML-KEM/ML-DSA/SLH-DSA/HQC via liboqs |
| Parsers (JSON/XML/HTML/Parquet) | jsonlite, xml2, arrow | jsonlite-parity outputs; accelerators optional |
| Weighting family (ps/entropy/CBPS/OW/stabilized/SuperLearner) | WeightIt, CBPS | glm weights == WeightIt to 1e-8; CBPS moments < 1e-6 |
| Modern staggered DiD (Sun-Abraham/Borusyak/did2s) | did2s, didimputation | point estimates within 0.02 of did2s |
| Unified front-ends (morie_did/morie_iv_2sls/morie_rdd) | did, AER, rdrobust | CS overall == did::aggte to 0.1; 2SLS == ivreg to 1e-6 |
| Crim methods (ETAS/multivariate Hawkes/Knox/RTM) | (papers) | recovers simulated truths; Knox permutation calibrated |
rmorie is not a wrapper. At runtime it does not call:
morie_matching_*
morie_weight_*
morie_ipw_* / morie_ebac_*
morie_dag_*
morie_did_* with auto-dispatch to Callaway-Sant'Anna, Sun-Abraham, Borusyak, and Gardner two-stagemorie_rdd (IK bandwidth + McCrary + placebo cutoffs bundled)morie_synth_control with built-in placebo inferencemorie_iv_2sls with the Staiger-Stock refusal gatemorie_psymet_* and morie_irt_*
rgfir/rgiir/rgwav and morie_dsp_*
morie_crim_etas / morie_crim_hawkes_multivariate
morie_fetch_* native parsers and the package's own .xlsx reader (those packages remain optional fast paths; readxl is needed only for the old binary .xls format)Those packages appear in Suggests so that tests/cross/ can prove,
on every CI run, that the native engines match them; the named
pass-throughs and integrations listed above are the only other uses of
Suggests.
Everything since 1.3.4, in one place; NEWS.md has the release-by-release detail.
morie_* entry
points (13,655 exports in all), each with a test that recomputes its value,
and the same names in the Python package morie, checked against each other
in CI.research/, implemented as package functions with Lean 4 proofs of the
identification results (264 theorems, 0 sorry): DerSimonian-Laird pooling,
separation in a logistic fit, Imbens-Manski intervals for partially
identified sentencing effects, the Cheeger bound on a hot-spot boundary,
Duncan-Davis bounds, monotone treatment selection, near-repeat extinction,
judge-leniency designs, the Oaxaca-Blinder decomposition, Little's law on a
docket and the incapacitation identity. The Python package carries every
research function at parity.morie_dag*
toolkit, cross-validated against MatchIt, DoubleML, grf and dagitty.install_cli() puts rmorie on your PATH,
with every verb of the Python command line: login, doctor, models,
ask, analyze, list-modules, run-module, list-datasets, pull,
provider, cheatsheet, selftest, pipeline, emissions,
verify-pollution, crypto, ingest. It runs under R 4.6.rmorie login signs in with
GitHub or an emailed code, or ask at https://rmorie.com/access; the terms are
at https://rmorie.com/data-license, and the ICPSR, NCVS 38604 and a2aj tables
open once you accept theirs at https://data.rmorie.com/terms;
built-in datasets come through
rmoriedata (r-universe), fetched with provenance by rmoriebricklayer
(r-universe); module runs fall back to
rmoriedata's synthetic CPADS PUMF.morie_capsule_write(), morie_capsule_verify(), morie_capsule_sign(),
morie_capsule_bundle(), morie_capsule_drift(), morie_capsule_manifest() and
morie_capsule_compare() pin, check, sign and re-check a CSV through rmoriebricklayer
(vignette capsules). Their twins in morie (Python) are morie.capsule.write() and so on:
the same words name the same things: write/verify/sign/bundle/drift/manifest/compare
take the same arguments and defaults, return the same fields, and verification gives the same
check rows (those of rmoriebricklayer::vrfcps()). The deliberate differences: morie signs with
hmac (a shared secret) only, so its sign() and bundle() have no context, prehash or
deterministic (rmorie also signs with ML-DSA, SLH-DSA and XMSS keys); rmorie's results checks
are a data frame, morie's a list of dicts; rmorie's drift takes the capsule directory (dir) and
a data frame or CSV as current, morie's takes ref (a capsule directory or a CSV) and a CSV;
rmorie pins only a CSV, morie any file (a row count for a CSV); morie also has load, pin,
record, canon, digest and the attestation helpers, which in R are rmoriebricklayer's own
(loadprov(), recrd(), mnfcanon(), mnfdgst(), cpsatst()); and the command line
morie capsule init|pin|verify|sign|drift exits 0 (verified, no drift), 1 (a check failed or
drift) or 2 (an error), where the R functions return a result with $ok (or $anydrft) and
stop on an error.agent() to call the rmorie CLI
agent from R (agent_available() probes for it).From r-universe (prebuilt binaries for macOS and Windows, a source build on Linux). Its companions, rmoriebricklayer >= 1.0.0 and rmoriedata >= 0.4.0, come from r-universe too: CRAN carries older versions. Naming them replaces an older copy already installed.
With pak (progress bars, parallel downloads, compiler output hidden unless a build fails, and the named packages always upgraded to the current release):
if (!requireNamespace("pak", quietly = TRUE)) {
install.packages("pak", repos = "https://cloud.r-project.org")
}
pak::repo_add(rootcoder007 = "https://rootcoder007.r-universe.dev")
pak::pkg_install(c("rmoriebricklayer", "rmoriedata", "rmorie"))
# want every optional package too, in one shot? add dependencies = TRUE
# (large: compiles many specialist packages; see "Optional packages" below)
pak::pkg_install("rmorie", dependencies = TRUE)
From a terminal (single quotes outside, double quotes inside, so the shell passes the R code through untouched):
Rscript -e 'if (!requireNamespace("pak", quietly = TRUE)) install.packages("pak", repos = "https://cloud.r-project.org"); pak::repo_add(rootcoder007 = "https://rootcoder007.r-universe.dev"); pak::pkg_install(c("rmoriebricklayer", "rmoriedata", "rmorie"))'
Without pak, plain install.packages() does the same with R's own output. Keep
repos: under Rscript there is no mirror chooser, and a bare call stops with
"trying to use CRAN without setting a mirror".
Rscript -e 'install.packages(c("rmoriebricklayer", "rmoriedata", "rmorie"), repos = c("https://rootcoder007.r-universe.dev", "https://cloud.r-project.org"))'
From GitHub (a source build; needs a C/C++ toolchain):
Rscript -e 'if (!requireNamespace("pak", quietly = TRUE)) install.packages("pak", repos = "https://cloud.r-project.org"); pak::repo_add(rootcoder007 = "https://rootcoder007.r-universe.dev"); pak::pkg_install("rootcoder007/rmorie")'
# without pak
Rscript -e 'repos <- c("https://rootcoder007.r-universe.dev", "https://cloud.r-project.org"); install.packages("remotes", repos = repos); remotes::install_github("rootcoder007/rmorie", repos = repos, upgrade = "always")'
From a clone, at the repository root:
pak::repo_add(rootcoder007 = "https://rootcoder007.r-universe.dev")
pak::local_install()
# without pak
install.packages(c("rmoriebricklayer", "rmoriedata"),
repos = c("https://rootcoder007.r-universe.dev", "https://cloud.r-project.org"))
install.packages(".", repos = NULL, type = "source")
On macOS, CRAN's R (from https://cloud.r-project.org/bin/macosx/) installs r-universe's prebuilt binaries in seconds. Homebrew's R cannot use them, so there every package is compiled from source.
The assistant (morie_llm_ask()) asks the model you bring (a provider's key,
your own OpenAI-compatible server, or a local Ollama; see Ask a model and sign
in), and falls back to a keyword answer that needs no network.
pip install pkg[extra])The base install is complete for every statistical workflow — the
native engines need nothing beyond the hard dependencies. Suggests
entries are (a) reference packages used only by the cross-validation
tests in tests/cross/, and (b) optional accelerators (e.g.
jsonlite/xml2/arrow fast paths for the parsers, ML backends). Every
optional-path function tells you what to install when it's missing,
and the test suite skips (never fails) without them. To provision the
extras up front:
# install every optional package rmorie can use (one-time, ~15 min)
morie_install_extras(which = "all", ask = FALSE)
# or just what's missing, interactively
morie_install_extras()
# or a specific family, e.g. machine learning
morie_install_extras(which = c("randomForest", "glmnet", "xgboost",
"ranger", "caret", "pROC"))
Common families: ML (randomForest, glmnet, xgboost/gbm,
ranger, caret, pROC, Rtsne, e1071, dbscan), DSP
(signal, pracma, wavelets), causal (DoubleML, mlr3,
mlr3learners, ivreg, fixest), storage (RSQLite, duckdb).
morie_llm_ask() asks the model you set up, through rmoriebricklayer, in its
automatic order: your own OpenAI-compatible endpoint, then each provider whose
key is set (OPENAI_API_KEY, ANTHROPIC_API_KEY, GEMINI_API_KEY,
OPENROUTER_API_KEY, GROQ_API_KEY, ...), then a local Ollama. Nothing is
hosted for you, and no prompt goes anywhere you did not set up. The model gets
the help of rmorie, rmoriedata and rmoriebricklayer, with tools to search and
read it; with no model set up, the answer comes from a keyword index.
The sign-in is for the curated tables only: a personal key for
data.rmorie.com, which the Python package morie reads too.
morie_llm_config(route = "anthropic") # with ANTHROPIC_API_KEY set; rmoriebricklayer::llmprvd() lists them
morie_llm_provider_set("http://localhost:1234/v1", model = "local-model") # your own server (LM Studio, vLLM, llama.cpp)
morie_llm_ask("Which design fits a pre/post comparison with a control group?")
morie_llm_login() # the data key: GitHub sign-in
morie_llm_login(email = "you@example.com") # an emailed code instead
morie_llm_login(token = "sk-...") # a key you were given
morie_hosted_datasets() # curated db/table keys
df <- morie_load_hosted_dataset("chicago_crime/incidents")
morie_llm_logout()
From the shell, after install_cli():
rmorie config setup # pick a provider, paste its key, choose a model
rmorie models # the models your route offers
rmorie ask "What does the power-design module compute?"
rmorie doctor # which route ask takes from this machine
rmorie login # the data key: GitHub sign-in
rmorie login --email you@example.com # an emailed code instead: type it at the prompt
rmorie login --no-browser # server / SSH: prints a link + code to open on any device
rmorie login --token # paste a key you were given
library(rmorie)
# a project that keeps data/manifest/outputs_manifest.csv (morie_build_outputs_manifest() writes one)
manifest <- morie_read_outputs_manifest(project_root = "/path/to/project")
audit <- morie_audit_public_outputs(project_root = "/path/to/project",
manifest = manifest)
morie_summarize_output_audit(audit)
library(rmorie)
synthetic_path <- morie_write_synthetic_data(
path = "data/private/synthetic_study_data.csv",
n = 8000,
seed = 2026,
overwrite = TRUE
)
library(rmorie)
name_map <- morie_default_synthetic_name_map("generic")
name_map["cannabis_use"] <- "exposure_any"
name_map["bac"] <- "outcome_continuous"
dat <- morie_generate_synthetic_data(
n = 5000,
seed = 1,
name_map = name_map
)
rmorie ships the first open-source parser and data-mining subsystem for the Ontario Special Investigations Unit (SIU) director's-report corpus — created by Vansh Singh Ruhela as part of the MORIE / R-MORIE ecosystem and the MRM (Multilevel Reconciliation Methodology) framework. To our knowledge no prior public, open-source SIU director's-report parser or automated SIU data-mining engine existed in Canada; the SIU publishes the reports, but there was no programmatic pipeline to fetch, parse, and analyse them at corpus scale until this one.
A first-class subsystem for the Ontario Special Investigations Unit director's-report corpus. The fetcher handles both English and French templates from 2005 onward across all three of the site's historical layout generations (pre-2017 Attorney-General releases, the 2017-2019 transitional format, and the post-2019 SIU Act template); the parser extracts the report fields (police service, incident/notification/ decision dates, investigator and witness/subject-official counts, affected-person demographics, injuries, legislation, charges verdict, and director's decision) and is hand-rolled for correctness under SIU's heterogeneous markup.
Since 1.1.4 the subsystem is layered on the compiled SIU core in
'rmoriebricklayer' and the verified corpus shipped by
'rmoriedata' (0.3.4): a 66-column table of 4,613 reports, 2,309 English and
2,304 French, whose English entries were read and cross-audited by a multi-agent
review panel (a French report carries its English report's reviewed case facts)
(every subject-official count verified; the mechanical resolver
scores zero wrong against it). morie_siu_reports() returns that
corpus verbatim and only ever fetches/parses reports newer than it;
morie_siu_resolve_so(report_text) resolves the subject-official count
from a report's text, the verified corpus first, then the compiled rule engine; morie_siu_panel() runs the
same Mixture-of-Agents reading panel on new reports through any
Ollama-compatible endpoint you point it at (your models, your host —
no hardcoded default).
The subsystem powers downstream MRM analyses — Hawkes self-exciting point processes, causal estimators, fairness audits, and the physics- of-crime modules — on Canadian police-oversight data.
Key entry points: morie_siu_reports(), morie_siu_resolve_so(),
morie_siu_panel(), morie_siu_parse_report(), plus the legacy
fetch path morie_fetch_siu(), morie_siu_index_url(),
morie_siu_refresh_manifest(), morie_siu_audit_case(),
morie_siu_sanity_check(), morie_siu_all_analyses().
library(rmorie)
# Prefer the panel-verified corpus (4,613 reports x 66 columns, 2,309 English
# entries human+multi-agent reviewed, French rows carrying their facts) — no re-fetching:
df <- morie_siu_reports(update = FALSE)
# The legacy live fetch remains available:
# df <- morie_fetch_siu(lang = "en", cache_html = TRUE, rate_limit = 4)
nrow(df)
# Inspect parser row + raw HTML + cleaned text side-by-side.
morie_siu_audit_case("17-OVI-201")
# Per-field "does the HTML actually support this value?" check.
morie_siu_anomaly_check("17-OVI-201")
# Diff parser output against an external table.
# field_map maps the external table's columns to parser fields; external_case_col names its case column
morie_siu_compare(
case_number = "17-OVI-201",
external = my_other_table, # e.g. data.frame(case_number = "17-OVI-201", n_officers = 2L)
field_map = list(n_officers = "number_of_officers_involved"),
external_case_col = "case_number"
)
# Default: local Ollama with gemma3:4b. No API key required.
morie_siu_llm_extract("17-OVI-201")
# An explicit chain: local first, then the model you set up for rmoriebricklayer (`route`), then Gemini.
morie_siu_llm_extract("17-OVI-201", model = c("ollama", "route", "gemini"))
# French to English translation of the cached reports (field by field, via the local model).
morie_siu_translate(target_lang = "en", case_numbers = "26-OCI-168")
Supported providers: ollama (default), route (the model you set up: a provider's key or your own server; a provider id such as anthropic or groq names one), gemini, claude, vertex,
openai, openai_compatible. Environment knobs: OLLAMA_HOST (defaults to http://localhost:11434),
OLLAMA_MODEL (defaults to gemma3:4b), OLLAMA_KEEP_ALIVE (30m), GEMINI_API_KEY.
df <- morie_siu_reports() # the reviewed corpus, from rmoriedata (r-universe)
sane <- morie_siu_sanity_check(df) # one row per report, with its format issues (if any)
table(sane$issues_count > 0) # regex / ISO date / yes-no / chrome leak; older reports leave many fields blank
head(sane$issues[sane$issues_count > 0], 3)
# How accurate is each column across a sample of cases?
df <- morie_siu_reports()
morie_siu_audit_columns(case_numbers = sample(df$case_number[nzchar(df$case_number)], 50))
The parser learns. Ship-time corrections live in
inst/extdata/siu_canonical_overrides.csv.gz (47 hand-verified
corrections covering 10 spot-checked cases). Users can add their own:
morie_siu_record_correction(
case_number = "20-OFD-082",
field = "number_of_officers_involved",
verified_value = "3 SO"
)
Overrides are applied automatically at the end of morie_fetch_siu(),
per cell, by case number.
manifest <- morie_siu_index()
table(manifest$`_language`) # en=2532, fr=2217, other=0
The R CMD check matrix covers six cells, all green on main:
| Platform | R version |
|---|---|
| macos-latest | release |
| windows-2025 | release |
| ubuntu-latest | release |
| ubuntu-latest | release + postgres-15 |
| ubuntu-latest | oldrel-1 |
| ubuntu-latest | devel |
Plus: pkgcheck, covr + Codecov upload, lintr, goodpractice, and
CodeQL.
If you use rmorie in your research, please cite the software:
Ruhela, V. S. (2026). rmorie: Multi-domain Open Research and Inferential Estimation in R. R package version 1.5.1. https://rootcoder007.r-universe.dev/rmorie
BibTeX (or run citation("rmorie") after installation for the entry
stamped with the exact installed version, sourced from inst/CITATION):
@Manual{ruhela_rmorie_2026,
title = {rmorie: Multi-domain Open Research and Inferential Estimation in R},
author = {Ruhela, Vansh Singh},
year = {2026},
url = {https://rootcoder007.r-universe.dev/rmorie}
}
See CITATION.cff
for the machine-readable metadata GitHub's "Cite this repository" button uses.
R-MORIE is licensed under AGPL-3.0-or-later. See LICENSE for the
full text and LICENSING.md for the per-component breakdown.
rmorie's Bayesian regression (morie_bayes_lm) places zero-mean Normal
priors on the regression coefficients; the prior_sd argument is the
prior standard deviation (the scale of plausible coefficient values).
Larger prior_sd is weakly informative; smaller values pull estimates
toward zero (regularisation). Example:
d <- data.frame(x = rnorm(100)); d$y <- 1 + 2 * d$x + rnorm(100)
# weakly-informative prior (sd = 10) vs a tight regularising prior (sd = 0.5)
fit_weak <- morie_bayes_lm(y ~ x, d, prior_sd = 10)
fit_tight <- morie_bayes_lm(y ~ x, d, prior_sd = 0.5)
See the bayesian-priors vignette for applied guidance.