Implements the bootstrapping method described in Snijders and Borgatti (1999).
This function is essentially a wrapper of boot
.
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, ...)
A list of class diffnet_bootnet
containing the following:
The graph passed to bootnet
.
The resulting p-value of the test (see details).
The observed value of the statistic.
The average value of the statistic applied to the simulated networks.
A vector of length length(t0)
. Bootstrap variances.
Number of simulations.
The function statistic
passed to bootnet
.
A boot
class object as return from the call to boot
.
The list resample.args
passed to bootnet
.
Any class of accepted graph format (see netdiffuseR-graphs
).
Logical scalar. When TRUE
autolinks (loops, self edges) are allowed (see details).
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).
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)
Number of reps
List. Arguments to be passed to resample_graph
Ignored
A diffnet_bootnet
class object.
Character scalar. Title of the histogram.
Character scalar. x-axis label.
Passed to hist
.
Logical scalar. When TRUE marks the observed data average and the simulated data average.
Character scalar. When annotated=TRUE
, label for the value of b0
.
Character scalar. When annotated=TRUE
, label for the value of b
.
Logical scalar. When TRUE
, asks the user to type <Enter>
to
see each plot (as many as statistics where computed).
Ignored.
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.
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
Other Functions for inference:
moran()
,
struct_test()
# 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