Skip to contents

Plots what ctNetwork computes, in the style of the network psychometrics literature: signed edges, width by magnitude, arrowheads and self-loops on the directed temporal network, and no arrowheads on the undirected contemporaneous one.

Give dt more than one value and the same networks are drawn side by side at each interval, which is the continuous time point: the graph a study would have recovered depends on how often it measured.

Usage

ctNetworkPlot(
  x,
  dt = 1,
  state = NULL,
  networks = c("temporal", "contemporaneous"),
  threshold = 0,
  engine = c("ggplot", "qgraph"),
  maxwidth = 3,
  arrowsize = 2.6,
  nodesize = 10,
  labelsize = 3.2,
  poscolour = "#2166AC",
  negcolour = "#B2182B",
  title = "auto",
  ...
)

Arguments

x

A ctStanModel, a fit, or a ctNetwork from ctNetwork.

dt

One or more time intervals. Ignored, with a message, when x is already a ctNetwork.

state

Where a state dependent cell is evaluated; see ctNetwork. Ignored, with a message, when x is already a ctNetwork, which was built at a point of its own. When the system is state dependent the point appears in the plot's subtitle, so a saved figure carries its own caveat; a linear system gets no subtitle.

networks

Which networks to draw; see ctNetwork. Each becomes a panel, as does each dt.

threshold

Edges with abs(weight) at or below this are not drawn.

engine

'ggplot' (the default) or 'qgraph'.

maxwidth

Line width of the largest edge drawn.

arrowsize

Arrowhead length in mm.

nodesize, labelsize

Node and label size.

poscolour, negcolour

Colours for positive and negative edges. The defaults are a colour-blind safe blue and red; the literature's green and red are 'darkgreen' and 'red'.

title

Panel title, or NULL for none. 'auto' names the source and the interval.

...

Passed to ctNetwork, or to qgraph::qgraph() when engine='qgraph'.

Value

A ggplot2 object, which can be modified further or printed. With engine='qgraph', the qgraph object, invisibly, having drawn.

Details

Drawn with ggplot2, which ctsem already depends on, so no extra package is needed. engine='qgraph' hands the weight matrix to qgraph::qgraph() instead, if that package is installed – ctNetwork's matrices are in the shape qgraph expects, so qgraph::qgraph(ctNetwork(fit)$temporal, directed=TRUE) needs nothing from this function.

Examples

m <- ctModel(type='ct', n.latent=3, n.manifest=3,
  manifestNames=c('y1','y2','y3'), latentNames=c('a','b','c'),
  LAMBDA=diag(3),
  DRIFT=matrix(c(-.4,0,0, .3,-.5,0, 0,.4,-.6), 3, 3, byrow=TRUE),
  DIFFUSION=matrix(c(1,0,0, .3,1,0, 0,-.4,1), 3, 3, byrow=TRUE))

# The indirect path a -> b -> c is invisible at a short interval and present
# at a long one -- the same model, two networks.
ctNetworkPlot(m, dt=c(.2, 2), networks='temporal')