Vine copulas in modern Fortran — pair copulas and regular-vine copulas with 111 families, exact parameter scores, Dissmann structure selection, densities, Rosenblatt transforms and simulation. No dependencies beyond a Fortran compiler with OpenMP; callable from Fortran, C and Python.
Documentation: https://bluerrror.github.io/fortvine/
- 111 pair-copula families — 26 hand-coded (Gaussian, Student t, Clayton, Gumbel, Frank, Joe, AMH, BB1-BB10, Tawn, Galambos, Hüsler-Reiss, t-EV, Plackett, FGM, nonparametric TLL and Bernstein) and 85 from a generic engine covering Archimedean, extreme-value, Archimax and Khoudraji-asymmetrised copulas. Every family has 90/180/270 degree rotations where they make sense; 32 families are asymmetric (non-exchangeable).
- Exact parameter scores. Each log-density is written once and compiled for real numbers and for dual numbers, so maximum likelihood uses exact gradients for every family.
- Fast fitting. Closed-form log-space kernels, a two-stage fit (subsample, then all data), candidate pre-selection, racing of candidate families, a fit cache and OpenMP.
- Vines. R-, C- and D-vines; Dissmann selection with Kendall's tau, Spearman's rho, Hoeffding's D, Chatterjee's xi, mutual information or tail criteria; truncation and thresholds by mBICv; density on samples and on prediction grids; log-likelihood; Rosenblatt and inverse Rosenblatt transforms; simulation.
- Real data. Discrete and mixed margins, observation weights, non-simplified (covariate-dependent) target edges.
- Three languages, one engine. A typed Fortran API (
fortvine_api), a C ABI, and thin Python and R packages that call the same compiled Fortran library — every density, fit and simulation runs in Fortran whichever language you use.
Python — pip install fortvine (wheels for Linux, macOS and Windows; no compiler needed), or
from GitHub: pip install "git+https://github.com/Bluerrror/fortvine#subdirectory=python".
See the Python page.
R — remotes::install_github("Bluerrror/fortvine", subdir = "r") (needs Rtools on Windows,
gfortran on Linux/macOS). See the R page.
Fortran — build the library from source:
git clone https://github.com/Bluerrror/fortvine.git
cd fortvine
bash build.sh test # builds build/libfortvine.a + shared library, runs the test suitesRequirements: gfortran 10 or newer with OpenMP (Linux, macOS, or Windows with MinGW-w64 /
MSYS2 / WinLibs). fpm works too: fpm build, fpm test.
Link your own program against the library:
gfortran -O2 -fopenmp -I fortvine/build my_program.f90 fortvine/build/libfortvine.a -o my_programprogram quickstart
use fortvine_api
implicit none
integer, parameter :: dp = kind(1.0d0), n = 2000, d = 5
type(fv_bicop) :: cop
type(fv_vinecop) :: vine
real(dp) :: u1(n), w(n), u2(n), u(n, d)
! a pair copula: simulate from Clayton(2), then select family, rotation and parameter by BIC
cop%family = FV_CLAYTON; cop%par(1) = 2.0_dp
call random_number(u1); call random_number(w)
call cop%hinv1(u1, w, u2)
call cop%select(u1, u2)
print *, 'pair copula: ', trim(fv_fam_name(cop%family)), cop%par(1)
! a vine copula: simulate from a D-vine, then select a regular vine from the sample
call vine%set_dvine([1, 2, 3, 4, 5])
vine%fam(:, 1) = FV_GUMBEL; vine%par(1, :, 1) = 2.0_dp
call vine%simulate(n, u, seed=1)
call vine%select(u)
print *, 'vine log-likelihood:', vine%loglik(u), ' parameters:', vine%npars()
end program quickstartMore in example/ and the examples pages.
| general form | families | examples |
|---|---|---|
| elliptical | 2 | Gaussian, Student t |
| Archimedean | 19 | Clayton, Gumbel, Frank, Joe, AMH, BB1-BB3, BB6-BB10, gamma.Sibuya, logseries.PS, ... |
| extreme-value | 14 | Tawn (3 forms), Galambos, Hüsler-Reiss, t-EV, BB5, asymmetric negative logistic, mixed models, Khoudraji-HR |
| Archimax | 68 | BB4, Archimax(gamma|HuslerReiss), Archimax(Sibuya|asymlogistic1), ... |
| Khoudraji | 3 | Khoudraji-Clayton, Khoudraji-Joe, Khoudraji-Frank |
| other | 2 | Plackett, FGM |
| nonparametric | 2 | TLL, Bernstein |
| independence | 1 |
The complete list with codes, parameter boxes, symmetry and tail behaviour is in the catalogue.
fortvine from Fortran, Python and R against pyvinecopulib 1.0.1 / rvinecopulib 0.7.2.1.0 (vinecopulib) and torchvine 0.2.2, on the same data, family set and criterion (one Windows machine, one thread unless stated; see the benchmark page for the method and all tables):
| task | fortvine Fortran | fortvine Python | fortvine R | pyvinecopulib | rvinecopulib | torchvine |
|---|---|---|---|---|---|---|
| Clayton density, ns per point | 43 | 39 | 160 | 66 | 110 | 39 |
| BB1 inverse h-function, ns per point | 752 | 756 | 2 700 | 8 282 | 19 080 | 1 691 |
| BB1 MLE fit, n = 5000 | 4.5 ms | 4.6 ms | 11.9 ms | 33 ms | 84 ms | 34 ms |
| family selection (12 families, rotations), n = 5000 | 51-100 ms | 49-100 ms | 137-265 ms | 0.68-1.0 s | 1.9-3.1 s | 0.39-0.81 s |
| vine selection, d = 10, n = 2000 | 2.1 s | 2.1 s | 5.8 s | 18.3 s | 40.6 s | 5.9 s |
| vine selection, d = 20, n = 2000, 8 threads | 1.2 s | 1.2 s | 3.3 s | 14.9 s | 29.8 s | — |
fortvine (from every language), pyvinecopulib and rvinecopulib reach identical maximum log-likelihoods in every comparison. The Python package runs at the native library's speed; the R package is slower on Windows only because R's compiler (Rtools, gfortran 12) is.
- Getting started — installation, quick start, concepts
- Manual — pair copulas, vines, fitting and selection, controls, rotations, discrete data, the generic engine, performance, C interface
- Families — every family with formulas and properties
- Examples — runnable programs with output
- API reference
- Theory — numerics, exact scores, validation
src/ the library: fortvine_ad (dual numbers), fortvine (kernels, C ABI), fortvine_api (typed API),
families_core.inc / families_ext.inc (hand-coded families), families_gen.inc (generic engine)
test/ test_fortvine (every family x rotation), test_genfam (generic engine)
example/ tutorial programs (Fortran, Python, R, C) and micro-benchmarks
python/ Python package (ctypes binding to the compiled library)
r/ R package (.Call binding; r/src/fortvine is a synced copy of src/)
bench/ cross-library benchmark (fv_bench.f90 + run_bench.py)
tools/ documentation generators: family catalogue (catalogue.f90), figures (figures.py + density_grid.f90, vine_sample.f90)
docs/ documentation site (MkDocs Material)
bash build.sh testruns test/test_fortvine (properties of every family in every rotation: h-functions against
numerical integrals of the density, inverse consistency, MLE recovery, vine identities) and
test/test_genfam (the generic engine: reproduction of the hand-coded families, density / h /
CDF consistency in four rotations, the edge-flip transpose, MLE recovery).
If you use fortvine — from Fortran, C, Python or R — in published work, please cite:
Shojaeezadeh, S. A. (2026). fortvine: a complete compendium to work on vine copula modeling. In preparation.
@unpublished{shojaeezadeh2026fortvine,
author = {Shojaeezadeh, Shahab Aldin},
title = {fortvine: a complete compendium to work on vine copula modeling},
year = {2026},
note = {In preparation. Software: https://github.com/Bluerrror/fortvine}
}GitHub's "Cite this repository" button (from CITATION.cff), citation("fortvine") in R
and fortvine.cite() in Python give the same reference.
fortvine is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License, version 3 or (at your option) any later version. Copyright (C) 2026 Shahab Aldin Shojaeezadeh. Distributed versions and derived works must stay under the GPL and keep this copyright notice.
