R Under development (unstable) (2024-02-18 r85939 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 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-2024 Statnet Commons > ################################################################################ > library(latentnet) Loading required package: network 'network' 1.18.2 (2023-12-04), 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.6.0 (2023-12-17), 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.11.0 (2024-02-19), 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 > > 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.1037666 0.1932808 0.3728236 beta.1 -0.1037666 1.0000000 -0.5367235 -0.4766429 beta.2 0.1932808 -0.5367235 1.0000000 0.2434301 receiver.1 0.3728236 -0.4766429 0.2434301 1.0000000 Lag 10 lpY beta.1 beta.2 receiver.1 lpY 0.11195657 -0.06445041 0.1280613 0.07193615 beta.1 -0.07126792 0.28174716 -0.1790951 -0.18245926 beta.2 0.10427313 -0.18907559 0.3194069 0.13205458 receiver.1 0.08558620 -0.19984796 0.1341321 0.20292448 [[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 20 6210 600 10.4 beta.1 40 7800 600 13.0 beta.2 40 8480 600 14.1 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.2827 -3.0055 -1.6212 < 2.2e-16 *** nodematch.group 3.0586 2.3821 3.7483 < 2.2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Receiver effect variance: 1.010678. Overall BIC: 286.0447 Likelihood BIC: 245.5269 Receiver effect BIC: 40.51786 Covariate coefficients MKL: Estimate (Intercept) -2.099603 nodematch.group 2.870347 > # 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 8.67 0.50 9.15