## ----setup, include=FALSE-----------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE, comment = "#>", message = FALSE, warning = FALSE,
  fig.width = 7, fig.height = 5.5
)

## ----libraries----------------------------------------------------------------
library(idiographic)
data(srl)
vars <- c("efficacy", "value", "planning", "monitoring", "effort")
has_cograph <- requireNamespace("cograph", quietly = TRUE)

## ----audit--------------------------------------------------------------------
preprocess(srl, vars = vars, id = "name")

## ----fit----------------------------------------------------------------------
var_fit <- fit_var(srl, vars = vars, id = "name", subject = "Grace",
                   scale = TRUE)
var_fit

## ----summary------------------------------------------------------------------
summary(var_fit)

## ----edges-temporal-----------------------------------------------------------
edges(var_fit, network = "temporal", n = 5)

## ----edges-contemp------------------------------------------------------------
edges(var_fit, network = "contemporaneous", n = 5)

## ----nodes--------------------------------------------------------------------
nodes(var_fit)

## ----plot-all, eval=has_cograph-----------------------------------------------
plot(var_fit)

## ----plot-temporal, eval=has_cograph------------------------------------------
plot(var_fit, layer = "temporal")

## ----plot-contemp, eval=has_cograph-------------------------------------------
plot(var_fit, layer = "contemporaneous")

## ----plot-mixed, eval=has_cograph---------------------------------------------
plot(var_fit, mixed = TRUE)

