Position the nodes in the diagram
lav_plotinfo_positions.RdComputes the positions for the nodes and anchors and control points for the edges in the diagram.
Usage
lav_plotinfo_positions(plotinfo,
placenodes = NULL,
edgelabelsbelow = NULL,
group_covar_indicators = FALSE,
debug = FALSE)Arguments
- plotinfo
The plotinfo structure as returned from
lav_model_plotinfo.- placenodes
optional list with members
nodename = c(row, column),rowandcolumndon't have to be integers.- edgelabelsbelow
optional list with members
c(nodename1, nodename2).- group_covar_indicators
logical, should items with indicators which have an explicit covariance link be placed in the same group, i.e. forced to be on the same side of the diagram?
- debug
logical, print debug information?
Value
A plotinfo structure with modified nodes and edges
data.frames, and an integer mlrij giving the position at which a line
should be drawn for multilevel models.
The data.frames have new columns defined as follows:
nodes- rij
index of the row where the node will be placed, initialized NA.
- kolom
index of the column where the node will be placed, initialized NA.
edges- vananker
character, anchor point for starting node, initialized NA.
- naaranker
character, anchor point for destination node, initialized NA.
- controlpt.kol
real, column position of control point if the edge has to be drawn as a quadratic Bezier curve.
- controlpt.row
real, row position of control point if the edge has to be drawn as a quadratic Bezier curve.
- labelbelow
logical, TRUE if label has to be positioned under the line, initialized FALSE.
Details
This function tries to arrange the nodes and the anchor points for the
edges in a way that keeps the diagram reasonably compact, while placing the
dependent variable of a regression to the right of the variables it depends on.
If the result is not what you want, you can inspect the plot with the
lav_plotinfo_rgraph or lav_plot functions and then place some
nodes at a different location (placenodes) and/or move some edge labels
to the other side of the edge (labelsbelow).
For multilevel models – maximum two levels – the nodes in block 2 are grouped
at the top of the diagram and those in block 1 at the bottom. The item
mlrij gives the position of the separation between the blocks.
Examples
model <- 'alfa =~ 1 * x1 + x2 + x3 # latent variable
beta <~ x4 + x5 + x6 # composite
gamma =~ 1 * x7 + x8 + x9 # latent variable
Xi =~ 1 * x10 + x11 + x12 + x13 # latent variable
# regressions
Xi ~ v * alfa + t * beta + cc * 1
alfa ~ tt * beta + ss * gamma + yy * Theta1
# variances and covariances
x2 ~~ cc25 * x5
x3 ~~ cc36 * x6
x3 ~~ cc34 * x4
gamma ~~ 0.55 * gamma
'
test <- lav_model_plotinfo(model)
(test_positioned <- lav_plotinfo_positions(test))
#> $nodes
#> id naam tiepe blok rij kolom group
#> 1 alfa alfa lv 0 2 3 1
#> 2 x1 x1 ov 0 1 2 1
#> 3 x2 x2 ov 0 1 3 1
#> 4 x3 x3 ov 0 1 4 1
#> 5 beta beta cv 0 3 2 2
#> 6 x4 x4 ov 0 2 1 2
#> 7 x5 x5 ov 0 3 1 2
#> 8 x6 x6 ov 0 4 1 2
#> 9 gamma gamma lv 0 6 2 3
#> 10 x7 x7 ov 0 5 1 3
#> 11 x8 x8 ov 0 6 1 3
#> 12 x9 x9 ov 0 7 1 3
#> 13 Xi Xi lv 0 6 4 4
#> 14 x10 x10 ov 0 5 5 4
#> 15 x11 x11 ov 0 6 5 4
#> 16 x12 x12 ov 0 7 5 4
#> 17 x13 x13 ov 0 8 5 4
#> 18 1vanXi 1vanXi const 0 2 4 5
#> 19 Theta1 Theta1 ov 0 8 2 6
#>
#> $edges
#> id label van naar tiepe vananker naaranker controlpt.kol controlpt.rij
#> 1 1 1 alfa x1 =~ n s NA NA
#> 2 2 alfa x2 =~ n s NA NA
#> 3 3 alfa x3 =~ n s NA NA
#> 4 4 x4 beta <~ e w NA NA
#> 5 5 x5 beta <~ e w NA NA
#> 6 6 x6 beta <~ e w NA NA
#> 7 7 1 gamma x7 =~ w e NA NA
#> 8 8 gamma x8 =~ w e NA NA
#> 9 9 gamma x9 =~ w e NA NA
#> 10 10 1 Xi x10 =~ e w NA NA
#> 11 11 Xi x11 =~ e w NA NA
#> 12 12 Xi x12 =~ e w NA NA
#> 13 13 Xi x13 =~ e w NA NA
#> 14 14 v alfa Xi ~ s n NA NA
#> 15 15 t beta Xi ~ se nw NA NA
#> 16 16 cc 1vanXi Xi ~ s n NA NA
#> 17 17 tt beta alfa ~ ne sw NA NA
#> 18 18 ss gamma alfa ~ n s NA NA
#> 19 19 yy Theta1 alfa ~ n s NA NA
#> 20 20 cc25 x5 x2 ~~ w n -0.5454545 -0.54545455
#> 21 21 cc36 x6 x3 ~~ w n -1.4090909 -1.40909091
#> 22 22 cc34 x4 x3 ~~ w n -1.0454545 -0.04545455
#> 23 23 0.55 gamma gamma ~~~ n n NA NA
#> labelbelow
#> 1 FALSE
#> 2 FALSE
#> 3 FALSE
#> 4 FALSE
#> 5 FALSE
#> 6 FALSE
#> 7 FALSE
#> 8 FALSE
#> 9 FALSE
#> 10 FALSE
#> 11 FALSE
#> 12 FALSE
#> 13 FALSE
#> 14 FALSE
#> 15 FALSE
#> 16 FALSE
#> 17 FALSE
#> 18 FALSE
#> 19 FALSE
#> 20 FALSE
#> 21 FALSE
#> 22 FALSE
#> 23 FALSE
#>
#> $mlrij
#> [1] 0
#>