rpanet {wdnet} | R Documentation |
Generate PA networks.
Description
Generate preferential attachment (PA) networks with linear or non-linear preference functions.
Usage
rpanet(
nstep,
initial.network = list(edgelist = matrix(c(1, 2), nrow = 1), edgeweight = 1, directed =
TRUE),
control,
method = c("binary", "linear", "bagx", "bag")
)
Arguments
nstep |
Number of steps. |
initial.network |
A |
control |
An |
method |
Which method to use: |
Value
Returns a wdnet
object that includes the following components:
-
directed
: Logical, whether the network is directed. -
weighted
: Logical, whether the network is weighted. -
edgelist
: A two-column matrix representing the edges. -
edge.attr
: A data frame including edge weights and edge scenarios (0: from initial network; 1:alpha
; 2:beta
; 3:gamma
; 4:xi
; 5;rho
; 6: reciprocal edge). -
node.attr
: A data frame including node out- and in-strength, node source and target preference scores (for directed networks), node strength and preference scores (for undirected networks), and node group (if applicable). -
newedge
: The number of new edges at each step, including reciprocal edges. -
control
: Anrpacontrol
object that is used to generate the network.
Note
The binary
method implements binary search algorithm;
linear
represents linear search algorithm; bag
method
implements the algorithm from Wan et al. (2017); bagx
puts all the
edges into a bag, then samples edges and find the source/target node of the
sampled edge.
References
Wan P, Wang T, Davis RA, Resnick SI (2017). Fitting the Linear Preferential Attachment Model. Electronic Journal of Statistics, 11(2), 3738–3780.
Examples
# Control edge scenario and edge weight through rpa_control_scenario()
# and rpa_control_edgeweight(), respectively,
# while keeping rpa_control_newedge(),
# rpa_control_preference() and rpa_control_reciprocal() as default.
set.seed(123)
control <- rpa_control_scenario(alpha = 0.5, beta = 0.5) +
rpa_control_edgeweight(
sampler = function(n) rgamma(n, shape = 5, scale = 0.2)
)
ret1 <- rpanet(nstep = 1e3, control = control)
# In addition, set node groups and probability of creating reciprocal edges.
control <- control + rpa_control_reciprocal(
group.prob = c(0.4, 0.6),
recip.prob = matrix(runif(4), ncol = 2)
)
ret2 <- rpanet(nstep = 1e3, control = control)
# Further, set the number of new edges in each step as Poisson(2) + 1 and use
# ret2 as a seed network.
control <- control + rpa_control_newedge(
sampler = function(n) rpois(n, lambda = 2) + 1
)
ret3 <- rpanet(nstep = 1e3, initial.network = ret2, control = control)