incidence.from.probability: Generates an incidence matrix with a given cell-filling...

View source: R/incidence.from.probability.R

incidence.from.probabilityR Documentation

Generates an incidence matrix with a given cell-filling probability

Description

incidence.from.probability generates a random incidence matrix in which each cell is filled with a 1 with a given probability.

Usage

incidence.from.probability(
  R,
  C,
  P = 0,
  constrain = TRUE,
  class = "matrix",
  narrative = FALSE
)

Arguments

R

integer: number of rows

C

integer: number of columns

P

numeric: probability that a cell contains a 1; if P = 0 a probability will be chosen randomly

constrain

boolean: ensure that no rows or columns sum to 0 (i.e., contain all 0s) or to 1 (i.e., contain all 1s)

class

string: the class of the returned backbone graph, one of c("matrix", "Matrix", "igraph").

narrative

boolean: TRUE if suggested text & citations should be displayed.

Value

An incidence matrix of class matrix or Matrix, or a bipartite graph of class igraph.

References

Neal, Z. P., Domagalski, R., and Sagan, B. 2021. Comparing alternatives to the fixed degree sequence model for extracting the backbone of bipartite projections. Scientific Reports, 11, 23929. doi: 10.1038/s41598-021-03238-3

Neal, Z. P. 2022. incidentally: An R package to generate incidence matrices and bipartite graphs. OSF Preprints doi: 10.31219/osf.io/ectms

Examples

I <- incidence.from.probability(R = 10, C = 10)
I <- incidence.from.probability(R = 10, C = 10, P = .5)
I <- incidence.from.probability(R = 10, C = 10, P = .5,
     class = "igraph", narrative = TRUE)

incidentally documentation built on Feb. 16, 2023, 6:04 p.m.