Learn R Programming

setweaver (version 1.0.0)

plot_prob: plot_prob

Description

Creates a network-style graph showing how a set of predictors (`x_vars`) are related to an outcome (`y_var`). Relationships can be displayed either as conditional probabilities or as effects estimated by logistic regression.

Usage

plot_prob(
  data,
  y_var,
  x_vars,
  var_labels = NULL,
  prob_digits = 2,
  method = "conditional",
  title = NULL,
  vertex_color = "lightblue",
  vertex_frame_color = "darkblue",
  vertex_label_color = "black",
  edge_color = "darkgrey",
  edge_label_color = "black",
  min_arrow_width = 1,
  max_arrow_width = 10,
  node_size = 45,
  label_cex = 0.8
)

Value

A graph object (typically an [`igraph::igraph`] object or similar) is returned and plotted. Nodes represent variables and edges represent associations. Node labels include variable names and marginal probabilities. Edge labels display either conditional probabilities or logistic regression effects.

Arguments

data

A data frame containing the outcome (`y_var`) and predictors (`x_vars`).

y_var

Character string giving the name of the outcome variable in `data`.

x_vars

Character vector of predictor variable names in `data`.

var_labels

Optional character vector of display labels for the predictors. Must match the length of `x_vars`.

prob_digits

Integer; number of decimal places to round conditional probabilities. Defaults to `2`.

method

Character string indicating how to quantify associations: `"prob"` for conditional probabilities or `"logistic"` for logistic regression effects.

title

Character string; title of the plot.

vertex_color

Character string giving the fill color of nodes.

vertex_frame_color

Character string giving the color of node borders.

vertex_label_color

Character string giving the color of node labels.

edge_color

Character string giving the color of edges.

edge_label_color

Character string giving the color of edge labels.

min_arrow_width

Numeric value for the minimum edge width.

max_arrow_width

Numeric value for the maximum edge width.

node_size

Numeric value controlling the size of nodes.

label_cex

Numeric value controlling the size of node labels.

Examples

Run this code
plot_prob(misimdata,'y',colnames(misimdata[,3:6]),method='logistic')

Run the code above in your browser using DataLab