@@ -395,10 +399,10 @@ which shows the number of nodes and groups in all levels:
.. testoutput:: celegans
l: 0, N: 297, B: 15
l: 1, N: 15, B: 7
l: 2, N: 7, B: 4
l: 3, N: 4, B: 1
l: 0, N: 297, B: 16
l: 1, N: 16, B: 5
l: 2, N: 5, B: 2
l: 3, N: 2, B: 1
The hierarchical levels themselves are represented by individual
:meth:`~graph_tool.inference.BlockState` instances obtained via the
...
...
@@ -412,10 +416,10 @@ The hierarchical levels themselves are represented by individual
.. testoutput:: celegans
<BlockState object with 15 blocks (15 nonempty), degree-corrected, for graph <Graph object, directed, with 297 vertices and 2359 edges at 0x...>, at 0x...>
<BlockState object with 7 blocks (7 nonempty), for graph <Graph object, directed, with 15 vertices and 116 edges at 0x...>, at 0x...>
<BlockState object with 4 blocks (4 nonempty), for graph <Graph object, directed, with 7 vertices and 38 edges at 0x...>, at 0x...>
<BlockState object with 1 blocks (1 nonempty), for graph <Graph object, directed, with 4 vertices and 16 edges at 0x...>, at 0x...>
<BlockState object with 16 blocks (16 nonempty), degree-corrected, for graph <Graph object, directed, with 297 vertices and 2359 edges at 0x...>, at 0x...>
<BlockState object with 5 blocks (5 nonempty), for graph <Graph object, directed, with 16 vertices and 139 edges at 0x...>, at 0x...>
<BlockState object with 2 blocks (2 nonempty), for graph <Graph object, directed, with 5 vertices and 23 edges at 0x...>, at 0x...>
<BlockState object with 1 blocks (1 nonempty), for graph <Graph object, directed, with 2 vertices and 4 edges at 0x...>, at 0x...>
This means that we can inspect the hierarchical partition just as before:
...
...
@@ -430,7 +434,7 @@ This means that we can inspect the hierarchical partition just as before:
.. testoutput:: celegans
3
2
1
0
...
...
@@ -455,9 +459,11 @@ case of the `C. elegans` network we have
.. testoutput:: model-selection
:options: +NORMALIZE_WHITESPACE
Non-degree-corrected DL: 8477.321131...
Degree-corrected DL: 8265.123659...
Non-degree-corrected DL: 8506.9904...
Degree-corrected DL: 8281.1975...
Since it yields the smallest description length, the degree-corrected
fit should be preferred. The statistical significance of the choice can
be accessed by inspecting the posterior odds ratio
...
...
@@ -482,12 +488,12 @@ fits. In our particular case, we have
.. testoutput:: model-selection
:options: +NORMALIZE_WHITESPACE
ln Λ: -212.197471...
ln Λ: -225.792822...
The precise threshold that should be used to decide when to `reject a
hypothesis <https://en.wikipedia.org/wiki/Hypothesis_testing>`_ is
subjective and context-dependent, but the value above implies that the
particular degree-corrected fit is around :math:`e^{258} \sim 10^{92}`
particular degree-corrected fit is around :math:`e^{225} \sim 10^{97}`
times more likely than the non-degree corrected one, and hence it can be
safely concluded that it provides a substantially better fit.
...
...
@@ -509,12 +515,12 @@ example, for the American football network above, we have:
.. testoutput:: model-selection
:options: +NORMALIZE_WHITESPACE
Non-degree-corrected DL: 1751.855586...
Degree-corrected DL: 1810.717327...
ln Λ: -58.861740...
Non-degree-corrected DL: 1745.006934...
Degree-corrected DL: 1787.646768...
ln Λ: -42.639834...
Hence, with a posterior odds ratio of :math:`\Lambda \sim e^{-58} \sim
10^{-25}` in favor of the non-degree-corrected model, it seems like the
Hence, with a posterior odds ratio of :math:`\Lambda \sim e^{-42} \sim
10^{-18}` in favor of the non-degree-corrected model, it seems like the
degree-corrected variant is an unnecessarily complex description for
this network.
...
...
@@ -599,8 +605,8 @@ random partition into 20 groups
.. testoutput:: model-averaging
Change in description length: 2.998041...
Number of accepted vertex moves: 3677
Change in description length: 11.533023...
Number of accepted vertex moves: 3860
Although the above is sufficient to implement model averaging, there is a