Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add options to plot single FOI estimates and rhats #270

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

ntorresd
Copy link
Member

@ntorresd ntorresd commented Jan 8, 2025

This PR introduces parameters plot_constant and x_axis to the visualisation functions of the package. These enable the option to plot constant FOI estimates and their corresponding r-hat values, avoiding ambiguity in the specification of the x-axis by means of x_axis = "time" or x_axis = "age".

Currently, plot_seromodel() behaves differently for constant models. The single FOI estimate and its corresponging r-hat value are displayed in the summary generated by means of plot_summary(), e.g.

data("chagas2012")
seromodel <- fit_seromodel(chagas2012)
plot_seromodel(seromodel, chagas2012, bin_serosurvey = TRUE)

image

This is preserved as the default behavior, as we would have to choose arbitrarily to plot either with respect to time or age otherwise. Now, if plot_model = TRUE and a constant model is provided, the x-axis can be specified to be either age or time by means of x_axis, e.g.

plot_seromodel(
  seromodel,
  serosurvey,
  plot_constant = TRUE,
  x_axis = "time",
  bin_serosurvey = TRUE
  )

image

Exceptions for other possible scenarios are handled by the new validation function validate_plot_constant(). This function stops the process whenever plot_constant = TRUE and a non-constant model is provided, or if x_axis is not set up properly when intending to plot constant models. Informative error messages are provided in both cases.

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (1630c70) to head (5ab5576).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #270   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            6         6           
  Lines         1015      1071   +56     
=========================================
+ Hits          1015      1071   +56     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ntorresd ntorresd requested a review from zmcucunuba January 8, 2025 21:19
@ntorresd ntorresd marked this pull request as ready for review January 16, 2025 20:37
Copy link
Member

@zmcucunuba zmcucunuba left a comment

Choose a reason for hiding this comment

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

Excellent! Plot approved.

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.

3 participants