Learn R Programming

netdiffuseR (version 1.22.6)

bootnet: Network Bootstrapping

Description

Implements the bootstrapping method described in Snijders and Borgatti (1999). This function is essentially a wrapper of boot.

Usage

resample_graph(graph, self = NULL, useR = FALSE, ...)

bootnet(graph, statistic, R, resample.args = list(self = FALSE), ...)

# S3 method for diffnet_bootnet c(..., recursive = FALSE)

# S3 method for diffnet_bootnet print(x, ...)

# S3 method for diffnet_bootnet hist( x, main = "Empirical Distribution of Statistic", xlab = expression(Values ~ of ~ t), breaks = 20, annotated = TRUE, b0 = expression(atop(plain("") %up% plain("")), t[0]), b = expression(atop(plain("") %up% plain("")), t[]), ask = TRUE, ... )

# S3 method for diffnet_bootnet plot(x, y, ...)

Value

A list of class diffnet_bootnet containing the following:

graph

The graph passed to bootnet.

p.value

The resulting p-value of the test (see details).

t0

The observed value of the statistic.

mean_t

The average value of the statistic applied to the simulated networks.

var_t

A vector of length length(t0). Bootstrap variances.

R

Number of simulations.

statistic

The function statistic passed to bootnet.

boot

A boot class object as return from the call to boot.

resample.args

The list resample.args passed to bootnet.

Arguments

graph

Any class of accepted graph format (see netdiffuseR-graphs).

self

Logical scalar. When TRUE autolinks (loops, self edges) are allowed (see details).

useR

Logical scalar. When TRUE, autolinks are filled using an R based rutine. Otherwise it uses the Rcpp implementation (default). This is intended for testing only.

...

Further arguments passed to the method (see details).

statistic

A function that returns a vector with the statistic(s) of interest. The first argument must be the graph, and the second argument a vector of indices (see details)

R

Number of reps

resample.args

List. Arguments to be passed to resample_graph

recursive

Ignored

x

A diffnet_bootnet class object.

main

Character scalar. Title of the histogram.

xlab

Character scalar. x-axis label.

breaks

Passed to hist.

annotated

Logical scalar. When TRUE marks the observed data average and the simulated data average.

b0

Character scalar. When annotated=TRUE, label for the value of b0.

b

Character scalar. When annotated=TRUE, label for the value of b.

ask

Logical scalar. When TRUE, asks the user to type <Enter> to see each plot (as many as statistics where computed).

y

Ignored.

Details

Just like the boot function of the boot package, the statistic that is passed must have as arguments the original data (the graph in this case), and a vector of indicides. In each repetition, the graph that is passed is a resampled version generated as described in Snijders and Borgatti (1999).

When self = FALSE, for pairs of individuals that haven been drawn more than once the algorithm, in particular, resample_graph, takes care of filling these pseudo autolinks that are not in the diagonal of the network. By default it is assumed that these pseudo-autolinks depend on whether the original graph had any, hence, if the diagonal has any non-zero value the algorithm assumes that self = TRUE, skiping the 'filling algorithm'. It is important to notice that, in order to preserve the density of the original network, when assigning an edge value to a pair of the form \((i,i)\) (pseudo-autolinks), such is done with probabilty proportional to the density of the network, in other words, before choosing from the existing list of edge values, the algorithm decides whether to set a zero value first.

The vector of indices that is passed to statistic, an integer vector with range 1 to \(n\), corresponds to the drawn sample of nodes, so the user can, for example, use it to get a subset of a data.frame that will be used with the graph.

The `plot.diffnet_bootnet` method is a wrapper for the `hist` method.

References

Snijders, T. A. B., & Borgatti, S. P. (1999). Non-Parametric Standard Errors and Tests for Network Statistics. Connections, 22(2), 1–10. Retrieved from https://www.stats.ox.ac.uk/~snijders/Snijders_Borgatti.pdf

See Also

Other Functions for inference: moran(), struct_test()

Examples

Run this code
# Computing edgecount -------------------------------------------------------
set.seed(13)
g <- rgraph_ba(t=99)

ans <- bootnet(g, function(w, ...) length(w@x), R=100)
ans

# Generating

Run the code above in your browser using DataLab