Skip to content

Add Support for Overlaying Stratified Marginal Curves in plot_predicted_curve() #128

@Kwan-Jenny

Description

@Kwan-Jenny

Description:

Summary:
This issue proposes extending the plot_predicted_curve() function to overlay marginal (“new person”) model predictions for different strata (e.g., age groups) in the same panel. This will improve visualization of stratified model fits from SRM outputs.

Motivation:

  • Current implementation only supports conditional (individual-level) predictions.

  • Comparing marginal model fits across strata (e.g., <5 vs ≥5 years) on the same plot would help assess group-level differences in antibody kinetics.

  • Suggested by Sam and supported by Kristen and Ezra during the 07.30.2025 meeting.

Proposed Features:

  • Overlay median marginal curves for each stratum using different colors or line types.

  • Optionally overlay observed individual data in the background (optional).

  • Ensure compatibility with stratified SRM outputs (i.e., one new_person per stratum).

  • Maintain current behavior when no stratification is used.

Implementation Notes:

  • Separate logic for:

    • Observed data (optional)

    • Marginal predicted values from new_person

  • Add new arguments to control stratified marginal overlay (e.g., strat_overlay = TRUE)

  • Reuse logic from serocalculator or internal helpers to minimize duplication

Development Plan:

Metadata

Metadata

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions