hfgolino/EGAnet

Mean loadings in bootEGA

Closed this issue · 1 comments

Hello, ALL
I noticed that the producer removed the mean loadings in bootEGA to avoid confusion with net.loads. Now, how can I get the mean loading in BootEGA? I tried to use net.loads, but it failed.
Thanks a lot!

Hi @fshulin,

I see that you closed this issue but then changed the title. Assuming you still would like to compute the mean network loadings, you can use:

# Load data
wmt <- wmt2[,7:24]

# Standard EGA parametric example
boot.wmt <- bootEGA(
  data = wmt, iter = 500,
  type = "parametric", ncores = 2
)

# Homogenize memberships
boot.wmt$boot.wc <- community.homogenize(
  target.membership = boot.wmt$EGA$wc,
  convert.membership = boot.wmt$boot.wc
)

# Compute network loadings
boot_loadings <- lapply(
  seq_along(boot.wmt$bootGraphs), function(iter){
    
    # Get graph
    graph <- boot.wmt$bootGraphs[[iter]]
    
    # Get names
    node_names <- colnames(boot.wmt$EGA$network)
    
    # Set names
    row.names(graph) <- colnames(graph) <- node_names
    
    # Get loadings
    loadings <- net.loads(
      A = graph,
      wc = boot.wmt$boot.wc[iter,]
    )$std
    
    # Ensure same order of nodes
    return(loadings[node_names,])
    
  }
)

You'll notice that the number of columns will vary based on the number of estimated dimensions in the bootstrap (part of why we got rid of this feature). You can still compute the mean loadings for the dimensions you need across the bootstraps.

Important: You need to perform community.homogenize to ensure that the community assignments are consistent across the bootstraps