plot_r2: Plot (adjusted) r-squared for multiple models

View source: R/model_selection.R

plot_r2R Documentation

Plot (adjusted) r-squared for multiple models

Description

Plots regression model r-squared vs. model size (number of variables).

Usage

plot_r2(
  pve_list,
  model_names = NULL,
  line_color = "gray50",
  line_alpha = 0.5,
  line_type = "dashed",
  line_size = 1.5,
  point_color = NULL,
  palette = "Paired",
  point_alpha = 1,
  point_shape = 16,
  point_size = 5,
  label_size = 5,
  label_line_size = 0.75,
  label_line_alpha = 0.5,
  title = NULL,
  x_title = "Model complexity (no. of variables)",
  y_title = "Variance explained",
  legend_title = NULL,
  legend_position = "right",
  xlim_multiplier = 0.25,
  ylim_multiplier = 0.25
)

Arguments

pve_list

A list of lists containing regression model information. Each list must have the same element ordering, and the following elements and corresponding names are required:

  • r2: The coefficient of determination. Can be calculated using get_matrix_r2(). Value can be NA if adjusted_r2 is numeric.

  • adjusted_r2: The adjusted r2. Can be calculated using get_matrix_r2(). Value can be NA if r2 is numeric.

  • num_model_vars: The number of variables in the model used to calculate r2 and adjusted_r2.

model_names

A vector of model names that follows the same ordering as the lists in pve_list. If not provided, a sequential numbering will be used.

line_color

A string for the line color between points.

line_alpha

A numeric for the line alpha value.

line_type

A string for the line type between points.

line_size

A numeric for the line size between points.

point_color

A vector of colors corresponding to the groups of points (r2 vs adjusted r2). If not specified, default colors from a color palette will be used.

palette

A string corresponding to a color palette from which point colors are chosen.

point_alpha

A numeric for the point alpha value.

point_shape

A numeric for the point shape.

point_size

A numeric for the point size.

label_size

A numeric for the label text size..

label_line_size

A numeric for the line thickness of the guide line from the label text to its corresponding point.

title

Plot title.

x_title

X-axis title.

y_title

Y-axis title.

legend_title

Legend title.

xlim_multiplier

A numeric constant used to increase or decrease the x-axis range.

ylim_multiplier

A numeric constant used to icnrease or decrease the y-axis range.

label_line_alpha.

A numeric for the line alpha value of the guide line from the label text to its corresponding point.

Details

Creates a scatterplot showing the tradeoff between variance explained of the outcome (e.g., gene expression) and model complexity. This function is designed to be a visualization helper function for the output from get_matrix_r2. It allows for the plotting of only r2, only adjusted r2, or both.

Value

A ggplot object.

See Also

get_matrix_r2 get_residual_matrix get_design_mat


bryancquach/omixjutsu documentation built on Jan. 29, 2023, 3:47 p.m.