Learn R Programming

networkscaleup

The networkscaleup package provides a suite of functions to both fit and diagnose the fit of several popular models for Aggregated Relational Data (ARD). These models are fit using Stan (RStan) and glmmTMB.

Installation

networkscaleup can be installed from CRAN with

install.packages("networkscaleup)

You can install the development version of networkscaleup from GitHub with:

# install.packages("pak")
pak::pak("ilaga/networkscaleup")

Simulating Data

The networkscaleup package allows simulation of synthetic ARD from commonly used models.

## simulate some simple data
library(networkscaleup)

set.seed(2)
sim_dat <- make_ard(family = "poisson")

We can then fit the (true) model to this data and evaluate the fit of this model. Several diagnostics are provided, including rootograms and residual computation.

pois_fit_list <- fit_mle(sim_dat$ard, family = "poisson")

pois_root <- hang_rootogram_ard(
  ard = sim_dat$ard,
  model_fit = pois_fit_list
)

pois_root

We see that the hanging rootogram indicates good fit, as would be expected. More flexible models and additional model checking diagnostics are also available.

Copy Link

Version

Install

install.packages('networkscaleup')

Monthly Downloads

11,996

Version

0.2-1

License

GPL (>= 3)

Issues

Pull Requests

Stars

Forks

Maintainer

Ian Laga

Last Published

December 10th, 2025

Functions in networkscaleup (0.2-1)

rqr_pois_logs

compute numerically stable Poisson rqr
rqr_nbinom_logs

compute numerically stable negative binomial rqr
tw_group_corr_test

Tracy-Widom test for residual group correlation
scaling

Scale raw log degree and log prevalence estimates
construct_pearson

Compute Pearson Residuals for ARD matrix and fitted model
dispersion_metric

Dispersion Metric for Fitted ARD Model
get_surrogate

Compute Surrogate Residuals for ARD Models
cov_plots

Covariance plots
correlatedStan

Fit ARD using the uncorrelated or correlated model in Stan This function fits the ARD using either the uncorrelated or correlated model in Laga et al. (2021) in Stan. The population size estimates and degrees are scaled using a post-hoc procedure.
example_data

Simulated ARD data set with z and x.
killworth

Fit Killworth models to ARD. This function estimates the degrees and population sizes using the plug-in MLE and MLE estimator.
fit_mle

Fit basic Poisson and Negative Binomial models using glmmTMB
hang_rootogram_ard

Hanging Rootogram for Fitted ARD Model
overdispersedStan

Fit ARD using the Overdispersed model in Stan
overdispersed

Fit Overdispersed model to ARD (Gibbs-Metropolis)
make_ard

Generate simulated ARD
plot_fitted

Plot residuals against fitted values
residual_correlation

Construction Residual (row/column) correlation matrix
construct_rqr

Compute Randomized Quantile Residuals for ARD Models
residual_heatmap

Construct heatmap of residuals
log_mix_uniform

log computed uniform quantile
make_ard_tidy

Construct tibble from ARD matrix
networkscaleup

The 'networkscaleup' package.