Draw the temporal and contemporaneous networks of a continuous time model
Source:R/ctGraph.R
ctNetworkPlot.RdPlots 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.
Arguments
- x
A
ctStanModel, a fit, or actNetworkfromctNetwork.- dt
One or more time intervals. Ignored, with a message, when
xis already actNetwork.- state
Where a state dependent cell is evaluated; see
ctNetwork. Ignored, with a message, whenxis already actNetwork, 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 eachdt.- 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 toqgraph::qgraph()whenengine='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')