Skip to content

Commit

Permalink
Merge branch 'master' into 1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
krivit committed Oct 10, 2024
2 parents aff8f0a + a3bcba4 commit 766af19
Show file tree
Hide file tree
Showing 57 changed files with 489 additions and 471 deletions.
55 changes: 42 additions & 13 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
# debug: compile package with -DDEBUG and -UNDEBUG
#
# covr: run in covr mode may be used with 'full' but probably not with others.
#
#
# Typical public, private, and release configurations are provided in the variables below.

on: [push, pull_request]

Expand All @@ -37,6 +40,21 @@ name: R-CMD-check
env:
PUBLIC: ''
PRIVATE: ''
PUBLIC_CONFIG: '{"config":[
{"os":"windows-latest", "r":"release", "timeout":360, "flags":"binaries"},
{"os":"macOS-latest", "r":"release", "timeout":360, "flags":"binaries, ubsan"},
{"os":"ubuntu-latest", "r":"release", "timeout":360, "flags":"full, ubsan, debug"},
{"os":"ubuntu-latest", "r":"devel", "timeout":360, "flags":"vignettes, remote"},
{"os":"ubuntu-latest", "r":"release", "timeout":360, "flags":"full, covr"}]}'
RELEASE_CONFIG: '{"config":[
{"os":"windows-latest", "r":"release", "timeout":360, "flags":"binaries, vignettes, remote, strict"},
{"os":"macOS-latest", "r":"release", "timeout":360, "flags":"binaries, ubsan, vignettes, remote, strict"},
{"os":"ubuntu-latest", "r":"release", "timeout":360, "flags":"full, ubsan, debug, strict"},
{"os":"ubuntu-latest", "r":"devel", "timeout":360, "flags":"vignettes, remote, strict"},
{"os":"ubuntu-latest", "r":"release", "timeout":360, "flags":"full, covr, strict"}]}'
PRIVATE_CONFIG: '{"config":[
{"os":"ubuntu-latest", "r":"release", "timeout":10, "flags":"none"}
]}'

jobs:
Set-Matrix-Private:
Expand Down Expand Up @@ -76,17 +94,10 @@ jobs:
run: |
if [[ "${{ env.IAM }}" == 'public' ]] # Public: full set.
then
config='{"config":[
{"os":"windows-latest", "r":"release", "timeout":360, "flags":"binaries, remote, vignettes, strict"},
{"os":"macOS-latest", "r":"release", "timeout":360, "flags":"binaries, ubsan, remote, vignettes, strict"},
{"os":"ubuntu-latest", "r":"release", "timeout":360, "flags":"full, ubsan, debug, strict"},
{"os":"ubuntu-latest", "r":"devel", "timeout":360, "flags":"vignettes, remote, strict"},
{"os":"ubuntu-latest", "r":"release", "timeout":360, "flags":"full, covr"}]}'
config='${{ env.RELEASE_CONFIG }}'
elif [[ "${{ env.FOUND_PUBLIC }}" != '0' ]] # Private with no public analogue: reduced set.
then
config='{"config":[
{"os":"ubuntu-latest", "r":"release", "timeout":10, "flags":"none"}
]}'
config='${{ env.PRIVATE_CONFIG }}'
else # Private with public analogue: no checking.
config=''
fi
Expand Down Expand Up @@ -123,7 +134,7 @@ jobs:
fi
shell: bash

- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
Expand All @@ -148,6 +159,7 @@ jobs:
any::rcmdcheck
any::covr
any::V8
any::xml2
needs: |
check
coverage
Expand All @@ -169,7 +181,7 @@ jobs:

- name: Upload build results
if: contains(matrix.config.flags, 'binaries') && !failure()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-binaries
path: binaries
Expand Down Expand Up @@ -243,7 +255,7 @@ jobs:

- name: Upload check results
if: contains(matrix.config.flags, 'covr') == false && failure()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: |
Expand All @@ -257,5 +269,22 @@ jobs:
_R_CHECK_CRAN_INCOMING_REMOTE_: false
_R_CHECK_FORCE_SUGGESTS_: ${{ runner.os != 'macOS' }} # Rmpi is not available on macOS.
ENABLE_statnet_TESTS: ${{ contains(matrix.config.flags, 'full') }}
run: covr::codecov(type=c("tests","examples"))
run: |
cov <- covr::package_coverage(
type=c("tests", "examples"),
quiet = FALSE,
clean = FALSE,
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
)
covr::to_cobertura(cov)
shell: Rscript {0}

