Skip to contents

Generate bootstrap samples of a network with the local bootstrap method described in Zu and Qin (2025) from the localboot package.

Usage

bootstrap_local(
  network,
  B = 3000,
  quantile_n = NULL,
  dist.func = dist_ASE,
  weighted = FALSE,
  fast = NULL,
  node.names = NULL
)

Arguments

network

An igraph object with \(n\) nodes.

B

number of bootstrap samples to calculate

quantile_n

Parameter for localboot function. The quantile used for neighborhood selection in the localboot function. Defaults to NULL which uses \(\sqrt{log(n)/n}\).

dist.func

Parameter for localboot function. The distance function used to calculate distances between nodes in network. Defaults to get_dist_default_eigen, an internal function in the localboot package.

weighted

Parameter for localboot function. A logical indicating if the network is weighted. Defaults to FALSE.

fast

Parameter for localboot function. A logical indicating if a faster, approximate method should be used. Automatically set based on network size if NULL.

Value

A list of length B where each element is a bootstrapped network as an igraph object. Each bootstrapped network, \(G^{(b)}\) has the following vertex attributes:

  • boot.index is the index of the node in the bootstrap sample as \(vb1, vb2, ..., vbn\).

  • original.index.cpp this is the index of the corresponding node in the original network as \(v0, v1, ..., v(n-1)\). The localboot function uses C++ which is the reason for this index. For example if \(v_1^{b)}\) is the \(4^{th}\) node in the original network, the original.index.cpp[1] is \(v3\).

  • original.index.rthis is the index of the corresponding node in the original network as \(v1, v2, ..., vn\). The localboot function uses C++, but we want to use R's indexing from 1 to n. For example if \(v_1^{b)}\) is the \(4^{th}\) node in the original network, then original.index.cpp[1] is \(v4\).

  • name is the name of the corresponding node in the original network. For example if \(v_1^{b)}\) is the \(4^{th}\) node in the original network, then name[1] is V(network)$name[4].

Details

This is a wrapper function to generate bootstrap samples of a network with the local bootstrap method described in Zu and Qin (2025) . This function uses the localboot function to generate bootstrap samples, then formats them to fit in the JaB package syntax.

Let \(\boldsymbol{A}\) be the adjacency matrix of network \(G \) with \(n\) nodes in node set \(V\).

Let \(\boldsymbol{D}\) be the distance matrix for all pairs of nodes where \(d_{i,j}\) is the distance between node \(i\) and node \(i\) according to the distance function dist.func.

Construct a neighborhood for each node as \(\mathcal{N}(v_i) = \{v_j \in V\ : d_{i,j} < d_i^{(s)} \}\) where \(d_i^{(s)} \) is the \(s^{th}\) smallest distance of \(d_{i,1}, ..., d_{i, n}\). This construction ensures each neighborhood always has \(s = |\mathcal(N)(v_i)|\) neighbors.

To generate a bootstrap adjacency matrix \(\boldsymbol{A}^{(b)}\), for \(1 \leq i < j \leq n\) independently draw $$ \begin{align} A_{ij}^{(b)} &\sim \text{Uniform} \Big(\{A_{k\ell} : k \in \mathcal{N}(v_{i}^{(b)}), \ell \in \mathcal{N}(v_{j}^{(b)})\} \Big) \\ v_i^{(b)} &\sim \text{Uniform}(V) \end{align} $$

There may be cases in which \(\mathcal{N}(v_{i}^{(b)})\) and \(\mathcal{N}(v_{j}^{(b)})\) are overlapping sets. In these cases, set \(\mathcal{N}(v_{i}^{(b)}) \cap \mathcal{N}(v_{j}^{(b)}) = \emptyset\).

References

Zu T, Qin Y (2025). “Local bootstrap for network data.” Biometrika, 112(1), asae046.

Examples

library(JaB)
library(igraph)
library(localboot)
data("paul.revere")

