This function can be used to visualize the results of the rank_change function, or to otherwise compare values from two different model versions or sets of estimates. This can help streamline the vetting process. All characteristics for each estimate should be matched, e.g. year, location, age. Plot_scatter creates scatter plots comparing the two sets of results. The various options for faceting or coloring the points allow the user to customize the plot to maximize utility.

plot_scatter(
  data,
  x_var,
  y_var,
  facet_x,
  facet_y = NULL,
  color_pt = NULL,
  pt_size = 1,
  title = NULL,
  facet_type = "none",
  fix_scale = FALSE
)

Arguments

data

data.frame or data.table. Data to plot comparing two sets of estimates, e.g. output of rank_change function. Required!

x_var

character() Variable to plot on the x-axis, e.g the "old" version or previous estimate. Required!

y_var

character() Variable to plot on the y-axis, e.g. the "new" version or updated estimate. Required!

facet_x

character() Variable to facet by, along x-axis. This is required in order to use facet_wrap and facet_grid. Defaults to NULL.

facet_y

character() Variable to facet by, along y-axis, if desired. This is required in order to use facet_grid. Defaults to NULL.

color_pt

character() Variable to modify color of geom_point, if desired. Defaults to NULL.

pt_size

numeric() Option to modify point size. Defaults to 1.

title

character() Title for plot, if desired. Defaults to NULL.

facet_type

character() Choice of "none", "wrap", or "grid". Defaults to "none". The "none" option will create a single plot. The "wrap" option will produce a plot using facet_wrap. The "grid" option will produce a plot using facet_grid.

fix_scale

boolean() Option to fix the axes for plot, using the min and max values. Defaults to FALSE. Will override scales = "free".

Value

A ggplot object

Examples

plot_scatter(trend_changes_USA, x_var = "old_mean", y_var = "new_mean", facet_x = "ihme_loc_id", pt_size = 2, facet_type = "wrap", fix_scale = TRUE, color_pt = "year_id")