Skip to contents

Computes 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)

Arguments

plotinfo

The plotinfo structure as returned from lav_model_plotinfo.

placenodes

optional list with members nodename = c(row, column), row and column don'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?

Value

A plotinfo strucure 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:

  1. 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.

  2. 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 Beziers curve.

    controlpt.row

    real, row position of control point if the edge has to be drawn as a quadratic Beziers curve.

    labelbelow

    logical, TRUE if label has to be positioned under the line, initalized FALSE.

Details

This function tries to arrange the nodes and anchor points for the edges in a way that gives a not-to-large diagram and taking into account the voorkeur column in the input nodes data.frame. If the result is not what you want, you can take a look at the plot via lav_plotinfo_rgraph or lav_plot functions and decide yourself to place some nodes at another location (placenodes) and/or put some edge labels at 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 voorkeur rij kolom
#> 1   1   alfa    lv    0        m   2     3
#> 2   2     x1    ov    0            1     2
#> 3   3     x2    ov    0            1     3
#> 4   4     x3    ov    0            1     4
#> 5   5   beta    cv    0        l   3     2
#> 6   6     x4    ov    0            2     1
#> 7   7     x5    ov    0            3     1
#> 8   8     x6    ov    0            4     1
#> 9   9  gamma    lv    0        l   6     2
#> 10 10     x7    ov    0            5     1
#> 11 11     x8    ov    0            6     1
#> 12 12     x9    ov    0            7     1
#> 13 13     Xi    lv    0        r   4     5
#> 14 14    x10    ov    0            3     6
#> 15 15    x11    ov    0            4     6
#> 16 16    x12    ov    0            5     6
#> 17 17    x13    ov    0            6     6
#> 18 18 1vanXi const    0        l   3     5
#> 19 19 Theta1    ov    0        l   2     4
#> 
#> $edges
#>    id label van naar tiepe vananker naaranker controlpt.kol controlpt.rij
#> 1   1     1   1    2    =~        n         s            NA            NA
#> 2   2         1    3    =~        n         s            NA            NA
#> 3   3         1    4    =~        n         s            NA            NA
#> 4   4         6    5    <~        e         w            NA            NA
#> 5   5         7    5    <~        e         w            NA            NA
#> 6   6         8    5    <~        e         w            NA            NA
#> 7   7     1   9   10    =~        w         e            NA            NA
#> 8   8         9   11    =~        w         e            NA            NA
#> 9   9         9   12    =~        w         e            NA            NA
#> 10 10     1  13   14    =~        e         w            NA            NA
#> 11 11        13   15    =~        e         w            NA            NA
#> 12 12        13   16    =~        e         w            NA            NA
#> 13 13        13   17    =~        e         w            NA            NA
#> 14 14     v   1   13     ~       se        nw            NA            NA
#> 15 15     t   5   13     ~        e         w            NA            NA
#> 16 16    cc  18   13     ~        s         n            NA            NA
#> 17 17    tt   5    1     ~       ne        sw            NA            NA
#> 18 18    ss   9    1     ~        n         s            NA            NA
#> 19 19    yy  19    1     ~        w         e            NA            NA
#> 20 20  cc25   7    3    ~~        w         n    -0.5454545   -0.54545455
#> 21 21  cc36   8    4    ~~        w         n    -1.4090909   -1.40909091
#> 22 22  cc34   6    4    ~~        w         n    -1.0454545   -0.04545455
#> 23 23  0.55   9    9   ~~~        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
#>