Adversarial estimation on graphs
Adversarial estimator for graph structural models extends the theoretical framework proposed by Kaji et al. (2023) to structural models defined on graphs (strategic communication games, peer-effect models, etc.). With graph data, the entire network is typically a single realization; to create variability for the discriminator we sample subgraphs from both the ground truth and the synthetic graph and label them by origin. Intuitively, local neighborhoods contain enough information about global structure for discrimination; our current implementation uses $k$-hop ego sampling. Additional challenges include multiple equilibria in dynamic network models, lack of closed-form asymptotics, and the need to tailor the discriminator architecture to the structural class.
Formal setup
Observed data. Let $G=(X,Y,N,A)$ where:
- $X\in\mathbb{R}^{n\times k}$ are exogenous node covariates (row $i$ is $x_i^\top$).
- $Y\in\mathbb{R}^{n\times \ell}$ are endogenous node outcomes (row $i$ is $y_i^\top$).
- $N={1,\dots,n}$ is the node index set.
- $A\in{0,1}^{n\times n}$ is a symmetric adjacency matrix.
We work with a peer operator $P(A)$ that excludes self-links:
P(A) = A - \mathrm{diag}(A)
Optionally, $P(A)$ may be row/degree-normalized; we only require $\mathrm{diag}!\big(P(A)\big)=0$.
Structural model (generator). A structural mapping
m_\theta:\ \big(X,\ P(A),\ Y^{(0)},\ \xi\big)\ \longmapsto\ Y' \in \mathbb{R}^{n\times \ell}
takes covariates, the peer operator, and an initial outcome state $Y^{(0)}$ (e.g., pre-interaction signals, baselines, or zeros) and returns simulated outcomes $Y'$. The innovation $\xi$ captures simulation randomness if present.
- Single-step (peer-to-peer, no self-loop):
Y' = m_\theta\!\Big(X,\ P(A)\,Y^{(0)},\ \xi\Big),
i.e., each $y_i'$ depends on $x_i$ and peers’ initial outcomes ${y_j^{(0)}: j\in\mathcal{N}(i)}$, but not on $y_i^{(0)}$ directly.
- Multi-step propagation (optional): for $t=0,\dots,T-1$,
Y^{(t+1)} = m_\theta\!\Big(X,\ P(A)\,Y^{(t)},\ \xi^{(t)}\Big),
\qquad Y' \equiv Y^{(T)}.
Synthetic data. Define $G'(\theta)=(X,\ Y',\ N,\ A)$ with $Y'=m_\theta(X,P(A),Y^{(0)},\xi)$. Exogenous features and topology are held fixed so identification comes from matching the distribution of outcomes over sampled subgraphs.
Subgraph sampling. Let $\mathsf{S}$ denote a randomized sampler (e.g., $k$-hop ego nets or rooted random-walk subgraphs). Sampling from $G$ induces $p_{\mathrm{data}}^{\mathsf{S}}$ over subgraphs $g$; sampling from $G'(\theta)$ induces $p_{\theta}^{\mathsf{S}}$.
Discriminator. A GNN discriminator $D_\phi: g\mapsto[0,1]$ outputs the probability that $g$ came from $p_{\mathrm{data}}^{\mathsf{S}}$.
Adversarial objective (Goodfellow-style). Estimate $\theta$ by
\min_{\theta}\ \max_{\phi}\
\mathbb{E}_{g\sim p_{\mathrm{data}}^{\mathsf{S}}}\!\big[\log D_\phi(g)\big]
\;+\;
\mathbb{E}_{g\sim p_{\theta}^{\mathsf{S}}}\!\big[\log\big(1-D_\phi(g)\big)\big].
At the optimal discriminator this minimizes the Jensen–Shannon divergence between $p_{\mathrm{data}}^{\mathsf{S}}$ and $p_{\theta}^{\mathsf{S}}$.
Practical implementation
-
Discriminator. Implement $D_\phi$ with PyTorch Geometric. Use the same sampler $\mathsf{S}$ (e.g., $k$-hop ego nets or rooted random-walk subgraphs) for real and synthetic graphs to keep the target distribution fixed.
-
Generators.
- Ground-truth generator: sampling manager over $G$ to produce $g\sim p_{\mathrm{data}}^{\mathsf{S}}$.
- Synthetic generator: wraps $m_\theta$, reuses $X$, $A$ and the chosen initial state $Y^{(0)}$ (passed through the estimator), constructs $P(A)$ with zero diagonal, and exposes
generate_outcomes(θ)for counterfactual simulation.
-
Optimization. Treat the outer problem as black-box in $\theta$. Bayesian optimization is a reasonable default; use binary cross-entropy from the objective above (not accuracy) as the scalar loss. The estimator exposes an
outer_optimizerswitch: keep"gp"(default, viaskopt.gp_minimize) or set"nelder-mead"to activate SciPy's derivative-free simplex routine. Additional optimizer arguments can be supplied throughouter_optimizer_params(legacy code usinggp_paramscontinues to work when the GP optimizer is selected). SciPy is declared as a project dependency.
linear_in_means_model.ipynb
A two-parameter testbed illustrating training curves and objective values. For linear-in-means,
Y = (I-\rho P)^{-1}(X\beta+\varepsilon),
the no-self-loop restriction holds via $P(A)$ and invertibility requires
|\rho| < 1/\lambda_{\max}(P).
Notes
- Utilities currently target the linear-in-means demo; they should generalize by swapping $m_\theta$ and the sampler $\mathsf{S}$.
- The demo’s GNN for $D_\phi$ is ad hoc; strong identification often tolerates simple discriminators.
- Prefer cross-entropy over accuracy for the outer objective.
Reference
Kaji, T., Manresa, E., & Pouliot, G. (2023). An adversarial approach to structural estimation. Econometrica, 91(6), 2041–2063.
Metadata
Release files for adversarial-nets-lib-econ 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| adversarial_nets_lib_econ-0.1.4.tar.gz | 23.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| adversarial_nets_lib_econ-0.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 40.2 kB
Release files / adversarial_nets_lib_econ-0.1.4.tar.gz
| Download URL | adversarial_nets_lib_econ-0.1.4.tar.gz |
|---|---|
| Size | 23.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
685bc09c55c42b940b4e45c34550e38153035b322926cacae0547fb53542be53
|
|
BLAKE2b-256 checksum How to use checksums |
8e96154bcbf9ee2767a8facc5381673f39e5fa8e0da88e47943648ab5540f3d2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / adversarial_nets_lib_econ-0.1.4-py3-none-any.whl
| Download URL | adversarial_nets_lib_econ-0.1.4-py3-none-any.whl |
|---|---|
| Size | 17.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
667055c9e3ee71a8b39c0eddb56ce602b7f91bcdb57736a47db41794184c0477
|
|
BLAKE2b-256 checksum How to use checksums |
5f338eef1825b24e6e2ed2853f6aba5425b750ad2024d9e61ad29a95d8636a71
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Security for adversarial-nets-lib-econ 0.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.