networkanalysis.ergm#
This module manages exponential random graph models (ERGMs).
Functions
|
Compute the adjusted pseudolikelihood function of a graph. |
|
Compute the maximum likelihood estimator. |
|
Compute the maximum pseudolikelihood estimator. |
|
Compute the pseudolikelihood of a graph. |
|
Simulate ngraphs graphs with respect to the param and the sufficient statistics. |
- networkanalysis.ergm.apl(mple, mle, statscomp, graph, ngraphs=500, burnin=500, thin=5, return_statscomp=False)#
Compute the adjusted pseudolikelihood function of a graph.
- Parameters:
mple (ndarray) – The maximum pseudolikelihood estimator.
mle (ndarray) – The maximum likelihood estimator.
statscomp (StatsComp | CachedStatsComp) – The function that computes the sufficient statistics.
graph (Graph) – The observed graph.
ngraphs (int, optional) – The number of graphs to simulate. Defaults to 500.
burnin (int, optional) – The number of iterations to discard. Defaults to 500.
thin (int, optional) – The thinning parameter. Defaults to 5.
return_statscomp (bool, optional) – Whether to return the function that computes the sufficient statistics. Defaults to False.
- Returns:
- The adjusted pseudolikelihood function with respect to the observed
graph.
The statistics computer if return_statscomp is True.
- Return type:
tuple[Callable[[numpy.ndarray], float], StatsComp | CachedStatsComp]
- networkanalysis.ergm.ml(graph, statscomp, init=None, ngraphs=500, burnin=500, thin=5, bound=0.1, tol=1e-05, maxiter=50, return_statscomp=False)#
Compute the maximum likelihood estimator.
- Parameters:
graph (Graph) – The graph to compute the estimator.
statscomp (StatsComp | CachedStatsComp) – The function that computes the sufficient statistics.
init (ndarray, optional) – The initial parameter to start the optimization. If None, the maximum pseudolikelihood estimator is used. Defaults to None.
ngraphs (int, optional) – The number of graphs to use when using simulate. Defaults to 500.
burnin (int, optional) – The number of graphs to discard when using simulate. Defaults to 500.
thin (int, optional) – The thinning parameter when using simulate. Defaults to 5.
bound (float, optional) – The bound for the optimization. Defaults to 1e-1.
tol (float, optional) – The tolerance for the optimization. Defaults to 1e-5.
maxiter (int, optional) – The maximum number of iterations for the current two-phases algorithm. Defaults to 50.
return_statscomp (bool, optional) – Whether to return the function that computes the sufficient statistics. Defaults to False.
- Returns:
The maximum likelihood estimator.
- Return type:
- networkanalysis.ergm.mpl(graph, statscomp, return_statscomp=False)#
Compute the maximum pseudolikelihood estimator.
- Parameters:
graph (Graph) – The observed graph.
statscomp (StatsComp | CachedStatsComp) – The statistics computer.
return_statscomp (bool, optional) – Whether to return the function that computes the sufficient statistics. Defaults to False.
- Returns:
The maximum pseudolikelihood estimator.
The statistics computer if return_statscomp is True.
- Return type:
- networkanalysis.ergm.pl(graph, param, statscomp, return_statscomp=False)#
Compute the pseudolikelihood of a graph.
- Parameters:
graph (Graph) – The graph.
param (ndarray) – The parameter.
statscomp (StatsComp | CachedStatsComp) – The function that computes the sufficient statistics.
return_statscomp (bool, optional) – Whether to return the function that computes the sufficient statistics. Defaults to False.
- Returns:
The pseudolikelihood of the graph.
The statistics computer if return_statscomp is True.
- Return type:
- networkanalysis.ergm.simulate(ngraphs, param, stats_comp, init, burnin=0, thin=1, summary=False, warn=None, return_statscomp=False)#
Simulate ngraphs graphs with respect to the param and the sufficient statistics.
- Parameters:
ngraphs (int) – The number of graphs to simulate.
param (ndarray) – The parameter of the model.
stats_comp (StatsComp | CachedStatsComp) – The sufficient statistics computer.
init (Graph, optional) – The initial graph to start the chain, or the number of nodes. If none is given, then a random graph is used.
burnin (int, optional) – The number of graphs to burn. If none is given, then no graphs will be burned. Defaults to 0.
thin (int, optional) – The thinning factor. Defaults to 1.
summary (bool, optional) – A flag for requesting to collect information about the chain such as the acceptance rate. Defaults to False.
warn (int, optional) – If an integer passed, then a warning is thrown if the graphs are near-empty or near-complete for this number of interation. Defaults to None.
return_statscomp (bool, optional) – A flag for requesting to return the sufficient statistics computer. Defaults to False.
- Returns:
The simulated graphs.
A summary of the Markov chain used if summary is True.
The statistics computer if return_statistics is True.
- Return type: