Dear all,

I hope this email finds you well. I’m writing to seek your expertise regarding some inconsistencies I’ve encountered while calculating Bonacich’s power centrality (Beta centrality) for an undirected and valued network using both **igraph** and **sna** packages.

I’ve attached example codes and annotations for your reference. Despite aligning the ‘exponent’ and ‘rescale’ parameters between the two packages, I’ve observed notable discrepancies in the results. I have two specific questions I hope you can assist me with:

**1. Determining the highest beta value:** Currently, I’m using **sna** to obtain this value prior to calculating Bonacich’s power centrality. Could you explain how to derive the highest beta value using **igraph**? I’m particularly interested in understanding the process and any specific considerations required when using **igraph** for this calculation.

**2. Achieving consistent results between igraph and sna:** Despite aligning key parameters such as ‘exponent’ and ‘rescale’ across both packages, the outputs still differ significantly. Are there additional parameters or factors I should take into account to ensure consistency between the two packages’ results?

Your insights on these matters would be invaluable to my research. I appreciate any guidance you can provide to help resolve these discrepancies and improve the consistency of my analyses.

Thank you for your time and expertise.

Best regards,

Chuding

Below are the codes with annotations:

```
## Step 1: Create a 5x5 undirected and valued matrix
set.seed(123) # Set seed for reproducibility
matrix_values <- sample(1:4, 15, replace = TRUE) # Generate random weights for the upper triangle
undirected_matrix <- matrix(0, 5, 5) # Initialize a 5x5 matrix
# Fill the upper triangle with random values
undirected_matrix[upper.tri(undirected_matrix)] <- matrix_values
# Make the matrix symmetric to represent an undirected graph
undirected_matrix <- undirected_matrix + t(undirected_matrix)
undirected_matrix
## Step 2: Convert the matrix to an igraph object
library(igraph)
undirected_matrix_graph <- graph_from_adjacency_matrix(undirected_matrix,
mode = c("undirected"),
weighted = TRUE,
diag = FALSE)
## Step 3: Calculate Bonacich's power centrality (Beta centrality)
library(sna)
HighestBeta <- 1/max(Mod(eigen(undirected_matrix)$values))
HighestBeta
Results_from_sna <- bonpow(undirected_matrix,
gmode="graph",
diag=FALSE,
tmaxdev=FALSE,
exponent=0.1025,
rescale=FALSE,
tol=1e-07)
Results_from_sna <- data.frame(Results_from_sna = Results_from_sna)
# 0.1025 in the specification is based on the results of highest Beta value
# We cannot use the value equal to the highest value (0.1026044)
# so we choose a slightly smaller one
# I do not know how to obtain the highest Beta value with igraph.
Results_from_igraph <- power_centrality(
undirected_matrix_graph,
nodes = V(undirected_matrix_graph),
loops = FALSE,
exponent = 0.1025,
rescale = FALSE,
tol = 1e-07,
sparse = TRUE
)
Results_from_igraph <- data.frame(Results_from_igraph = Results_from_igraph)
## Step 4: Combine the two results and compare them
# The values in 'Results_from_igraph' show no variance,
# which differs from the observation with my own dataset.
# However, with my own dataset,
# the results are still not consistent with those in 'Results_from_sna'.
CombinedResults <- cbind(Results_from_igraph, Results_from_sna)
CombinedResults
cor(CombinedResults)
```