Description Usage Arguments Value Examples
Perform social network simulations
1 2 3 4 5 6 7 8 9 10 11 |
Adj |
integer matrix, the reference adjacency matrix to base edge probabilities on. Users can either:
|
samp.effort |
integer scalar, the sampling effort, or number of scans, that led to obtaining
of |
mode |
character scalar, specifies what igraph network
|
n.scans |
integer scalar, number of scans to generate in the simulation |
exp.design |
|
... |
additional arguments to be passed to the function. Specifically, this is used at the
moment to pass more than one |
edge.Prob |
optional. An
|
alpha.prior |
positive numeric scalar, the parameter alpha (added to shape1 in |
beta.prior |
positive numeric scalar, the parameter beta (added to shape2 in |
a scanList
object, primarily a 3 dimensional array representing the (binary) adjacency
matrices (coded within the first two dimensions of the 3D-array) obtained at each simulated
scan (coded as the 3rd dimension of the 3D-array), and a list of attributes.
scanList
objects have this common structure:
the 3D-array where the first 2 dimensions are the adjacency matrices (with the node names
from Adj
) and the 3rd dimension is the simulated scan number
an attribute named attrs
: a list of objects - see attrs
as a flat list of attributes -
that are recorded throughout the simulation and subsequent experimental manipulations.
We provide an equivalent to r base's attr()
function - attrs()
- to retrieve
scanList objects' named attributes contained in their attrs
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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | set.seed(42)
n <- 5L
samp.effort <- 241L
# Adjacency matrix import
## random directed adjacency matrix
Adj <- sample(1:samp.effort,n * n) |>
matrix(nrow = 5,dimnames = list(letters[1:n],letters[1:n]))
diag(Adj) <- 0L
Adj
## manual lower adjacency matrix
Adj <- c(0, 0, 0, 0,0,
1, 0, 0, 0,0,
2, 3, 0, 0,0,
4, 5, 6, 0,0,
7, 8, 9,10,0) |>
matrix(nrow = 5,byrow = TRUE,dimnames = list(as.character(1:n),as.character(1:n)))
Adj
## upper adjacency matrix imported from ASNR (https://github.com/bansallab/asnr)
## Not run:
Adj <- import_from_asnr(class = "Mammalia",
species = "kangaroo_proximity_weighted",
output = "adjacency",type = "upper")
Adj
## End(Not run)
# this is retrieving and importing this matrix:
node_names <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17) |> as.character()
Adj <-
c(0, 21, 10, 45, 54, 7, 16, 1, 3, 4, 7, 3, 2, 3, 3, 0, 0,
0, 0, 9, 19, 20, 3, 9, 1, 10, 4, 11, 2, 2, 2, 6, 0, 0,
0, 0, 0, 8, 10, 3, 5, 1, 9, 4, 10, 0, 0, 0, 3, 2, 0,
0, 0, 0, 0, 45, 7, 17, 1, 1, 3, 6, 3, 2, 3, 4, 0, 0,
0, 0, 0, 0, 0, 6, 17, 1, 3, 4, 6, 1, 2, 3, 3, 1, 0,
0, 0, 0, 0, 0, 0, 4, 1, 2, 2, 3, 3, 3, 1, 4, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 5, 3, 1, 3, 3, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 9, 1, 0, 0, 2, 0, 1,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 5, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) |>
matrix(nrow = 17,byrow = TRUE,dimnames = list(node_names,node_names))
Adj
# social network simulations
## theoretical scans
sL <- simunet(Adj = Adj,samp.effort = samp.effort,mode = "upper",n.scans = 120L)
sL
sL |> sum_scans()
## group-scan sampling
### Designing the experiment: setting a constant probability of not observing edges
group.scan <- design_sampling(method = "group",sampling = 0.8)
### simulation can be directly run through the simunet() function
simunet(Adj = Adj,samp.effort = samp.effort,mode = "upper",n.scans = 120L,
exp.design = group.scan)
### or the experiment can be applied to a theoretical scanList object
group.sL <- perform_exp(sL,group.scan)
group.sL |> count_nonNA()
group.sL |> sum_scans()
## add more scans, perform even focal sampling, then remove the overall most peripheral node
foc.peri_removed <- design_exp(function(x) add_scans(x,200),
design_sampling(method = "focal",sampling = "even"),
remove_mostPeripheral
)
### or the experiment can be applied to a theoretical scanList object
foc.peri_removed.sL <- perform_exp(sL,foc.peri_removed)
foc.peri_removed.sL |> count_nonNA()
foc.peri_removed.sL |> sum_scans()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.