Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
4fcce10
Fixed marvel example
jhollway Feb 18, 2026
c4dc2a5
Fixed generic arguments and rely on dplyr::tibble instead of tibble::…
jhollway Feb 18, 2026
ffe90a8
#patch bump and NEWS
jhollway Feb 18, 2026
1ba97dc
Fixed diversity tutorial to work with fict_marvel
jhollway Mar 6, 2026
c2b69c5
Specifying which node_in_regular is used in testing
jhollway Mar 6, 2026
ae4e66f
Added tutorial testing
jhollway Mar 6, 2026
335cc6f
Added tutorial testing for three existing packages
jhollway Mar 6, 2026
6e5f3d2
Fixed ergm tutorial to work with netrics
jhollway Mar 15, 2026
bab0f0e
Moved run_tute() from manynet to here
jhollway Mar 15, 2026
6be3dbc
Fixed test_permutation() to use net_by_density() from netrics
jhollway Mar 15, 2026
18c3982
test_tutorials() now has a quiet option
jhollway Mar 15, 2026
f3a0478
Tutorials are highlighted in README
jhollway Mar 15, 2026
73eaa29
Added tutorials to website
jhollway Mar 15, 2026
e72c577
#minor bump
jhollway Mar 15, 2026
e8248e0
Updated logo
jhollway Mar 15, 2026
936940d
Updated migraph logo
jhollway Apr 4, 2026
b322d46
Using manynet::to_permuted() instead of older generate_permutation()
jhollway Apr 4, 2026
b7d875e
Printing multimodal mpn datasets now unpacks dimensions
jhollway Apr 4, 2026
b6fc33f
Added tutorial0 from manynet
jhollway Apr 4, 2026
02c615e
Updated date
jhollway Apr 4, 2026
66485c4
Updated pkg
jhollway Apr 4, 2026
8a4ac41
Added shiny dependency
jhollway Apr 4, 2026
1fbc59c
Using snet_ messaging instead of cli
jhollway Apr 4, 2026
129a8f3
New Depends on netrics
jhollway Apr 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: migraph
Title: Inferential Methods for Multimodal and Other Networks
Version: 1.5.7
Date: 2026-02-18
Version: 1.6.0
Date: 2026-04-04
Description: A set of tools for testing networks.
It includes functions for univariate and multivariate
conditional uniform graph and quadratic assignment procedure testing,
Expand All @@ -22,17 +22,22 @@ RoxygenNote: 7.3.3
Depends:
R (>= 3.6.0),
manynet (>= 1.0.5),
autograph (>= 0.4.0)
autograph (>= 0.4.0),
netrics
Imports:
dplyr (>= 1.1.0),
ergm,
future,
furrr,
generics,
knitr,
learnr,
purrr
Suggests:
covr,
rmarkdown,
roxygen2,
shiny,
testthat (>= 3.0.0)
Authors@R:
c(person(given = "James",
Expand All @@ -58,4 +63,4 @@ Authors@R:
Roxygen: list(markdown = TRUE, roclets = c("namespace", "rd"))
Config/testthat/parallel: true
Config/testthat/edition: 3
Config/testthat/start-first: helper-functions
Config/testthat/start-first: tutorials_manynet
9 changes: 8 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,37 @@ S3method(print,netlogit)
S3method(print,network_test)
S3method(print,over_memb)
S3method(summary,diffs_model)
S3method(summary,ergm)
S3method(summary,sienaFit)
S3method(tidy,ergm)
S3method(tidy,netlm)
S3method(tidy,netlogit)
S3method(tidy,sienaFit)
export("%>%")
export(extract_tute)
export(glance)
export(net_regression)
export(network_reg)
export(over_membership)
export(over_time)
export(over_waves)
export(play_diffusions)
export(run_tute)
export(test_configuration)
export(test_distribution)
export(test_fit)
export(test_gof)
export(test_permutation)
export(test_random)
export(test_tutorials)
export(tidy)
importFrom(autograph,ag_base)
importFrom(dplyr,"%>%")
importFrom(dplyr,`%>%`)
importFrom(dplyr,as_tibble)
importFrom(dplyr,bind_cols)
importFrom(dplyr,left_join)
importFrom(dplyr,select)
importFrom(dplyr,tibble)
importFrom(ergm,as.rlebdm)
importFrom(furrr,furrr_options)
importFrom(furrr,future_map_dfr)
Expand All @@ -50,6 +56,7 @@ importFrom(manynet,is_complex)
importFrom(manynet,is_directed)
importFrom(manynet,play_diffusion)
importFrom(manynet,to_subgraph)
importFrom(netrics,net_by_heterophily)
importFrom(purrr,flatten)
importFrom(stats,as.formula)
importFrom(stats,binomial)
Expand Down
33 changes: 28 additions & 5 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,33 @@
# migraph 1.5.7
# migraph 1.6.0

2026-04-04

## Package

- Updated logo
- Now Depends on `{netrics}`
- Fixed generic arguments and rely on `dplyr::tibble()` instead of `tibble::tibble()` internally

## Testing

- Fixed `test_permutation()` to use `netrics::net_by_density()`
- Fixed `net_regression()` to use `manynet::to_permuted()`

## Tutorials

- Moved `run_tute()` and `extract_tute()` from `{manynet}` to here
- Fixed `fict_marvel` example
- Fixed diversity tutorial to work with `fict_marvel`
- Fixed ergm tutorial to work with `{netrics}`
- Moved tutorial0/data from `{manynet}`
- Added tutorial testing, with a quiet option
- Tutorials are highlighted in the README

2026-02-18
# migraph 1.5.7

- Using fict_marvel in tests
- Added tidy(), glance(), and summary() methods for sienaFit class objects
- Added summary.ergm()
- Using `fict_marvel` in tests
- Added `tidy()`, `glance()`, and `summary()` methods for sienaFit class objects
- Added `summary.ergm()`

# migraph 1.5.6

Expand Down
44 changes: 23 additions & 21 deletions R/class_models.R
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,15 @@ tidy.ergm <- function(
}

#' @method tidy sienaFit
#' @importFrom dplyr tibble
#' @export
tidy.sienaFit <- function(ans){
tibble::tibble(
dv = ans$effects$name,
term = ans$effects$effectName,
estimate = ans$theta,
se = ans$se,
tstat = ans$theta/ans$se
tidy.sienaFit <- function(x, ...){
dplyr::tibble(
dv = x$effects$name,
term = x$effects$effectName,
estimate = x$theta,
std.error = x$se,
statistic = x$theta/x$se
)
}

Expand Down Expand Up @@ -252,10 +253,10 @@ glance.ergm <- function(x, deviance = FALSE, mcmc = FALSE, ...) {

#' @method glance sienaFit
#' @export
glance.sienaFit <- function(ans){
tibble::tibble(
tmax = ans$tmax,
tconv.max = ans$tconv.max[,1]
glance.sienaFit <- function(x, ...){
dplyr::tibble(
tmax = x$tmax,
tconv.max = x$tconv.max[,1]
)
}

Expand All @@ -275,20 +276,21 @@ print.netlogit <- function(x, ...){
print(glance(x))
}

#' @export
summary.ergm <- function(x, ...){
cat("# Fitted model results\n")
print(tidy(x))
cat("\n# Model summary statistics\n")
print(glance(x))
}
# Unused because infinite recursion through summary.ergm() in tidy.ergm()
# #' @export
# summary.ergm <- function(x, ...){
# cat("# Fitted model results\n")
# print(tidy(x))
# cat("\n# Model summary statistics\n")
# print(glance(x))
# }

#' @export
summary.sienaFit <- function(x, ...){
summary.sienaFit <- function(object, ...){
cat("# Fitted model results\n")
print(tidy(x))
print(tidy(object))
cat("\n# Model summary statistics\n")
print(glance(x))
print(glance(object))
}


Expand Down
5 changes: 4 additions & 1 deletion R/migraph-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@ thisRequires <- function(pkgname){
}

# defining global variables more centrally
utils::globalVariables(c(".data", "obs", "fin","n","sim","time","value","conf.low","conf.high"))
utils::globalVariables(c(".data", "obs", "fin","n","sim","time","value","conf.low","conf.high",
"name"))

# Suppress R CMD check note
# Namespace in Imports field not imported from: PKG
# All declared Imports should be used.
#' @importFrom autograph ag_base
#' @importFrom netrics net_by_heterophily
ignore_unused_imports <- function() {
# This function exists only to reference autograph::ag_base and suppress R CMD check notes about unused imports.
autograph::ag_base
netrics::net_by_heterophily
NULL
}

Expand Down
8 changes: 4 additions & 4 deletions R/model_regression.R
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,14 @@ net_regression <- function(formula, .data,
on.exit(future::plan(oplan), add = TRUE)
if(valued){
repdist <- furrr::future_map_dfr(1:times, function(j){
nlmfit(c(list(manynet::generate_permutation(g[[1]], with_attr = FALSE)),
nlmfit(c(list(manynet::to_permuted(g[[1]], with_attr = FALSE)),
g[2:(nx+1)]),
directed = directed, diag = diag,
rety = FALSE)
}, .progress = verbose, .options = furrr::furrr_options(seed = T))
} else {
repdist <- furrr::future_map_dfr(1:times, function(j){
repfit <- nlgfit(c(list(manynet::generate_permutation(g[[1]], with_attr = FALSE)),
repfit <- nlgfit(c(list(manynet::to_permuted(g[[1]], with_attr = FALSE)),
g[2:(nx+1)]),
directed = directed, diag = diag)
repfit$coef/sqrt(diag(chol2inv(repfit$qr$qr)))
Expand Down Expand Up @@ -207,14 +207,14 @@ net_regression <- function(formula, .data,
if(valued){
repdist[,i] <- furrr::future_map_dbl(1:times, function(j){
nlmfit(c(g[-(1 + i)],
list(manynet::generate_permutation(xres, with_attr = FALSE))),
list(manynet::to_permuted(xres, with_attr = FALSE))),
directed = directed, diag = diag,
rety = FALSE)[nx]
}, .progress = verbose, .options = furrr::furrr_options(seed = T))
} else {
repdist[,i] <- furrr::future_map_dbl(1:times, function(j){
repfit <- nlgfit(c(g[-(1 + i)],
list(manynet::generate_permutation(xres, with_attr = FALSE))),
list(manynet::to_permuted(xres, with_attr = FALSE))),
directed = directed, diag = diag)
repfit$coef[nx]/sqrt(diag(chol2inv(repfit$qr$qr)))[nx]
}, .progress = verbose, .options = furrr::furrr_options(seed = T))
Expand Down
10 changes: 5 additions & 5 deletions R/model_tests.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ NULL
#' @rdname tests
#' @importFrom manynet generate_random bind_node_attributes is_directed is_complex
#' @examples
#' marvel_friends <- to_unsigned(ison_marvel_relationships)
#' marvel_friends <- to_giant(marvel_friends) %>%
#' marvel_friends <- fict_marvel %>% to_uniplex("relationship") %>%
#' to_unsigned() %>% to_giant() %>%
#' to_subgraph(PowerOrigin == "Human")
#' (cugtest <- test_random(marvel_friends, manynet::net_heterophily, attribute = "Attractive",
#' (cugtest <- test_random(marvel_friends, net_by_heterophily, attribute = "Attractive",
#' times = 200))
#' # plot(cugtest)
#' @export
Expand Down Expand Up @@ -119,7 +119,7 @@ test_configuration <- function(.data, FUN, ...,
#' @rdname tests
#' @examples
#' # (qaptest <- test_permutation(marvel_friends,
#' # manynet::net_heterophily, attribute = "Attractive",
#' # net_by_heterophily, attribute = "Attractive",
#' # times = 200))
#' # plot(qaptest)
#' @export
Expand All @@ -134,7 +134,7 @@ test_permutation <- function(.data, FUN, ...,
obsd <- FUN(.data)
}
n <- manynet::net_dims(.data)
d <- manynet::net_density(.data)
d <- netrics::net_by_density(.data)
oplan <- future::plan(strategy)
on.exit(future::plan(oplan), add = TRUE)
rands <- furrr::future_map(1:times,
Expand Down
92 changes: 92 additions & 0 deletions R/tutorial_run.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Tutorials overview ####

#' Open and extract code from tutorials
#'
#' @description
#' These functions make it easy to use the tutorials
#' in the `{manynet}` and `{migraph}` packages:
#'
#' - `run_tute()` runs a `{learnr}` tutorial from
#' either the `{manynet}` or `{migraph}` packages,
#' wraps `learnr::run_tutorial()` with some convenience.
#' - `extract_tute()` extracts and opens just the solution code
#' from a `{manynet}` or `{migraph}` tutorial,
#' saving the .R script to the current working directory.
#'
#' @param tute String, name of the tutorial (e.g. "tutorial2").
#' @importFrom dplyr %>% as_tibble select tibble
#' @name tutorials
NULL

stocnet <- c("manynet", "migraph", "autograph")

#' @rdname tutorials
#' @export
run_tute <- function(tute) {
thisRequires("learnr")
avail_pkgs <- stocnet[suppressWarnings(unlist(lapply(stocnet,
function(x) nzchar(system.file(package = x)))))]
if (missing(tute)) {
tutelist <- lapply(manynet::snet_progress_along(avail_pkgs,
name = "Checking tutorials in stocnet packages"),
function(p){
dplyr::as_tibble(learnr::available_tutorials(package = avail_pkgs[p]),
silent = TRUE) %>% dplyr::select(1:3)
})
dplyr::bind_rows(tutelist) %>% dplyr::arrange(name) %>% print()
manynet::snet_info("You can run a tutorial by typing e.g `run_tute('tutorial1')` or `run_tute('Data')` into the console.")
} else {
try(learnr::run_tutorial(tute, "manynet"), silent = TRUE)
try(learnr::run_tutorial(tute, "migraph"), silent = TRUE)
try(learnr::run_tutorial(tute, "autograph"), silent = TRUE)
manynet::snet_info("Didn't find a direct match, so looking for close matches...")
tutelist <- lapply(manynet::snet_progress_along(avail_pkgs,
name = "Checking tutorials in stocnet packages"), function(p){
dplyr::as_tibble(learnr::available_tutorials(package = avail_pkgs[p]),
silent = TRUE) %>% dplyr::select(1:3)
})
avails <- dplyr::bind_rows(tutelist)
inftit <- grepl(tute, avails$title, ignore.case = TRUE)
if(!any(inftit) | sum(inftit)>1)
inftit <- which.min(utils::adist(tute, avails$title, ignore.case = TRUE,
costs = list(ins=0, del=1, sub=1)))
if(any(inftit) & sum(inftit)==1){
manynet::snet_success("And found one!")
try(learnr::run_tutorial(avails$name[inftit], avails$package[inftit]), silent = TRUE)
} else{
manynet::snet_warn("...and couldn't find which one you meant. Please specify one of these titles:\n")
print(avails)
}
}
}

#' @rdname tutorials
#' @export
extract_tute <- function(tute) {
if (missing(tute)) {
thisRequires("learnr")
avail_pkgs <- stocnet[suppressWarnings(unlist(lapply(stocnet, function(x) nzchar(system.file(package = x)))))]
tutelist <- lapply(manynet::snet_progress_along(avail_pkgs,
name = "Checking tutorials in stocnet packages"), function(p){
dplyr::as_tibble(learnr::available_tutorials(package = avail_pkgs[p]),
silent = TRUE) %>% dplyr::select(1:3)
})
dplyr::bind_rows(tutelist) %>% dplyr::arrange(name) %>% print()
manynet::snet_info("You can extract the code from one of these tutorials by typing e.g `extract_tute('tutorial1')` into the console.")
} else {
thisRequires("knitr")
pth <- file.path(path.package("manynet"), "tutorials", tute)
if(!dir.exists(pth)) {
thisRequires("autograph")
pth <- gsub("manynet", "autograph", pth)
}
if(!dir.exists(pth)) {
thisRequires("migraph")
pth <- gsub("autograph", "migraph", pth)
}
knitr::purl(file.path(pth, list.files(pth, pattern = "*.Rmd")),
documentation = 1)
utils::file.edit(gsub(".Rmd", ".R", list.files(pth, pattern = "*.Rmd")))
}
}

Loading
Loading