nodal_attributes-API: Helper functions for specifying nodal attribute levels

Description Usage Arguments Details Value Functions Examples

Description

These functions are meant to be used in EgoStat and other implementations to provide the user with a way to extract nodal attributes and select their levels in standardized and flexible ways. They are intended to parallel ergm::nodal_attributes-API of ergm package.

ergm.ego_get_vattr extracts and processes the specified nodal attribute vector. It is strongly recommended that check.ErgmTerm()'s corresponding vartype="function,formula,character" (using the ERGM_VATTR_SPEC constant).

ergm.ego_attr_levels filters the levels of the attribute. It is strongly recommended that check.ErgmTerm()'s corresponding vartype="function,formula,character,numeric,logical,AsIs,NULL" (using the ERGM_LEVELS_SPEC constant).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
ergm.ego_get_vattr(
  object,
  df,
  accept = "character",
  multiple = if (accept == "character") "paste" else "stop",
  ...
)

## S3 method for class 'character'
ergm.ego_get_vattr(
  object,
  df,
  accept = "character",
  multiple = if (accept == "character") "paste" else "stop",
  ...
)

## S3 method for class ''function''
ergm.ego_get_vattr(
  object,
  df,
  accept = "character",
  multiple = if (accept == "character") "paste" else "stop",
  ...
)

## S3 method for class 'formula'
ergm.ego_get_vattr(
  object,
  df,
  accept = "character",
  multiple = if (accept == "character") "paste" else "stop",
  ...
)

ergm.ego_attr_levels(object, attr, egor, levels = sort(unique(attr)), ...)

## S3 method for class 'numeric'
ergm.ego_attr_levels(object, attr, egor, levels = sort(unique(attr)), ...)

## S3 method for class 'logical'
ergm.ego_attr_levels(object, attr, egor, levels = sort(unique(attr)), ...)

## S3 method for class 'AsIs'
ergm.ego_attr_levels(object, attr, egor, levels = sort(unique(attr)), ...)

## S3 method for class 'character'
ergm.ego_attr_levels(object, attr, egor, levels = sort(unique(attr)), ...)

## S3 method for class ''NULL''
ergm.ego_attr_levels(object, attr, egor, levels = sort(unique(attr)), ...)

## S3 method for class 'matrix'
ergm.ego_attr_levels(object, attr, egor, levels = sort(unique(attr)), ...)

## S3 method for class ''function''
ergm.ego_attr_levels(object, attr, egor, levels = sort(unique(attr)), ...)

## S3 method for class 'formula'
ergm.ego_attr_levels(object, attr, egor, levels = sort(unique(attr)), ...)

COLLAPSE_SMALLEST(object, n, into)

Arguments

object

An argument specifying the nodal attribute to select or which levels to include.

df

Table of egos or of alters.

accept

A character vector listing permitted data types for the output. See the Details section for the specification.

multiple

Handling of multiple attributes or matrix or data frame output. See the Details section for the specification.

...

Additional argument to the functions of network or to the formula's environment.

attr

A vector of length equal to the number of nodes, specifying the attribute vector.

egor

An egor object.

levels

Starting set of levels to use; defaults to the sorted list of unique attributes.

Details

The accept argument is meant to allow the user to quickly check whether the output is of an acceptable class or mode. Typically, if a term accepts a character (i.e., categorical) attribute, it will also accept a numeric one, treating each number as a category label. For this reason, the following outputs are defined:

"character"

Accept any mode or class (since it can beconverted to character).

"numeric"

Accept real, integer, or logical.

"logical"

Accept logical.

"integer"

Accept integer or logical.

"natural"

Accept a strictly positive integer.

"0natural"

Accept a nonnegative integer or logical.

"nonnegative"

Accept a nonnegative number or logical.

"positive"

Accept a strictly positive number or logical.

"paste"

Paste together with dot as the separator.

"stop"

Fail with an error message.

"matrix"

Construct and/or return a matrix whose rows correspond to vertices.

Value

ergm.ego_get_vattr returns a vector of length equal to the number of nodes giving the selected attribute function. It may also have an attribute "name", which controls the suggested name of the attribute combination.

ergm.ego_attr_levels returns a vector of levels to use and their order.

Functions

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
data(florentine)
flomego <- as.egor(flomarriage)
ergm.ego_get_vattr("priorates", flomego)
ergm.ego_get_vattr(~priorates, flomego)
ergm.ego_get_vattr(c("wealth","priorates"), flomego)
ergm.ego_get_vattr(~priorates>30, flomego)
(a <- ergm.ego_get_vattr(~cut(priorates,c(-Inf,0,20,40,60,Inf),label=FALSE)-1, flomego))
ergm.ego_attr_levels(NULL, a, flomego)
ergm.ego_attr_levels(-1, a, flomego)
ergm.ego_attr_levels(1:2, a, flomego)
ergm.ego_attr_levels(I(1:2), a, flomego)

statnet/ergm.ego documentation built on April 26, 2021, 4:46 a.m.