The lavaangui
package provides a free, open-source graphical user interface for the lavaan package. The core feature is that models can be specified by drawing path diagrams and fitted models visualized via interactive path diagrams.
There are three main ways to use the lavaangui
package.
-
Web application: The easiest is to visit http://lavaangui.org/ and use it as a web application. This requires no additional software besides a web browser. The main downside of this is that the webserver is likely slower than your computer. So, fitting complicated models might take a long time. The app is likely also more responsive on your computer.
-
Local web application: After installing the
lavaangui
package (see below), you can start a local version of the web application via thestart_gui()
command. -
Interactive plots:
lavaangui
can also be used for plottinglavaan
models that were created in R. For this, useplot_interactive(fit)
. This will create a path diagram of your model. The core difference compared to other packages for plottinglavaan
models is that the resulting plot is interactive. That is, you can change its appearance easily, for example, by dragging around nodes with your mouse.
For the web application, no installation is necessary. Simply go to http://lavaangui.org/. The web application should work with any modern browser. It is continuously being tested with: Chrome, Edge, Safari, Firefox, and Opera.
Only Windows users first need to install Rtools. Then, you can install the latest version of the R package via the following commands.
if (!requireNamespace("remotes", quietly = TRUE)) {
install.packages("remotes")
}
remotes::install_github("karchjd/lavaangui")
You can start the lavaangui
web application by typing
library(lavaangui)
start_gui()
into your R console.
Alternatively, you can also use the command start_gui(fit)
, where fit
is any supported fitted lavaan object. This will initialize the web application with the model (and data) contained in fit. For example, the following code initializes the web application with a three factor model.
library(lavaan)
library(lavaangui)
HS.model <- ' visual =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed =~ x7 + x8 + x9 '
fit <- cfa(HS.model, data = HolzingerSwineford1939)
start_gui(fit)
To obtain an interactive plot of your fitted model without leaving R Studio, use the plot_interactive(fit)
function:
library(lavaan)
library(lavaangui)
HS.model <- ' visual =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed =~ x7 + x8 + x9 '
fit <- cfa(HS.model, data = HolzingerSwineford1939)
plot_interactive(fit)