R Under development (unstable) (2025-09-10 r88809 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/nolatent.R in package latentnet, 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 2003-2025 Statnet Commons > ################################################################################ > library(latentnet) Loading required package: network 'network' 1.19.0 (2024-12-08), part of the Statnet Project * 'news(package="network")' for changes since last version * 'citation("network")' for citation information * 'https://statnet.org' for help, support, and other information Loading required package: ergm 'ergm' 4.10.1 (2025-08-26), part of the Statnet Project * 'news(package="ergm")' for changes since last version * 'citation("ergm")' for citation information * 'https://statnet.org' for help, support, and other information 'ergm' 4 is a major update that introduces some backwards-incompatible changes. Please type 'news(package="ergm")' for a list of major changes. 'latentnet' 2.12.0 (2025-09-11), part of the Statnet Project * 'news(package="latentnet")' for changes since last version * 'citation("latentnet")' for citation information * 'https://statnet.org' for help, support, and other information NOTE: BIC calculation prior to latentnet 2.7.0 had a bug in the calculation of the effective number of parameters. See help(summary.ergmm) for details. NOTE: Prior to version 2.8.0, handling of fixed effects for directed networks had a bug: the covariate matrix was transposed. > library(statnet.common) Attaching package: 'statnet.common' The following objects are masked from 'package:base': attr, order, replace > > data(sampson) > > monks.nmr<-ergmm(samplike~nodematch("group")+rreceiver) > mcmc.diagnostics(monks.nmr) Chain 1 Lag 0 lpY beta.1 beta.2 receiver.1 lpY 1.0000000 -0.1000986 0.1312203 0.3872573 beta.1 -0.1000986 1.0000000 -0.5449333 -0.4351302 beta.2 0.1312203 -0.5449333 1.0000000 0.2448082 receiver.1 0.3872573 -0.4351302 0.2448082 1.0000000 Lag 10 lpY beta.1 beta.2 receiver.1 lpY 0.10637348 -0.07562939 0.07746423 0.1091578 beta.1 -0.06542921 0.29241804 -0.15792314 -0.1960133 beta.2 0.07496478 -0.13557278 0.21327726 0.1376868 receiver.1 0.09111538 -0.22172493 0.14333851 0.2139628 [[1]] Quantile (q) = 0.025 Accuracy (r) = +/- 0.0125 Probability (s) = 0.95 Burn-in Total Lower bound Dependence (M) (N) (Nmin) factor (I) lpY 30 6480 600 10.8 beta.1 40 7490 600 12.5 beta.2 30 6750 600 11.2 receiver.1 30 6480 600 10.8 > > print(summary(monks.nmr)) NOTE: It is not certain whether it is appropriate to use latentnet's BIC to select latent space dimension, whether or not to include actor-specific random effects, and to compare clustered models with the unclustered model. ========================== Summary of model fit ========================== Formula: samplike ~ nodematch("group") + rreceiver Attribute: edges Model: Bernoulli MCMC sample of size 4000, draws are 10 iterations apart, after burnin of 10000 iterations. Covariate coefficients posterior means: Estimate 2.5% 97.5% 2*min(Pr(>0),Pr(<0)) (Intercept) -2.2813 -2.9851 -1.6307 < 2.2e-16 *** nodematch.group 3.0624 2.3681 3.7908 < 2.2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Receiver effect variance: 1.015566. Overall BIC: 288.6835 Likelihood BIC: 245.5964 Receiver effect BIC: 43.08709 Covariate coefficients MKL: Estimate (Intercept) -1.872355 nodematch.group 2.872666 > # Should produce a meaningful error message. > print(try(plot(monks.nmr))) Error in plot.ergmm(monks.nmr) : Plotting non-latent-space models is not available. [1] "Error in plot.ergmm(monks.nmr) : \n Plotting non-latent-space models is not available.\n" attr(,"class") [1] "try-error" attr(,"condition") > > opttest({ + + monks.dnmr<-ergmm(samplike~nodematch("group",diff=TRUE)+rreceiver) + mcmc.diagnostics(monks.dnmr) + print(summary(monks.dnmr)) + + monks.dnmr2<-ergmm(samplike~nodematch("group",diff=TRUE)+rreceiver,prior=monks.dnmr$prior) + if(!all.equal(monks.dnmr2$prior,monks.dnmr$prior)) stop("Prior specification problem!") + + monks.nm<-ergmm(samplike~nodematch("group")) + mcmc.diagnostics(monks.nm) + print(summary(monks.nm)) + + monks.dnm<-ergmm(samplike~nodematch("group",diff=TRUE)) + mcmc.diagnostics(monks.dnm) + print(summary(monks.dnm)) + + # tests importing of ergm terms with local variable as inputs + set.seed(1) + nw <- samplike + n <- network.size(samplike) + covar <- matrix(rbinom(n^2, 1, 0.2), nrow=n) + covar.nw <- network(covar) + test3 <- ergmm(nw ~ euclidean(d = 2) + edgecov(covar)) + test4 <- ergmm(nw ~ euclidean(d = 2) + edgecov(covar.nw)) + + + }, "Some non-latent-space") Some non-latent-space test(s) skipped. Set ENABLE_statnet_TESTS environment variable to run. > > proc.time() user system elapsed 5.53 0.34 5.79