inst/references/CODE_READING_GUIDE.md

Code Reading Guide (for Human Developers)

This guide is written for intermediate R users who want to understand and modify mfrmr.

1) Start here: public API

Read /R/api.R first.

If you only need to use the package, you can stop at api.R + the vignettes.

2) Core estimation flow

Core numeric logic is in /R/mfrm_core.R.

mfrm_estimate() is intentionally structured in five stages:

  1. normalize inputs and model options
  2. resolve facet/model configuration
  3. build optimization structures
  4. run optimization (JMLE or MML)
  5. convert optimized parameters to readable tables

Helper functions around mfrm_estimate() are separated so each stage can be debugged independently.

3) Data assumptions

Input data is long format (one row = one rating event).

Required columns at runtime:

Packaged example datasets can be loaded via data() or load_mfrmr_data().

4) Diagnostics flow

Diagnostics are computed in mfrm_diagnostics() (/R/mfrm_core.R).

Key components:

5) Reporting flow

Text/report builders live in /R/reporting.R.

6) Sign conventions

Facet orientation is controlled by positive_facets.

This sign map is used consistently when converting between logits, fair averages, and report values.

7) Where to edit safely

If you need to change behavior:

After changes, always run:

  1. Rscript -e 'testthat::test_dir("mfrmr/tests/testthat")'
  2. R CMD build mfrmr
  3. R CMD check --no-manual mfrmr_0.1.0.tar.gz


Try the mfrmr package in your browser

Any scripts or data that you put into this service are public.

mfrmr documentation built on March 31, 2026, 1:06 a.m.