SGL 1.1.1

05/09/2011: This program has been superseded by SGL 1.1.2.

: Stata Graph Library (SGL) version 1.1.1.  Under review at the Stata Journal.  Except for command name change (to better reflect ongoing project), program identical to NETGEN 1.1.3.  R/Matlab routines used to double check output now included as part of the upload - please refer to 'test' folder in the below zip attachment.  Different file types are as follows (please note that 'graph' and 'network' are used interchangeably):
  • sgltest1 series: Tests SGL on undirected unweighted graphs.
    • sgltest1: Tests distance matrix, path matrix, betweenness centrality, clustering coefficients, and eigenvector centrality.
    • sgltest1a1: Tests Katz-Bonacich centrality.
    • sgltest1a2: Tests Katz-Bonacich centrality with specified exogenous beta vector.
    • sgltest1b1: Similar to sgltest1 but uses edge list in Mata.
  • sgltest2 series: Tests SGL on directed unweighted graphs.
  • sgltest3 series: Tests SGL on undirected weighted graphs.
  • sgltest4 series: Tests SGL on directed weighted graphs.
All test files start with R programs that run package 'sna' to produce random graphs (random seed is set such that generated graphs do not contain isolates).  R (and Matlab if using .m files) must be installed beforehand.  Directory paths will need to be changed.  For generating matrices/measures for weighted networks, MatlabBGL is implemented if necessary, as 'sna' does not produce correct results in certain cases when graph is weighted (refer to 'Note' under 'geodist' routine in 'sna' manual).  After R/MatlabBGL programs are run, corresponding Stata do-files are run to compare results from R/MatlabBGL and SGL outputs.  That is, to check matrices/measures for undirected unweighted networks, first run sgltest1.R then run  To check output for undirected weighted networks, first run sgltest3.R, then sgltest3.m, and then  igraph and RBGL are some other alternatives that can be used to check output.

Test programs are written for debugging purposes.  Users should perhaps do the opposite, generating matrices/measures in Stata then running R/Matlab, to double check their own results.  The question is, then, why even use Stata if R/Matlab is going to be used anyways?  Since all programs are user-written, it's best to double check each other, and also users may find it easier (but understandably still tedious) to customize Mata code (e.g. SGLX) rather than customizing underlying code used in other programs.
Hirotaka Miura,
Mar 12, 2011, 12:00 PM