- name: Upload coverage results
if: contains(matrix.config.flags, 'covr')
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }}
file: ./cobertura.xml
plugin: noop
disable_search: true
token: ${{ secrets.CODECOV_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,6 @@ dkms.conf

# GDB history files
.gdb_history

# Data generation log files
data-raw/*.log
31 changes: 16 additions & 15 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: ergm.ego
Version: 1.1.0
Date: 2023-05-30
Version: 1.1.1
Date: 2024-10-11
Title: Fit, Simulate and Diagnose Exponential-Family Random Graph Models to Egocentrically Sampled Network Data
Authors@R: c(
person(c("Pavel", "N."), "Krivitsky", role=c("aut","cre"), email="pavel@statnet.org", comment=c(ORCID="0000-0002-9101-3362")),
Expand All @@ -12,27 +12,28 @@ Authors@R: c(
person("Chad", "Klumb", role=c("ctb"), email="cklumb@gmail.com"))
Depends:
R (>= 4.1.0),
ergm (>= 4.5.0),
egor,
network (>= 1.17.1)
LinkingTo: ergm
ergm (>= 4.7.1),
egor (>= 1.24.2),
network (>= 1.18.2)
Imports:
statnet.common (>= 4.5.0),
RColorBrewer (>= 1.1.2),
purrr (>= 0.3.2),
tibble (>= 2.1.1),
dplyr,
survey,
statnet.common (>= 4.10.0),
RColorBrewer (>= 1.1-3),
purrr (>= 1.0.2),
tibble (>= 3.2.1),
dplyr (>= 1.1.4),
survey (>= 4.4-2),
stats,
methods
LinkingTo:
ergm
Suggests:
testthat (>= 2.1.1),
covr (>= 3.2.1)
testthat (>= 3.2.1.1),
covr (>= 3.6.4)
Description: Utilities for managing egocentrically sampled network data and a wrapper around the 'ergm' package to facilitate ERGM inference and simulation from such data. See Krivitsky and Morris (2017) <doi:10.1214/16-AOAS1010>.
License: GPL-3 + file LICENSE
URL: https://statnet.org
BugReports: https://github.com/statnet/ergm.ego/issues
RoxygenNote: 7.2.3
RoxygenNote: 7.3.2.9000
Roxygen: list(markdown = TRUE)
Encoding: UTF-8
LazyData: true
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ Martina Morris, University of Washington

The 'statnet' development team

Copyright 2015-2023
Copyright 2015-2024
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ S3method(ergm.ego_get_vattr,"function")
S3method(ergm.ego_get_vattr,character)
S3method(ergm.ego_get_vattr,formula)
S3method(gof,ergm.ego)
S3method(logLik,ergm.ego)
S3method(mixingmatrix,egor)
S3method(na.omit,egor)
S3method(plot,gof.ergm.ego)
Expand Down
51 changes: 41 additions & 10 deletions R/EgoStat.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# open source, and has the attribution requirements (GPL Section 7) at
# https://statnet.org/attribution .
#
# Copyright 2015-2023 Statnet Commons
# Copyright 2015-2024 Statnet Commons
################################################################################
# An EgoStat.* function takes an egor object and returns a matrix of
# h(e[i]) values, with egos in rows and elements of h(e[i]) in
Expand Down Expand Up @@ -153,17 +153,17 @@ split_aaties_by_ego <- function(x, egor){
h
}

#' \code{\link[ergm]{ergm}} Terms Implemented for
#' \code{\link{egor}}
#' [ergm()] Terms Implemented for
#' [`egor`]
#'
#' This page describes the \code{\link[ergm]{ergm}} terms (and hence network
#' This page describes the [ergm()] terms (and hence network
#' statistics) for which inference based on egocentrically sampled data is
#' implemented in \code{ergm.ego} package. Other packages may add their own
#' implemented in \CRANpkg{ergm.ego} package. Other packages may add their own
#' terms. These functions should not be called by the end-user.
#'
#' The current recommendation for any package implementing additional
#' egocentric calculator terms is to create a help file with a name or alias
#' \code{ergm.ego-terms}, so that \code{help("ergm.ego-terms")} will
#' \code{\link{ergm.ego-terms}}, so that \code{help("ergm.ego-terms")} will
#' list egocentric ERGM terms available from all loaded packages.
#'
#'
Expand All @@ -178,9 +178,9 @@ split_aaties_by_ego <- function(x, egor){
#' \describe{ \item{Special-purpose terms:}{ \describe{
#' \item{netsize.adj(edges=+1, mutual=0, transitiveties=0,
#' cyclicalties=0)}{A special-purpose term equivalent to a linear
#' combination of \code{\link[ergm]{edges-ergmTerm}},
#' \code{\link[ergm]{mutual-ergmTerm}}, \code{\link[ergm]{transitiveties-ergmTerm}}, and
#' \code{\link[ergm]{cyclicalties-ergmTerm}}, to house the network-size
#' combination of \code{\link[ergm:edges-ergmTerm]{edges}},
#' \code{\link[ergm:mutual-ergmTerm]{mutual}}, \code{\link[ergm:transitiveties-ergmTerm]{transitiveties}}, and
#' \code{\link[ergm:cyclicalties-ergmTerm]{cyclicalties}}, to house the network-size
#' adjustment offset. This term is added to the model automatically
#' and should not be used in the model formula directly. } } }
#'
Expand All @@ -192,6 +192,7 @@ split_aaties_by_ego <- function(x, egor){
#' * `nodematch`
#' * `nodemix`
#' * `absdiff`
#' * `absdiffcat`
#' * `degree`
#' * `degrange`
#' * `concurrent`
Expand All @@ -215,7 +216,7 @@ split_aaties_by_ego <- function(x, egor){
#' evaluated, some inferential results and standard error calculation
#' methods may not be applicable.
#'
#' @seealso \code{\link[ergm]{ergm-terms}}
#' @seealso [`ergmTerm`]
#' @keywords models
NULL

Expand Down Expand Up @@ -397,6 +398,36 @@ EgoStat.absdiff <- function(egor, attr, pow=1){
h
}

EgoStat.absdiffcat <- function(egor, attr, base=NULL, levels=NULL){
if(!missing(base)) message("In term `absdiffcat' in package `ergm.ego': Argument \"base\" has been superseded by \"levels\" and it is recommended to use the latter. Note that its interpretation may be different.")

egos <- as_tibble(egor$ego)
alters <- egor$alter

xe <- ergm.ego_get_vattr(attr, egos)
xa <- ergm.ego_get_vattr(attr, alters)

attrname <- attributes(xe)$name

ux <- unique(c(xe,xa))
u <- sort(unique(as.vector(abs(outer(ux,ux,"-")))),na.last=NA)
u <- u[u>0]
if(missing(levels) && any(NVL(base,0)!=0)) u <- u[-base]

levs <- ergm.ego_attr_levels(levels, u, egor)
nlevs <- length(levs)

if (nlevs==0)
stop("Argument to `absdiffcat' has too few distinct differences.")

xal <- split_alters_by_ego(xa, egor)

h <- .mapply_col(function(e,a) .extabulate(.matchNA(abs(e-a), levs, 0), nbins=nlevs)/2, xe, xal, SIMPLIFY=TRUE)
colnames(h) <- paste("absdiff",attrname,levs,sep=".")
attr(h, "order") <- 1
h
}

EgoStat.degree <- function(egor, d, by=NULL, homophily=FALSE, levels=NULL){
## if(any(d==0)) warning("degree(0) (isolate) count statistic depends strongly on the specified population network size.")

Expand Down
2 changes: 1 addition & 1 deletion R/EgoStat.duration.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# open source, and has the attribution requirements (GPL Section 7) at
# https://statnet.org/attribution .
#
# Copyright 2015-2023 Statnet Commons
# Copyright 2015-2024 Statnet Commons
################################################################################
EgoStat.mean.age <- function(egor, emptyval=0){
startcol <- attr(egor,"alter_design")$startcol
Expand Down
Loading

0 comments on commit 766af19

Please sign in to comment.