Plot displacement diagnostics using base R
Arguments
- x
Output from
fit_mfrm()ordisplacement_table().- diagnostics
Optional output from
diagnose_mfrm()whenxismfrm_fit.- anchored_only
Keep only anchored/group-anchored levels.
- facets
Optional subset of facets.
- plot_type
"lollipop"or"hist".- top_n
Maximum levels shown in
"lollipop"mode.- show_ci
Logical. When
TRUEandplot_type = "lollipop", draw approximate confidence-interval whiskers fromDisplacementSE(ignored for"hist").- ci_level
Confidence level used when
show_ci = TRUE; default0.95. The returned plot-data object gainsCI_Lower/CI_Upper/CI_Levelcolumns on thetableelement for downstream reuse.- preset
Visual preset (
"standard","publication","compact", or"monochrome").- draw
If
TRUE, draw with base graphics.- ...
Additional arguments passed to
displacement_table()whenxismfrm_fit.
Details
Displacement quantifies how much a single element's calibration would shift the overall model if it were allowed to move freely. It is computed as:
$$\mathrm{Displacement}_j = \frac{\sum_i (X_{ij} - E_{ij})} {\sum_i \mathrm{Var}_{ij}}$$
where the sums run over all observations involving element \(j\). The standard error is \(1 / \sqrt{\sum_i \mathrm{Var}_{ij}}\), and a t-statistic \(t = \mathrm{Displacement} / \mathrm{SE}\) flags elements whose observed residual pattern is inconsistent with the current anchor structure.
Displacement is most informative after anchoring: large values suggest that anchored values may be drifting from the current sample. For non-anchored analyses, displacement reflects residual calibration tension.
Plot types
"lollipop"(default)Dot-and-line chart of displacement values. X-axis: displacement (logits). Y-axis: element labels. Points colored red when flagged (default: \(|\mathrm{Disp.}| > 0.5\) logits). Dashed lines at \(\pm\) threshold. Ordered by absolute displacement.
"hist"Histogram of displacement values with Freedman-Diaconis breaks. Dashed reference lines at \(\pm\) threshold. Use for inspecting the overall distribution shape.
Interpreting output
Lollipop: top absolute displacement levels; flagged points indicate larger movement from anchor expectations.
Histogram: overall displacement distribution and threshold lines. A symmetric distribution centred near zero indicates good anchor stability; heavy tails or skew suggest systematic drift.
Use anchored_only = TRUE when your main question is anchor robustness.
Typical workflow
Run with
plot_type = "lollipop"andanchored_only = TRUE.Inspect distribution with
plot_type = "hist".Drill into flagged rows via
displacement_table().
Further guidance
For a plot-selection guide and a longer walkthrough, see
mfrmr_visual_diagnostics and
vignette("mfrmr-visual-diagnostics", package = "mfrmr").
Session plot defaults
Set options(mfrmr.plot_preset = "publication") to choose a session default
for plotting functions that expose the common preset argument. The
supported values are "standard", "publication", "compact" and
"monochrome". Precedence is an explicit call argument, then the session
option, then "standard". For example, preset = "standard" overrides
a session set to "monochrome". Explicit preset = NULL retains the
earlier package-default behavior; it does not read the session option.
Invalid session values cause an error only when that option is needed.
The category-curve, data-quality, fit-review, connectivity and network
routes of plot() for report bundles use the same option through ....
Plots without a common preset argument, including extended-model plots
with their own palette controls, keep their own settings. This option
selects a preset, not a universal theme or a guarantee that all renderers
implement every appearance control identically.
New plot payloads retain the resolved preset for supported saved-data
rendering. Converting an existing payload with as_ggplot() uses its saved
appearance, even after the session option changes. A call that creates a
new plot from a fit or statistical result uses the current default.
For a reproducible script, supply preset explicitly or set the option in
that script. Saving only the fitted model does not save a session option.
No global ggplot theme is changed.
Restore previous settings with old <- options(mfrmr.plot_preset = "monochrome") followed by options(old). Use
options(mfrmr.plot_preset = NULL) to remove the option. The preset changes
appearance, not estimates, confidence levels or diagnostic thresholds.
Examples
# \donttest{
toy <- load_mfrmr_data("example_core")
fit <- fit_mfrm(toy, "Person", c("Rater", "Criterion"), "Score", method = "JML", maxit = 300)
p <- plot_displacement(fit, anchored_only = FALSE, draw = FALSE)
if (interactive()) {
plot_displacement(
fit,
anchored_only = FALSE,
plot_type = "lollipop",
preset = "publication"
)
}
# }
