Skip to content

add-plot-model-fit#52

Merged
brianmsm merged 32 commits into
masterfrom
add-plot-model-fit
Mar 19, 2026
Merged

add-plot-model-fit#52
brianmsm merged 32 commits into
masterfrom
add-plot-model-fit

Conversation

@brianmsm

@brianmsm brianmsm commented Mar 18, 2026

Copy link
Copy Markdown
Owner
  • Added plot_model_fit dispatcher, helpers, and S3 methods to centralize validation, metric/type resolution, and default-plot selection Implemented test_mode and_model_fit_dispatch to support, type/metric resolution and thin wrappers for model_fit and_model_fit
  • Introduced new geoms and visuals: bar geom, shapes, labels, plainout geom and variant marker shapes; hid shape legend
  • Enabled multi-row comparison plotting with adaptive sizing, layout spacing, and refined axis/legend themes/colors
  • Adjusted bar layout, label spacing, tick sizes, offsets, and widths for consistent visuals
  • Exported and registered_model S3 methods
  • Added comprehensive tests and multi-row fixtures covering single-row, multi-row, and comparison plotting; tightened input/type checks
  • Fixed and refined axis specs, colors, and this change is needed
  • Provides a robust, well-tested, flexible plotting system for-fit summaries with defaults across single- and-row cases; centralizes dispatch and sizing logic to reduce duplication and edge-case errors
  • Notes reviewers- Focus review dispatcher/type-resolution logic, sizing/layout heuristics, and new geoms/ behavior
  • Tests and included to cover core behaviors and edge

brianmsm added 16 commits March 13, 2026 19:10
…o plot_model_fit and functions,

multi-row test summaries can be selected and plotted.
Introduce plot_model_fit_dispatch centralize validation,
metric resolution, and type resolution after filtering rows.
Make model_fit and compare_model_fit methods thin wrappersthat call dispatcher. Decide default plot based onrow count (bullet single-row, otherwise) and preserve-aware for comparisons.
… model_fit fixtures used by tests to validate plottingbehavior across compare and estimator-only summaries.
… compute sizes, and bar layoutdensity and pt helpers tune label and tick sizesgroup offsets and widths multi plots

@brianmsm brianmsm left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📋 Review Summary

This PR introduces a flexible, well-structured plotting system for visualizing single and multi-row model fit summaries. The implementation is comprehensive, but there are a few correctness and architectural issues that need addressing before merging.

🔍 General Feedback

  • Excellent test coverage and defensive checks around missing or non-converged metrics.
  • The ggproto objects evaluated at the top level will break package loading for users without ggplot2 installed, since it is an optional dependency.
  • Exact threshold matches (like CFI = 0.90) are currently misclassified into the lower band, which violates standard psychometric conventions.

Comment thread R/plot_model_fit-helpers.R
Comment thread R/plot_model_fit-helpers.R
@brianmsm brianmsm requested a review from Copilot March 18, 2026 22:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new plot_model_fit() plotting API to psymetrics, including centralized dispatch/validation and multiple plot styles for model_fit / compare_model_fit summaries, plus supporting metadata and documentation/site updates.

Changes:

  • Introduces plot_model_fit() generic + S3 methods, with helpers for metric/test-mode resolution and plot type defaults.
  • Persists per-row test metadata on model_fit/compare_model_fit outputs to support multi-row filtering and “primary” test selection in plotting.
  • Adds new test coverage and updates docs/pkgdown/README for the new plotting workflow and revised dependency model (ggplot2 in Imports).

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
R/plot_model_fit.R Adds exported plot_model_fit() generic + default method.
R/plot_model_fit-methods.R Implements dispatcher and the four plot styles (bullet/dots/bars/heatmap).
R/plot_model_fit-helpers.R Adds metric specs, sizing/layout heuristics, custom geoms, and data prep helpers.
R/model_fit-lavaan.R Attaches and exposes row-level test-role/primary metadata for downstream consumers.
R/compare_model_fit.R Binds per-fit metadata into the combined compare_model_fit table.
R/compare_model_estimates-methods.R Minor namespace qualification change (stats::setNames).
tests/testthat/test-plot-model-fit.R Adds comprehensive tests for defaults, styles, metric ordering, CI handling, and test_mode.
tests/testthat/test-sem-support.R Removes ggplot2 skips (now required dependency).
tests/testthat/test-plot-lavaan.R Removes ggplot2 skips (now required dependency).
tests/manual/sem_stress_lavaan.R Removes manual ggplot2 availability gating.
man/plot_model_fit.Rd New reference documentation for plot_model_fit().
man/plot_factor_loadings.Rd Updates docs/examples consistent with ggplot2 being required.
man/plot.lavaan.Rd Updates docs/examples consistent with ggplot2 being required.
DESCRIPTION Bumps version to 0.5.0; moves ggplot2 to Imports.
NAMESPACE Exports/registers plot_model_fit S3 methods.
NEWS.md Adds 0.5.0 release notes for plotting + metadata changes.
README.md / README.Rmd Adds plot_model_fit() to positioning and examples; bumps install tag to v0.5.0.
index.md Updates homepage copy, version tag, and roadmap/logo links.
_pkgdown.yml Adds plot_model_fit to reference index; reorders print-method entries.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread index.md
Comment thread index.md
Comment thread R/plot_model_fit-helpers.R Outdated
Comment thread R/plot_model_fit-helpers.R Outdated
Comment thread R/plot_model_fit-methods.R Outdated
@brianmsm brianmsm merged commit 19ee16e into master Mar 19, 2026
1 check passed
@brianmsm brianmsm deleted the add-plot-model-fit branch March 19, 2026 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants