plotNet {modnets}R Documentation

Plot moderated and unmoderated network models

Description

Core function for plotting various types of network models. Accessible through the plot() S3 generic function.

Usage

plotNet(
  x,
  which.net = "temporal",
  threshold = FALSE,
  layout = "spring",
  predict = FALSE,
  mnet = FALSE,
  names = TRUE,
  nodewise = FALSE,
  scale = FALSE,
  lag = NULL,
  con = "R2",
  cat = "nCC",
  covNet = FALSE,
  plot = TRUE,
  elabs = FALSE,
  elsize = 1,
  rule = "OR",
  binarize = FALSE,
  mlty = TRUE,
  mselect = NULL,
  ...
)

## S3 method for class 'ggm'
plot(
  x,
  which.net = "temporal",
  threshold = FALSE,
  layout = "spring",
  predict = FALSE,
  mnet = FALSE,
  names = TRUE,
  nodewise = FALSE,
  scale = FALSE,
  lag = NULL,
  con = "R2",
  cat = "nCC",
  covNet = FALSE,
  plot = TRUE,
  elabs = FALSE,
  elsize = 1,
  rule = "OR",
  binarize = FALSE,
  mlty = TRUE,
  mselect = NULL,
  ...
)

## S3 method for class 'SURnet'
plot(
  x,
  which.net = "temporal",
  threshold = FALSE,
  layout = "spring",
  predict = FALSE,
  mnet = FALSE,
  names = TRUE,
  nodewise = FALSE,
  scale = FALSE,
  lag = NULL,
  con = "R2",
  cat = "nCC",
  covNet = FALSE,
  plot = TRUE,
  elabs = FALSE,
  elsize = 1,
  rule = "OR",
  binarize = FALSE,
  mlty = TRUE,
  mselect = NULL,
  ...
)

## S3 method for class 'mlGVAR'
plot(
  x,
  which.net = "temporal",
  threshold = FALSE,
  layout = "spring",
  predict = FALSE,
  mnet = FALSE,
  names = TRUE,
  nodewise = FALSE,
  scale = FALSE,
  lag = NULL,
  con = "R2",
  cat = "nCC",
  covNet = FALSE,
  plot = TRUE,
  elabs = FALSE,
  elsize = 1,
  rule = "OR",
  binarize = FALSE,
  mlty = TRUE,
  mselect = NULL,
  ...
)

## S3 method for class 'lmerVAR'
plot(
  x,
  which.net = "temporal",
  threshold = FALSE,
  layout = "spring",
  predict = FALSE,
  mnet = FALSE,
  names = TRUE,
  nodewise = FALSE,
  scale = FALSE,
  lag = NULL,
  con = "R2",
  cat = "nCC",
  covNet = FALSE,
  plot = TRUE,
  elabs = FALSE,
  elsize = 1,
  rule = "OR",
  binarize = FALSE,
  mlty = TRUE,
  mselect = NULL,
  ...
)

## S3 method for class 'ggmSim'
plot(
  x,
  which.net = "temporal",
  threshold = FALSE,
  layout = "spring",
  predict = FALSE,
  mnet = FALSE,
  names = TRUE,
  nodewise = FALSE,
  scale = FALSE,
  lag = NULL,
  con = "R2",
  cat = "nCC",
  covNet = FALSE,
  plot = TRUE,
  elabs = FALSE,
  elsize = 1,
  rule = "OR",
  binarize = FALSE,
  mlty = TRUE,
  mselect = NULL,
  ...
)

## S3 method for class 'mlGVARsim'
plot(
  x,
  which.net = "temporal",
  threshold = FALSE,
  layout = "spring",
  predict = FALSE,
  mnet = FALSE,
  names = TRUE,
  nodewise = FALSE,
  scale = FALSE,
  lag = NULL,
  con = "R2",
  cat = "nCC",
  covNet = FALSE,
  plot = TRUE,
  elabs = FALSE,
  elsize = 1,
  rule = "OR",
  binarize = FALSE,
  mlty = TRUE,
  mselect = NULL,
  ...
)

## S3 method for class 'GVARsim'
plot(
  x,
  which.net = "temporal",
  threshold = FALSE,
  layout = "spring",
  predict = FALSE,
  mnet = FALSE,
  names = TRUE,
  nodewise = FALSE,
  scale = FALSE,
  lag = NULL,
  con = "R2",
  cat = "nCC",
  covNet = FALSE,
  plot = TRUE,
  elabs = FALSE,
  elsize = 1,
  rule = "OR",
  binarize = FALSE,
  mlty = TRUE,
  mselect = NULL,
  ...
)

Arguments

x

Output from any of the modnets model fitting or simulation functions.

which.net

When multiple networks exist for a single object, this allows the user to indicate which network to plot. For a GGM, all values of this argument return the same adjacency matrix. For a SUR network, "beta" and "temporal" plot the temporal network, while "pdc" plots the Partial Directed Correlations, or the standardized temporal network. "contemporaneous" and "pcc" plot the standardized contemporaneous network (Partial Contemporaneous Correlations). All of these terms apply for multilevel networks, but "between" can also plot the between-subjects network. Additionally, the value "coef" will plot the model coefficients and confidence intervals, defaulting to the plotCoefs function. Moreover, with GGMs or outputs from mlGVAR with a moderated between-subjects network, the value "ints" will call the intsPlot function. If a numeric or logical value is supplied, however, this argument will function as the threshold argument. A numeric value will set a threshold at the supplied value, while TRUE will set a threshold of .05.

threshold

A numeric or logical value to set a p-value threshold. TRUE will automatically set the threshold at .05.

layout

Character. Corresponds to the layout argument in the qgraph::qgraph function.

predict

If TRUE, then prediction error associated with each node will be plotted as a pie graph around the nodes. For continuous variables, the type of prediction error is determined by the con argument. For categorical variables, the type of error is determined by the cat argument. The desired value of con or can can be supplied directly into the present argument as well. Alternatively, another network model constituted by the same nodes can be supplied in order to plot the difference in prediction error, such as R-squared change.

mnet

Logical. If TRUE, the moderator will be plotted as a square "node" in the network, along with main effects represented as directed edges.

names

If TRUE, then the variable names associated with the model will be plotted as labels on the nodes. If FALSE, then nodes will be labeled with numbers rather than names. Alternatively, a character vector can be provided to serve as custom labels for the nodes.

nodewise

Only applies to GGMs. If TRUE, then nodewise edges will be plotted rather than the undirected averages of corresponding edges.

scale

Logical. Only applies when predict does not equal FALSE. The value of this argument is sent to the predictNet function. This argument will be removed.

lag

This argument will be removed. The function will automatically detect whether the network is based on time-lagged data.

con

Character string indicating which type of prediction error to plot for continuous variables, if predict does not equal FALSE. Options are: "R2", "adjR2", "MSE", "RMSE"

cat

Character string indicating which type of prediction error to plot for categorical variables, if predict does not equal FALSE. Options are: "nCC", "CC", "CCmarg"

covNet

Logical. Only applies when a covariate is modeled. Allows the covariate to be plotted as a separate square "node".

plot

Logical. If FALSE, then a qgraph object will be returned rather than plotted.

elabs

Logical. If TRUE, the values of the edges will be plotted as labels on the edges.

elsize

numeric

rule

Only applies to GGMs (including between-subjects networks) when a threshold is supplied. The "AND" rule will only preserve edges when both corresponding coefficients have p-values below the threshold, while the "OR" rule will preserve an edge so long as one of the two coefficients have a p-value below the supplied threshold.

binarize

Logical. If TRUE, the network will be plotted as an unweighted network. Only applies to GGMs.

mlty

Logical. If FALSE, then moderated edges are displayed as solid lines. If TRUE, then moderated edges are shown as dashed lines.

mselect

If the model contains more than one moderator, input the character string naming which moderator you would like the plot to reflect. Only affects which lines are dashed or solid. Not compatible with the mnet argument.

...

Additional arguments.

Value

Displays a network plot, or returns a qgraph object if plot = FALSE.

See Also

fitNetwork, predictNet, mlGVAR, lmerVAR, simNet, mlGVARsim, plotCoefs, intsPlot, resample

Examples

fit1 <- fitNetwork(ggmDat)

plot(fit1)
plotNet(fit1) # This and the command above produce the same result

fit2 <- fitNetwork(gvarDat, moderators = 'M', lags = 1)

plot(fit2, 'pdc') # Partial Directed Correlations
plot(fit2, 'pcc') # Partial Contemporaneous Correlations

[Package modnets version 0.9.0 Index]