Skip to content

About

Branch efficiency benchmarking by DEA with slack-adjusted targets, named peer branches, bootstrap bias correction and a Malmquist split of productivity change into catch-up and frontier shift.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

peerfrontier

CI

peerfrontier

peerfrontier benchmarks bank branches by data envelopment analysis (DEA). Each branch is scored against a frontier built from the best observed branches, using several inputs and outputs at once, so a specialist is not penalised for its mix. The score comes with slack-adjusted input targets and a named blend of peer branches, a Simar-Wilson bootstrap that measures and corrects the small-sample bias in the scores, and a Malmquist index that splits year-on-year productivity change into branches catching up and the whole frontier moving. All linear programs run on SciPy's HiGHS solver. The data in this repository is synthetic and comes from a seeded generator with a known frontier.

The problem

A credit union with 60 branches ranks them by cost per teller transaction and sets staffing targets from that ratio. Branches do different work: a downtown branch handles thousands of teller transactions, a suburban one opens accounts and books car loans, and the business lending hub barely touches cash. A single ratio punishes specialists and gives the weakest branches no realistic target and no one to learn from. The regional manager wants a score that respects output mix, a concrete input target with named peer branches, and to know whether this year's improvement came from branches catching up or from the whole network moving.

How it works

flowchart LR
    A["Branch inputs<br/>staff FTE, opex<br/>Branch outputs<br/>transactions, accounts, loans"] --> B["Envelopment LPs<br/>CRS and VRS<br/>phase 1: theta<br/>phase 2: slacks"]
    B --> C["Scores, peer weights<br/>input targets<br/>output shortfalls"]
    B --> D["Smoothed bootstrap<br/>reflection, Silverman h<br/>bias-corrected VRS<br/>95% intervals"]
    A --> E["Cross-year CRS<br/>distance functions<br/>4 LPs per branch"]
    E --> F["Malmquist index<br/>catch-up x frontier shift"]
    A --> G["Single ratios<br/>cost per transaction"]
    C --> H["Report<br/>rank comparison"]
    D --> H
    F --> H
    G --> H
Loading

For branch o with inputs x_o and outputs y_o, phase 1 minimises theta so that a weighted blend of branches uses at most theta times x_o and produces at least y_o. Under variable returns to scale (VRS) the weights also sum to 1. Phase 2 fixes theta and maximises the total slack, so a branch on the frontier that still wastes one input is not reported as perfect. The target is theta times the input minus the input slack, and the output slack is the extra output the peers show is possible.

Constant returns to scale (CRS) scores divided by VRS scores give scale efficiency. A branch whose CRS and VRS scores agree is scale efficient (crs). For the rest a third model that forbids scaling up (non-increasing returns, weights summing to at most 1) decides: if its score matches the VRS score the branch is above its most productive scale (decreasing returns, drs), otherwise below it (increasing returns, irs). The label uses scores, which are unique, rather than peer weights, which can differ between optimal solutions. Super-efficiency (Andersen-Petersen) removes a branch from its own reference set, so frontier branches score above 1 and can be ranked. Under VRS that LP can be infeasible for a very large or very specialised branch; those are reported and scored under CRS instead.

Quick start

python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
peerfrontier generate --seed 29 --out data/
peerfrontier score --year 2025 --top 5
peerfrontier peers --branch B06
peerfrontier bootstrap --B 2000 --seed 5
peerfrontier malmquist --from 2024 --to 2025
peerfrontier report --out out/
pytest

Every command reads data/ by default; --data DIR changes it. bootstrap and report split the LPs over up to 8 processes (--workers N to change); the result does not depend on the worker count. bootstrap --B 2000 takes about 40 seconds on 8 cores.

Example output

All of this comes from peerfrontier generate --seed 29 and the commands above. Rows are elided with ....

$ peerfrontier score --year 2025 --top 5
Branch efficiency, 2025 (60 branches)
branch    crs    vrs  scale_eff  rts  super_crs  super_rank  cost_rank
------  -----  -----  ---------  ---  ---------  ----------  ---------
   B03  1.000  1.000      1.000  crs      1.130           1         60
   B19  1.000  1.000      1.000  crs      1.129           2         43
   B40  1.000  1.000      1.000  crs      1.093           3          1
   B01  1.000  1.000      1.000  crs      1.080           4          2
   B07  1.000  1.000      1.000  crs      1.047           5          6
   ...
   B56  0.654  0.674      0.970  irs      0.654          56         15
   B13  0.648  0.661      0.980  irs      0.648          57         58
   B10  0.638  0.649      0.982  irs      0.638          58          9
   B18  0.601  1.000      0.601  drs      0.601          59         54
   B06  0.540  0.540      1.000  crs      0.540          60         49

