## ----setup, include=FALSE-----------------------------------------------------
knitr::opts_chunk$set(dpi = 72, collapse = TRUE, comment = "#>")

## ----load---------------------------------------------------------------------
library(remverse)

## ----data---------------------------------------------------------------------
data(randomREH3)
data(info3)
str(randomREH3)

## ----tie-setup----------------------------------------------------------------
reh <- remify(
  edgelist = randomREH3,
  model    = "tie",
  directed = TRUE
)

stats_tie <- remstats(
  reh = reh,
  tie_effects = ~ inertia(scaling = "std") + reciprocity(scaling = "std") +
                   send("age", attr_actors = info3, scaling = "std"),
  memory = "decay", memory_value = 2000
)

## ----tie-auto-----------------------------------------------------------------
mw_tie_auto <- remwindow(reh = reh, stats = stats_tie)
mw_tie_auto

## ----tie-auto-summary---------------------------------------------------------
summary(mw_tie_auto)

## ----tie-auto-plot, out.width="70%", dev=c("jpeg"), dev.args = list(bg = "white")----
plot(mw_tie_auto)

## ----tie-manual---------------------------------------------------------------
mw_tie <- remwindow(
  reh              = reh,
  stats            = stats_tie,
  window.width     = 200,
  step.size.window = 50
)
mw_tie

## ----tie-manual-plot, out.width="70%", dev=c("jpeg"), dev.args = list(bg = "white")----
plot(mw_tie)

## ----tie-stability------------------------------------------------------------
summary(mw_tie)

## ----actor-setup--------------------------------------------------------------
reh_ao <- remify(
  edgelist = randomREH3,
  model    = "actor",
  directed = TRUE
)

stats_ao <- remstats(
  reh = reh_ao,
  sender_effects   = ~ outdegreeSender(scaling = "std"),
  receiver_effects = ~ inertia(scaling = "std") + reciprocity(scaling = "std"),
  memory = "decay", memory_value = 2000
)

## ----actor-auto---------------------------------------------------------------
mw_actor <- remwindow(reh = reh_ao, stats = stats_ao)
mw_actor

## ----actor-summary------------------------------------------------------------
summary(mw_actor)

## ----actor-plot, out.width="70%", dev=c("jpeg"), dev.args = list(bg = "white")----
plot(mw_actor)

## ----actor-receiver-only------------------------------------------------------
stats_choice_only <- remstats(
  reh = reh_ao,
  receiver_effects = ~ inertia(scaling = "std") + reciprocity(scaling = "std"),
  memory = "decay", memory_value = 2000
)

mw_actor_choice <- remwindow(reh = reh_ao, stats = stats_choice_only)
mw_actor_choice

## ----tie-diag, out.width="70%", dev=c("jpeg"), dev.args = list(bg = "white")----
diag_tie <- diagnostics(mw_tie, reh, stats_tie)
diag_tie

plot(diag_tie)

## ----actor-diag, out.width="70%", dev=c("jpeg"), dev.args = list(bg = "white")----
diag_actor <- diagnostics(mw_actor, reh_ao, stats_ao)

plot(diag_actor)

## ----parallel, eval=FALSE-----------------------------------------------------
# mw_parallel <- remwindow(
#   reh           = reh,
#   stats         = stats_tie,
#   parallel      = TRUE,
#   ncores.window = 4
# )

