# arnabaich96/causalmixgpd architecture

> Architecture diagram of the GitHub repository arnabaich96/causalmixgpd, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/arnabaich96/causalmixgpd
- Repository: https://github.com/arnabaich96/causalmixgpd

## Overview

CausalMixGPD is an R package for Bayesian nonparametric conditional-density modeling, with heavy-tail/GPD extensions for causal inference and clustering. The principal workflow is to specify a model, select a density kernel and tail behavior, fit it, then inspect posterior results or derive causal estimands and cluster summaries. The graph also preserves the package’s kernel family, registry, bundled-data, and result-processing branches. Paths and module roles are based on the repository tree and README; sampled source excerpts were unrelated vendored website JavaScript, so internal call wiring is not verified.

Main entry points: [`R/1-registry.R`](https://github.com/arnabaich96/causalmixgpd/blob/master/R/1-registry.R) (Backend registry), [`R/build-run.R`](https://github.com/arnabaich96/causalmixgpd/blob/master/R/build-run.R) (Fit runner), [`R/wrappers.R`](https://github.com/arnabaich96/causalmixgpd/blob/master/R/wrappers.R) (Model wrappers), [`R/causal.R`](https://github.com/arnabaich96/causalmixgpd/blob/master/R/causal.R) (Causal models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_modeling["Model specification"]
  node_api["Model wrappers<br/>[wrappers.R]"]
  node_causal["Causal models<br/>[causal.R]"]
  node_cluster["Clustering models<br/>[cluster.R]"]
  node_spec["Model compiler<br/>[compile-spec.R]"]
  node_registry["Backend registry<br/>[1-registry.R]"]
end

subgraph group_inference["Inference runtime"]
  node_runner["Fit runner<br/>[build-run.R]"]
  node_engine["Inference engine<br/>[engine.R]"]
end

subgraph group_analysis["Analysis results"]
  node_extract["Posterior extraction<br/>[extract.R]"]
  node_summary["Posterior summaries<br/>[summary.R]"]
  node_methods["Fit methods<br/>[methods.R]"]
  node_causal_results["Causal estimands<br/>[causal.R]"]
  node_cluster_results["Cluster summaries<br/>[cluster.R]"]
  node_datasets["Example datasets<br/>[data-datasets.R]"]
end

subgraph group_distributions["Density backends"]
  node_gpd["GPD tails"]
  node_normal["Normal kernel<br/>[normal.R]"]
  node_gamma["Gamma kernel<br/>[gamma.R]"]
  node_amoroso["Amoroso kernel<br/>[amoroso.R]"]
  node_cauchy["Cauchy kernel<br/>[cauchy.R]"]
  node_invgauss["Inverse Gaussian<br/>[invgauss.R]"]
  node_laplace["Laplace kernel<br/>[laplace.R]"]
  node_lognormal["Lognormal kernel<br/>[lognormal.R]"]
end

node_user(("R user"))

node_user -->|"specifies and fits"| node_api
node_user -->|"requests causal fit"| node_causal
node_user -->|"requests clustering fit"| node_cluster
node_api -->|"builds specification"| node_spec
node_spec -->|"resolves backend"| node_registry
node_registry -->|"selects tail"| node_gpd
node_registry -->|"selects kernel"| node_normal
node_registry -->|"selects kernel"| node_gamma
node_registry -->|"selects kernel"| node_amoroso
node_registry -->|"selects kernel"| node_cauchy
node_registry -->|"selects kernel"| node_invgauss
node_registry -->|"selects kernel"| node_laplace
node_registry -->|"selects kernel"| node_lognormal
node_api -->|"runs fit"| node_runner
node_runner -->|"executes inference"| node_engine
node_causal -->|"fits model"| node_runner
node_cluster -->|"fits model"| node_runner
node_user -->|"requests draws"| node_extract
node_extract -->|"summarizes draws"| node_summary
node_user -->|"inspects fit"| node_methods
node_user -->|"requests estimands"| node_causal_results
node_user -->|"requests profiles"| node_cluster_results
node_user -->|"loads examples"| node_datasets

click node_api "https://github.com/arnabaich96/causalmixgpd/blob/master/R/wrappers.R"
click node_causal "https://github.com/arnabaich96/causalmixgpd/blob/master/R/causal.R"
click node_cluster "https://github.com/arnabaich96/causalmixgpd/blob/master/R/cluster.R"
click node_spec "https://github.com/arnabaich96/causalmixgpd/blob/master/R/compile-spec.R"
click node_registry "https://github.com/arnabaich96/causalmixgpd/blob/master/R/1-registry.R"
click node_runner "https://github.com/arnabaich96/causalmixgpd/blob/master/R/build-run.R"
click node_engine "https://github.com/arnabaich96/causalmixgpd/blob/master/R/engine.R"
click node_gpd "https://github.com/arnabaich96/causalmixgpd/blob/master/R/0-base-distributions.R"
click node_normal "https://github.com/arnabaich96/causalmixgpd/blob/master/R/normal.R"
click node_gamma "https://github.com/arnabaich96/causalmixgpd/blob/master/R/gamma.R"
click node_amoroso "https://github.com/arnabaich96/causalmixgpd/blob/master/R/amoroso.R"
click node_cauchy "https://github.com/arnabaich96/causalmixgpd/blob/master/R/cauchy.R"
click node_invgauss "https://github.com/arnabaich96/causalmixgpd/blob/master/R/invgauss.R"
click node_laplace "https://github.com/arnabaich96/causalmixgpd/blob/master/R/laplace.R"
click node_lognormal "https://github.com/arnabaich96/causalmixgpd/blob/master/R/lognormal.R"
click node_extract "https://github.com/arnabaich96/causalmixgpd/blob/master/R/extract.R"
click node_summary "https://github.com/arnabaich96/causalmixgpd/blob/master/R/summary.R"
click node_methods "https://github.com/arnabaich96/causalmixgpd/blob/master/R/methods.R"
click node_causal_results "https://github.com/arnabaich96/causalmixgpd/blob/master/R/causal.R"
click node_cluster_results "https://github.com/arnabaich96/causalmixgpd/blob/master/R/cluster.R"
click node_datasets "https://github.com/arnabaich96/causalmixgpd/blob/master/R/data-datasets.R"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_api,node_causal,node_cluster,node_spec,node_registry,node_user toneBlue
class node_runner,node_engine toneAmber
class node_extract,node_summary,node_methods,node_causal_results,node_cluster_results,node_datasets toneMint
class node_gpd,node_normal,node_gamma,node_amoroso,node_cauchy,node_invgauss,node_laplace,node_lognormal toneRose
```

## Components

### Model specification

- [Model wrappers](https://github.com/arnabaich96/causalmixgpd/blob/master/R/wrappers.R): `R/wrappers.R`
- [Causal models](https://github.com/arnabaich96/causalmixgpd/blob/master/R/causal.R): `R/causal.R`
- [Clustering models](https://github.com/arnabaich96/causalmixgpd/blob/master/R/cluster.R): `R/cluster.R`
- [Model compiler](https://github.com/arnabaich96/causalmixgpd/blob/master/R/compile-spec.R): `R/compile-spec.R`
- [Backend registry](https://github.com/arnabaich96/causalmixgpd/blob/master/R/1-registry.R): `R/1-registry.R`

### Inference runtime

- [Fit runner](https://github.com/arnabaich96/causalmixgpd/blob/master/R/build-run.R): `R/build-run.R`
- [Inference engine](https://github.com/arnabaich96/causalmixgpd/blob/master/R/engine.R): `R/engine.R`

### Analysis results

- [Posterior extraction](https://github.com/arnabaich96/causalmixgpd/blob/master/R/extract.R): `R/extract.R`
- [Posterior summaries](https://github.com/arnabaich96/causalmixgpd/blob/master/R/summary.R): `R/summary.R`
- [Fit methods](https://github.com/arnabaich96/causalmixgpd/blob/master/R/methods.R): `R/methods.R`
- [Causal estimands](https://github.com/arnabaich96/causalmixgpd/blob/master/R/causal.R): `R/causal.R`
- [Cluster summaries](https://github.com/arnabaich96/causalmixgpd/blob/master/R/cluster.R): `R/cluster.R`
- [Example datasets](https://github.com/arnabaich96/causalmixgpd/blob/master/R/data-datasets.R): `R/data-datasets.R`

### Density backends

- [GPD tails](https://github.com/arnabaich96/causalmixgpd/blob/master/R/0-base-distributions.R): `R/0-base-distributions.R`
- [Normal kernel](https://github.com/arnabaich96/causalmixgpd/blob/master/R/normal.R): `R/normal.R`
- [Gamma kernel](https://github.com/arnabaich96/causalmixgpd/blob/master/R/gamma.R): `R/gamma.R`
- [Amoroso kernel](https://github.com/arnabaich96/causalmixgpd/blob/master/R/amoroso.R): `R/amoroso.R`
- [Cauchy kernel](https://github.com/arnabaich96/causalmixgpd/blob/master/R/cauchy.R): `R/cauchy.R`
- [Inverse Gaussian](https://github.com/arnabaich96/causalmixgpd/blob/master/R/invgauss.R): `R/invgauss.R`
- [Laplace kernel](https://github.com/arnabaich96/causalmixgpd/blob/master/R/laplace.R): `R/laplace.R`
- [Lognormal kernel](https://github.com/arnabaich96/causalmixgpd/blob/master/R/lognormal.R): `R/lognormal.R`

### Other components

- **R user**

## Connections

- R user → Model wrappers: specifies and fits
- R user → Causal models: requests causal fit
- R user → Clustering models: requests clustering fit
- Model wrappers → Model compiler: builds specification
- Model compiler → Backend registry: resolves backend
- Backend registry → GPD tails: selects tail
- Backend registry → Normal kernel: selects kernel
- Backend registry → Gamma kernel: selects kernel
- Backend registry → Amoroso kernel: selects kernel
- Backend registry → Cauchy kernel: selects kernel
- Backend registry → Inverse Gaussian: selects kernel
- Backend registry → Laplace kernel: selects kernel
- Backend registry → Lognormal kernel: selects kernel
- Model wrappers → Fit runner: runs fit
- Fit runner → Inference engine: executes inference
- Causal models → Fit runner: fits model
- Clustering models → Fit runner: fits model
- R user → Posterior extraction: requests draws
- Posterior extraction → Posterior summaries: summarizes draws
- R user → Fit methods: inspects fit
- R user → Causal estimands: requests estimands
- R user → Cluster summaries: requests profiles
- R user → Example datasets: loads examples