11 branches on the CRS frontier; VRS super-efficiency is infeasible for 5 (CRS fallback).

B03 is the business lending hub: it is last by cost per transaction (rank 60 of 60) and first by super-efficiency. B18 is efficient under VRS (1.000) but only 0.601 under CRS, with decreasing returns to scale: it is larger than its peers' most productive scale.

$ peerfrontier peers --branch B06
B06, 2025, CRS score 0.540

peer  lambda    fte  opex_k
----  ------  -----  ------
 B27   0.928   8.25   453.0
 B19   0.293  18.84  1122.4
 B07   0.127  21.19   910.7

 input   actual  target  reduction_pct
------  ------  ------  -------------
   fte    29.42   15.88           46.0
opex_k  1603.42  865.60           46.0

          output  actual  target  gain
----------------  ------  ------  ----
    teller_txn_k    98.0    98.0   0.0
    new_accounts  1450.0  1450.0   0.0
consumer_loans_m    36.1    36.1   0.0

B06 needs 54.0% of its current inputs to produce what it produces now.
Peers that can do so, with their weights: B27 (weight 0.93), B19 (weight 0.29), B07 (weight 0.13).
Staff FTE target: 15.9 against 29.4 now (46.0% lower).
Non-staff opex ($k) target: 865.6 against 1603.4 now (46.0% lower).

B06 is scale efficient (CRS and VRS scores are both 0.540), so score labels it crs. Its CRS peer weights sum to 1.35 here, but the weights of a CRS optimum are not unique and their sum says nothing about returns to scale on its own.

$ peerfrontier bootstrap --B 2000 --seed 5
Bootstrap VRS scores, 2025: B=2000, seed=5, bandwidth 0.0460, bias correction applied to 11 of 60 branches
branch    vrs   bias  corrected  lower  upper  adjusted
------  -----  -----  ---------  -----  -----  --------
   B03  1.000  0.174      1.000  0.378  0.996        no
   B07  1.000  0.169      1.000  0.454  0.997        no
   ...
   B05  1.000  0.028      0.972  0.937  0.997       yes
   B60  1.000  0.037      0.963  0.926  0.996       yes
   B48  0.991  0.029      0.962  0.930  0.987       yes
   ...
   B13  0.661  0.028      0.661  0.584  0.659        no
   B10  0.649  0.023      0.649  0.580  0.647        no
   B06  0.540  0.015      0.540  0.499  0.539        no

Branches on the VRS frontier carry estimated biases between 0.03 and 0.18: a branch cannot score above 1, so a score of exactly 1 says little about true efficiency. Where the bootstrap variance is large relative to the squared bias the correction would add more noise than it removes, so those branches keep their original score and a wide interval. The intervals are for the true efficiency and so lie below the VRS score; see the coverage caveat under Design decisions.

$ peerfrontier malmquist --from 2024 --to 2025 --top 4
Malmquist productivity change, 2024 to 2025
  branches: 60
  median catch-up (efficiency change): 1.000
  median frontier shift (technical change): 1.053
  median Malmquist index: 1.053
  branches with catch-up below 0.9: 6
  branches with a Malmquist index above 1: 54

branch  catch_up  frontier_shift  malmquist
------  --------  --------------  ---------
   B11     0.789           1.057      0.834
   B54     0.800           1.053      0.842
   B13     0.800           1.053      0.842
   B56     0.800           1.053      0.842
   ...
   B19     1.000           1.064      1.064
   B07     1.000           1.066      1.066
   B18     1.022           1.055      1.078
   B50     1.037           1.040      1.079

On the seeded network the generator planted a 5% input saving (a frontier shift of 1 / 0.95 = 1.053) and a 20% efficiency loss in six branches. The median frontier shift recovers 1.053 and exactly six branches have catch-up below 0.9. Against the generator's true efficiency, the CRS scores have a Spearman correlation of 0.995 and put 15 of the 15 truly least efficient branches in the 20 lowest scores; the cost-per-transaction ranking has a correlation of 0.13 and gets 6 of 15.

