## ----setup, include=FALSE-----------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE, comment = "#>", message = FALSE, warning = FALSE,
  fig.width = 7, fig.height = 5.5
)
library(idiographic)
data(srl)
has_cograph <- requireNamespace("cograph", quietly = TRUE)

## ----vars-audit---------------------------------------------------------------
vars <- c("efficacy", "value", "planning", "monitoring", "effort")
preprocess(srl, vars = vars, id = "name", min_obs = 100)

## ----fit----------------------------------------------------------------------
mlvar_fit <- fit_mlvar(
  srl, vars = vars, id = "name",
  estimator = "lmer", temporal = "fixed", contemporaneous = "fixed",
  AR = FALSE
)
mlvar_fit

## ----summary------------------------------------------------------------------
summary(mlvar_fit)

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

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

## ----edges-between------------------------------------------------------------
edges(mlvar_fit, network = "between", n = 5)

## ----nodes--------------------------------------------------------------------
nodes(mlvar_fit)

## ----matrices-----------------------------------------------------------------
matrices(mlvar_fit)

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

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

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

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

## ----plot-between, eval=has_cograph-------------------------------------------
plot(mlvar_fit, layer = "between")