# generate 10 bootstrap samples
bootstrap_local(paul.revere, B = 10)
#> [[1]]
#> IGRAPH f97c95e UN-- 254 9355 -- 
#> + attr: name (v/c), original.index.cpp (v/c), original.index.r (v/c),
#> | boot.index (v/c)
#> + edges from f97c95e (vertex names):
#>  [1] Adams.John--Allen.Dr          Adams.John--Barber.Nathaniel 
#>  [3] Adams.John--Barber.Nathaniel  Adams.John--Barber.Nathaniel 
#>  [5] Adams.John--Bass.Henry        Adams.John--Bass.Henry       
#>  [7] Adams.John--Boit.John         Adams.John--Breck.William    
#>  [9] Adams.John--Burt.Benjamin     Adams.John--Chadwell.Mr      
#> [11] Adams.John--Chadwell.Mr       Adams.John--Champney.Caleb   
#> [13] Adams.John--Champney.Caleb    Adams.John--Chase.Thomas     
#> + ... omitted several edges
#> 
#> [[2]]
#> IGRAPH 9d2f39e UN-- 254 8583 -- 
#> + attr: name (v/c), original.index.cpp (v/c), original.index.r (v/c),
#> | boot.index (v/c)
#> + edges from 9d2f39e (vertex names):
#>  [1] Adams.Samuel--Adams.Samuel     Adams.Samuel--Adams.Samuel    
#>  [3] Adams.Samuel--Allen.Dr         Adams.Samuel--Allen.Dr        
#>  [5] Adams.Samuel--Austin.Benjamin  Adams.Samuel--Austin.Benjamin 
#>  [7] Adams.Samuel--Avery.John       Adams.Samuel--Barber.Nathaniel
#>  [9] Adams.Samuel--Barrett.Samuel   Adams.Samuel--Barrett.Samuel  
#> [11] Adams.Samuel--Barrett.Samuel   Adams.Samuel--Boyer.Peter     
#> [13] Adams.Samuel--Boynton.Richard  Adams.Samuel--Boynton.Richard 
#> + ... omitted several edges
#> 
#> [[3]]
#> IGRAPH 7fde4c1 UN-- 254 9472 -- 
#> + attr: name (v/c), original.index.cpp (v/c), original.index.r (v/c),
#> | boot.index (v/c)
#> + edges from 7fde4c1 (vertex names):
#>  [1] Adams.Samuel--Appleton.Nathaniel Adams.Samuel--Austin.Benjamin   
#>  [3] Adams.Samuel--Austin.Samuel      Adams.Samuel--Avery.John        
#>  [5] Adams.Samuel--Baldwin.Cyrus      Adams.Samuel--Baldwin.Cyrus     
#>  [7] Adams.Samuel--Baldwin.Cyrus      Adams.Samuel--Barber.Nathaniel  
#>  [9] Adams.Samuel--Barber.Nathaniel   Adams.Samuel--Barber.Nathaniel  
#> [11] Adams.Samuel--Boyer.Peter        Adams.Samuel--Boynton.Richard   
#> [13] Adams.Samuel--Bradford.John      Adams.Samuel--Brimmer.Martin    
#> + ... omitted several edges
#> 
#> [[4]]
#> IGRAPH d887f76 UN-- 254 8370 -- 
#> + attr: name (v/c), original.index.cpp (v/c), original.index.r (v/c),
#> | boot.index (v/c)
#> + edges from d887f76 (vertex names):
#>  [1] Adams.John--Appleton.Nathaniel Adams.John--Barber.Nathaniel  
#>  [3] Adams.John--Breck.William      Adams.John--Breck.William     
#>  [5] Adams.John--Burt.Benjamin      Adams.John--Burt.Benjamin     
#>  [7] Adams.John--Burt.Benjamin      Adams.John--Cazneau.Capt      
#>  [9] Adams.John--Cazneau.Capt       Adams.John--Chadwell.Mr       
#> [11] Adams.John--Chadwell.Mr        Adams.John--Chadwell.Mr       
#> [13] Adams.John--Champney.Caleb     Adams.John--Cheever.Ezekiel   
#> + ... omitted several edges
#> 
#> [[5]]
#> IGRAPH 6484bf3 UN-- 254 8651 -- 
#> + attr: name (v/c), original.index.cpp (v/c), original.index.r (v/c),
#> | boot.index (v/c)
#> + edges from 6484bf3 (vertex names):
#>  [1] Adams.John--Adams.John         Adams.John--Appleton.Nathaniel
#>  [3] Adams.John--Appleton.Nathaniel Adams.John--Ballard.John      
#>  [5] Adams.John--Barber.Nathaniel   Adams.John--Bass.Henry        
#>  [7] Adams.John--Breck.William      Adams.John--Burt.Benjamin     
#>  [9] Adams.John--Burt.Benjamin      Adams.John--Cazneau.Capt      
#> [11] Adams.John--Cazneau.Capt       Adams.John--Chase.Thomas      
#> [13] Adams.John--Cheever.Ezekiel    Adams.John--Condy.JamesFoster 
#> + ... omitted several edges
#> 
#> [[6]]
#> IGRAPH 20fe904 UN-- 254 9335 -- 
#> + attr: name (v/c), original.index.cpp (v/c), original.index.r (v/c),
#> | boot.index (v/c)
#> + edges from 20fe904 (vertex names):
#>  [1] Adams.John--Barber.Nathaniel  Adams.John--Bass.Henry       
#>  [3] Adams.John--Boynton.Richard   Adams.John--Chadwell.Mr      
#>  [5] Adams.John--Chadwell.Mr       Adams.John--Chrysty.Thomas   
#>  [7] Adams.John--Chrysty.Thomas    Adams.John--Church.Benjamin  
#>  [9] Adams.John--Condy.JamesFoster Adams.John--Condy.JamesFoster
#> [11] Adams.John--Edes.Benjamin     Adams.John--Edes.Benjamin    
#> [13] Adams.John--Emmes.Samuel      Adams.John--Emmes.Samuel     
#> + ... omitted several edges
#> 
#> [[7]]
#> IGRAPH 64c31f5 UN-- 254 9225 -- 
#> + attr: name (v/c), original.index.cpp (v/c), original.index.r (v/c),
#> | boot.index (v/c)
#> + edges from 64c31f5 (vertex names):
#>  [1] Adams.John--Adams.John       Adams.John--Adams.Samuel    
#>  [3] Adams.John--Allen.Dr         Adams.John--Ballard.John    
#>  [5] Adams.John--Ballard.John     Adams.John--Barber.Nathaniel
#>  [7] Adams.John--Breck.William    Adams.John--Breck.William   
#>  [9] Adams.John--Burt.Benjamin    Adams.John--Chrysty.Thomas  
#> [11] Adams.John--Cleverly.Stephen Adams.John--Dennie.William  
#> [13] Adams.John--Eayres.Joseph    Adams.John--Eayres.Joseph   
#> + ... omitted several edges
#> 
#> [[8]]
#> IGRAPH 5634eee UN-- 254 8571 -- 
#> + attr: name (v/c), original.index.cpp (v/c), original.index.r (v/c),
#> | boot.index (v/c)
#> + edges from 5634eee (vertex names):
#>  [1] Adams.Samuel--Austin.Benjamin  Adams.Samuel--Avery.John      
#>  [3] Adams.Samuel--Baldwin.Cyrus    Adams.Samuel--Barber.Nathaniel
#>  [5] Adams.Samuel--Bass.Henry       Adams.Samuel--Boyer.Peter     
#>  [7] Adams.Samuel--Boyer.Peter      Adams.Samuel--Boyer.Peter     
#>  [9] Adams.Samuel--Boynton.Richard  Adams.Samuel--Boynton.Richard 
#> [11] Adams.Samuel--Boynton.Richard  Adams.Samuel--Boynton.Richard 
#> [13] Adams.Samuel--Brackett.Jos     Adams.Samuel--Brimmer.Martin  
#> + ... omitted several edges
#> 
#> [[9]]
#> IGRAPH 84ed5a1 UN-- 254 8761 -- 
#> + attr: name (v/c), original.index.cpp (v/c), original.index.r (v/c),
#> | boot.index (v/c)
#> + edges from 84ed5a1 (vertex names):
#>  [1] Allen.Dr--Ballard.John      Allen.Dr--Ballard.John     
#>  [3] Allen.Dr--Ballard.John      Allen.Dr--Barber.Nathaniel 
#>  [5] Allen.Dr--Boit.John         Allen.Dr--Boit.John        
#>  [7] Allen.Dr--Breck.William     Allen.Dr--Breck.William    
#>  [9] Allen.Dr--Breck.William     Allen.Dr--Brimmer.Herman   
#> [11] Allen.Dr--Burt.Benjamin     Allen.Dr--Cazneau.Capt     
#> [13] Allen.Dr--Champney.Caleb    Allen.Dr--Condy.JamesFoster
#> + ... omitted several edges
#> 
#> [[10]]
#> IGRAPH 3a37edb UN-- 254 8871 -- 
#> + attr: name (v/c), original.index.cpp (v/c), original.index.r (v/c),
#> | boot.index (v/c)
#> + edges from 3a37edb (vertex names):
#>  [1] Adams.John--Adams.John       Adams.John--Allen.Dr        
#>  [3] Adams.John--Bass.Henry       Adams.John--Boit.John       
#>  [5] Adams.John--Boit.John        Adams.John--Burt.Benjamin   
#>  [7] Adams.John--Burt.Benjamin    Adams.John--Cazneau.Capt    
#>  [9] Adams.John--Chadwell.Mr      Adams.John--Chadwell.Mr     
#> [11] Adams.John--Chadwell.Mr      Adams.John--Champney.Caleb  
#> [13] Adams.John--Dennie.William   Adams.John--Edes.Benjamin   
#> + ... omitted several edges
#> 

# Use a new distance function