peerfrontier report --out out/ writes report.md (scores, peers for the 10 least efficient branches, bootstrap intervals, Malmquist table) and frontier.png, a plot of teller transactions against consumer loans per staff FTE with the frontier branches marked.

Design decisions

  • Two-phase LPs with normalised data. Phase 1 finds theta; phase 2 fixes it and maximises the slack sum. The reported slacks are therefore the largest ones consistent with the radial score, and a projected target always rescores as 1 with zero slack (tested under CRS and VRS). Both phases run on data divided by the column means, so slacks in different units are comparable and the solver sees well-scaled coefficients; the slacks are scaled back before they are returned.
  • Super-efficiency under VRS can fail, and that is reported. A branch whose output no convex mix of the others reaches has no VRS super-efficiency score. The model flags it (infeasible_vrs) and falls back to CRS rather than dropping it or inventing a number. The ranking in score uses the CRS super-efficiency because CRS scores exist for every branch.
  • Simar-Wilson bias correction is selective. Correcting every score would roughly quadruple the variance of the estimate for branches where the bias is small compared with its sampling noise. The correction is applied only where the bootstrap variance is below a third of the squared bias, following Simar and Wilson (2000); the threshold is the variance_ratio argument. Intervals are the raw Simar-Wilson percentile intervals of the bootstrap differences, capped at 1 and not adjusted to contain the reported score. They describe the true efficiency, so they sit below the VRS score, and a branch that keeps its original score lies above its own interval (49 of 60 branches here). The nominal 95% coverage is not achieved on this data: with 60 branches and five inputs and outputs the intervals contain the generator's true efficiency for 43% of branches (B = 2000, seed 5). Treat them as indicating direction and spread, not as calibrated 95% intervals.
  • Reflection and variance rescaling. DEA scores pile up at 1, so a plain kernel smoother would leak mass above the boundary. The sample is reflected around 1, the bandwidth is Silverman's rule on the reflected sample, draws above 1 are folded back, and the draws are rescaled so their variance matches the original scores. Pseudo inputs are the original inputs scaled along their ray.
  • Malmquist from four LPs per branch, in terms of input efficiency. Cross-period scores can exceed 1 (a branch can lie outside the other year's frontier), so the evaluation allows points outside the reference set. Catch-up is the ratio of own-period scores and the frontier shift is the geometric mean of the two cross-period ratios; their product is the index, and values above 1 always mean improvement.
  • Deterministic by construction. Every random draw of the bootstrap is made in one stream before any LP runs, so splitting the LPs over processes changes nothing. All ranks break ties on the branch id.

Testing

pytest

72 tests, about 40 seconds. They check:

  • hand-computed LP fixtures: the one-input one-output case (CRS scores 1, 0.75, 1, 0.5; VRS 1, 0.75, 1, 2/3; scale efficiency 0.75) and the two-input case with a second-input slack of 2;
  • invariants on the seeded data: VRS never below CRS, scale invariance, doubling inputs halves the score, a dominated branch changes nothing else, projections rescore as 1 with zero slack;
  • super-efficiency, VRS infeasibility, a loud failure (not zero slacks) when the slack LP is infeasible, and returns-to-scale labels;
  • recovery of the generator's true efficiency, the failure of the cost ratio on the two specialists, and the Malmquist decomposition of the planted shift and decline;
  • the bootstrap: corrected scores never above the originals, intervals equal the raw percentile interval recomputed independently and are not stretched to the reported score, exact repeatability across seeds and worker counts, and a floor on how often the intervals contain the generator's true efficiency;
  • every CLI command, including error exits.

Project layout

src/peerfrontier/
  dea.py         envelopment LPs, slacks, super-efficiency, returns to scale
  bootstrap.py   Simar-Wilson smoothed bootstrap and bias correction
  malmquist.py   Malmquist index, catch-up and frontier shift
  ratios.py      cost per transaction and companion ratios, stable ranks
  scoring.py     score table, peer report and sentences
  generate.py    seeded synthetic network with a known frontier
  data.py        column names and CSV loading
  report.py      markdown tables, report text, frontier plot
  cli.py         typer commands
tests/           pytest suite
.github/workflows/ci.yml

License

MIT, see LICENSE.

About

Branch efficiency benchmarking by DEA with slack-adjusted targets, named peer branches, bootstrap bias correction and a Malmquist split of productivity change into catch-up and frontier shift.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages