Skip to content

Web application - Graphical user interface for lavaan

License

Notifications You must be signed in to change notification settings

karchjd/lavaangui

Repository files navigation

lavaangui

R CMD CHECK Tests . contributions

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.

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

  2. Local web application: After installing the lavaangui package (see below), you can start a local version of the web application via the start_gui() command.

  3. Interactive plots: lavaangui can also be used for plotting lavaan models that were created in R. For this, use plot_interactive(fit). This will create a path diagram of your model. The core difference compared to other packages for plotting lavaan 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.

Getting Started

Web application

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.

R Package

Installation

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

start_gui

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)

plot_interactive

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)