R Under development (unstable) (2025-06-14 r88315 ucrt) -- "Unsuffered Consequences" Copyright (C) 2025 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > # File tests/tergm_offset_tests.R in package tergm, part of the Statnet suite > # of packages for network analysis, https://statnet.org . > # > # This software is distributed under the GPL-3 license. It is free, open > # source, and has the attribution requirements (GPL Section 7) at > # https://statnet.org/attribution . > # > # Copyright 2008-2025 Statnet Commons > ################################################################################ > library(statnet.common) Attaching package: 'statnet.common' The following objects are masked from 'package:base': attr, order, replace > opttest({ + library(tergm) + data(florentine) + net <- flobusiness + summary(net ~ edges+degree(3)) + set.seed(3) + + # default initialization + mod1 <- tergm(flobusiness ~ Form(~edges) + Form(~offset(degree(3))) + Persist(~offset(edges)), + offset.coef=c(0.8,log(9)), + targets="formation", + estimate="EGMME" + ) + + # init.method set to zeros works + mod2 <- tergm(flobusiness ~ Form(~edges + offset(degree(3))) + Persist(~offset(edges)), + offset.coef=c(0.8,log(9)), + targets="formation", + estimate="EGMME",control=control.tergm(init.method='zeros')) + + # this works, auto defaulting SAN coefs if they are different from stergm init.form + mod3 <- tergm(flobusiness ~ Form(~edges) + Form(~offset(degree(3))) + Persist(~offset(edges)), + offset.coef=c(0.8,log(9)), + targets="formation", estimate="EGMME", + control=control.tergm(init=c(-3,0.8,log(9))) + ) + + # we can explicitly specify the target and target stats + mod4 <- tergm(flobusiness ~ Form(~edges) + Form(~offset(degree(3))) + Persist(~offset(edges)), + offset.coef=c(0.8,log(9)), + targets=~edges, target.stats = 15, + estimate="EGMME", + control=control.tergm(init=c(-3,0.8,log(9))) + ) + + sapply(list(mod1, mod2, mod3, mod4), function(x) coef(x)) + + for (mod in list(mod1, mod2, mod3, mod4)) { + print(apply(simulate(mod, monitor=~edges+degree(3), output="stats", time.slices=200), 2, mean)) + } + }, testname='target_offset') target_offset test(s) skipped. Set ENABLE_statnet_TESTS environment variable to run. > > proc.time() user system elapsed 0.31 0.07 0.37