Learn R Programming

ergm.ego (version 0.5)

as.network.egodata: Construct an Empty ``Template'' Network Consistent with an Egocentric Sample

Description

Taking a egodata object, constructs a network object with no edges whose vertices have the attributes of the egos in the dataset, replicating the egos as needed, and taking into accounts their sampling weights.

Usage

# S3 method for egodata
as.network(x, N, scaling = c("round", "sample"), ...)

Arguments

x

A egodata object.

N

The target number of vertices the output network should have.

scaling

If egodata contains weights or N is not a multiple of number of egos in the sample, it may not be possible, for a finite N to represent each ego exactly according to its relative weight, and scaling controls how the fractional egos are allocated:

"round"

(the default) Rather than treating N as a hard setting, calculate \(N w_i / w_\cdot\) for each ego \(i\) and round it to the nearest integer. Then, the N actually used will be the sum of these rounded freqencies.

"sample"

Resample in proportion to \(w_i\).

Additional arguments, currently unused.

Value

A network object.

See Also

as.egodata.network, which performs the inverse operation.

Examples

Run this code
# NOT RUN {

data(faux.mesa.high)
summary(faux.mesa.high, print.adj = FALSE)

fmh.ego <- as.egodata(faux.mesa.high)

# Same actor attributes
fmh.template <- as.network(fmh.ego, N=network.size(faux.mesa.high))
summary(fmh.template, print.adj = FALSE)

# Twice the actors, same distribution
fmh2.template <- as.network(fmh.ego, N=2*network.size(faux.mesa.high))
summary(fmh2.template, print.adj = FALSE)

# }

Run the code above in your browser using DataLab