knitr::opts_chunk$set(echo = TRUE)

install and load package

install.packages("devtools")
devtools::install_github("mkearney/lavplot")
library(lavplot)
library(lavplot)

draw the plot

## plot nodes with grid background
par(bg = "#f5f5f5")
plot_nodes(c(-.75, 0, .75), c(-.5, .5, -.5),
           panel.first = grid(8))

## draw arrows
draw.arrow(-.75, -.50, .00,  .50)
draw.arrow( .00,  .50, .75, -.50)
draw.arrow(-.75, -.50, .75, -.50)

## add coefficients
text(-.45, .00, ".25")
text( .45,  .00, ".33")
text( .00, -.55, "-.15")

## add var names
text(-.75, -.50, "X")
text( .00,  .50, "W")
text( .75, -.50, "Y")



mkearney/lavplot documentation built on May 23, 2019, 1:06 a.m.