draw_edgeProb: Draw edge presence probability matrix from posterior Beta...

Description Usage Arguments Details Value See Also Examples

View source: R/edgeProb.R

Description

Edge presence probabilities are drawn from a posterior Beta distribution Beta(α,β), in which parameters α and β correspond to total (pseudo-)counts of the times when an edge was 1 and 0, respectively. By default, an uninformative prior (Jeffrey's prior, i.e. α.prior = β.prior = 0.5) is used, and is added to the observed edge weights in Adj, so that:

α = Adj + α.prior, β = samp.effort - Adj + β.prior

where samp.effort - Adj is a positive or null integer.

Usage

1
2
3
4
5
6
7
draw_edgeProb(
  Adj,
  samp.effort,
  Adj.subfun = NULL,
  alpha.prior = 0.5,
  beta.prior = 0.5
)

Arguments

Adj

integer matrix, the adjacency matrix (see simunet())

samp.effort

integer scalar, the sampling effort (see simunet())

Adj.subfun

function, the matrix subsetting function relevant for the adjacency matrix mode (see simunet())

alpha.prior

positive numeric scalar, the parameter alpha (added to shape1 in rbeta()) used in the prior beta distribution. See rbeta()

beta.prior

positive numeric scalar, the parameter beta (added to shape2 in rbeta()) used in the prior beta distribution. See rbeta()

Details

For Bayesian inference and conjugation, a prior beta distribution Beta(α.prior,β.prior) is used, with default

α.prior = β.prior = 0.5

which corresponds to Jeffrey's prior. Alternative parametrization can rely on

α.prior = β.prior = 1

for a prior beta distribution equivalent to a uniform distribution over [0,1].

In simunet(), a new edgeProb is drawn before simulating binary scans. Two scanLists outputted from an identical Adj matrix and samp.effort will result in different edgeProbs, but these edgeProbs are drawn from the same posterior Beta distribution Beta(α,β).

The edgeProb used is stored in the scanList outputted by simunet() as an attribute in the attributes list attrs, and can be retrieved via attrs(scan.list,"edgeProb")).

This procedure is equivalent to drawing a scanList from a Beta-Binomial distribution BetaBinom(n.scans,α,β), but allows "decomposing" the simulated edge weights into a list of binary scans instead of outputting only a new weighted adjacency matrix.

Value

numeric matrix of edge presence probabilities

See Also

simunet().

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# Internally used in `generate_edgeProb()`, itself used in `simunet()`
set.seed(42)
n <- 5L
samp.effort <- 241L

# Adjacency matrix import
## random directed adjacency matrix
Adj <- matrix(sample(1:samp.effort,n * n),
  nrow = 5,dimnames = list(letters[1:n],letters[1:n]))
diag(Adj) <- 0L
Adj

sL <- simunet(Adj = Adj,samp.effort = samp.effort,mode = "directed",n.scans = 20L)
attrs(sL,"edge.Prob")

R-KenK/SimuNet documentation built on Oct. 22, 2021, 1:27 a.m.