shiftshare

Regional economic analysis for planners: location quotients (SLQ, CILQ, FLQ, AFLQ), shift-share decompositions (Dunn, Esteban-Marquillas, Arcelus, dynamic), Krugman and Hoover indices, Ellison-Glaeser agglomeration and economic base multipliers.

Version 0.1.2 · Python >=3.9 · MIT licence
pip install shiftshare
PyPISourceIssuesChangelogCite (DOI)

shiftshare

PyPI version Python versions pipeline status License: MIT DOI Downloads

Regional economic analysis on region x sector employment tables.

shiftshare collects the standard tools of regional economic analysis used in planning practice and regional science, working on a matrix of employment (or output, or establishments) by region and sector:

It needs only NumPy. Inputs can be NumPy arrays, nested lists, or labelled EmploymentTables read from CSV (wide or long) or JSON. A command-line tool is included.

Installation

pip install shiftshare

Requires Python 3.9 or newer.

Quickstart

import numpy as np
import shiftshare as ss

# rows = regions, columns = sectors
base = np.array([[60, 40], [40, 60]], dtype=float)
end = np.array([[75, 40], [45, 70]], dtype=float)

ss.location_quotient(base)            # [[1.2, 0.8], [0.8, 1.2]]

res = ss.classic(base, end)           # Dunn (1960)
res.national_share                    # [[9, 6], [6, 9]]
res.industry_mix                      # [[3, -2], [2, -3]]
res.regional_shift                    # [[3, -4], [-3, 4]]
res.region_totals()                   # each component summed per region

em = ss.esteban_marquillas(base, end)
em.competitive, em.allocation         # split of the regional shift
em.allocation_type()                  # "competitive advantage, specialized", ...

ss.arcelus(base, end).components()    # eight components that add up to the change
ss.dynamic([base, end, end * 1.05])   # year-by-year shift-share, summed

ss.krugman_index(base, versus="rest")         # [0.4, 0.4]
ss.coefficient_of_localization(base)          # Hoover, per sector
ss.lq_method(base).multiplier                 # economic base multiplier, LQ method
ss.minimum_requirements(base).multiplier      # Ullman & Dacey
ss.flq(base[0], base.sum(axis=0), delta=0.3)  # FLQ matrix for region 0

With labels:

t = ss.read_table("employment_2015.csv")      # wide: region,Agri,Manuf,...  or long
t.label(ss.location_quotient(t), "lq")        # [{"region":..., "sector":..., "lq":...}]
ss.profile(t)                                 # LQs, specialisation, localisation, multipliers
ss.decompose(t, ss.read_table("employment_2023.csv"), "esteban-marquillas")

National totals default to the column sums of the matrix (the regions make up the nation). When the regions are only part of the nation, pass the national sector totals as reference= (structure measures) or national_base= / national_end= (shift-share).

Features

Area Functions
Location quotients location_quotient, cross_industry_lq, flegg_lambda, flq, aflq, regionalize
Shift-share classic, esteban_marquillas, arcelus, dynamic, growth_rates
Specialisation krugman_index, krugman_pairwise, coefficient_of_specialization, herfindahl, sector_shares
Localisation coefficient_of_localization, localization_curve
Agglomeration ellison_glaeser, coagglomeration, raw_concentration, plant_herfindahl
Economic base assumption_method, lq_method, minimum_requirements, base_multiplier
Tables and I/O EmploymentTable, read_table, read_vector, write_csv, write_json, profile, decompose, decompose_dynamic

Methods and sources

Notation: e[r,i] employment of sector i in region r, e[r] regional total, E[i] national sector total, E national total; 0 base year, 1 end year; G = E1/E0 - 1, G[i] = E1[i]/E0[i] - 1, g[r] = e1[r]/e0[r] - 1, g[r,i] = e1[r,i]/e0[r,i] - 1.

Measure Definition Source
SLQ (e[r,i]/e[r]) / (E[i]/E) Isard (1960); Miller & Blair (2009)
CILQ SLQ[i] / SLQ[j] (supplying i, purchasing j) Miller & Blair (2009)
FLQ lambda* CILQ[i,j], diagonal lambda* SLQ[i], lambda* = [log2(1 + RE/NE)]^delta, 0 <= delta < 1 Flegg, Webber & Elliott (1995)
AFLQ FLQ[i,j] log2(1 + SLQ[j]) where SLQ[j] > 1 Flegg & Webber (2000)
Regionalisation r[i,j] = a[i,j] min(LQ, 1) Miller & Blair (2009)
Classic shift-share NS = e0 G, IM = e0 (G[i] - G), RS = e0 (g[r,i] - G[i]) Dunn (1960)
Esteban-Marquillas e_hat = e0[r] E0[i]/E0; C' = e_hat (g[r,i] - G[i]), A = (e0 - e_hat)(g[r,i] - G[i]) Esteban-Marquillas (1972)
Arcelus rate split G + (G[i]-G) + (g[r]-G) + [(g[r,i]-g[r]) - (G[i]-G)], each applied to e_hat and e0 - e_hat Arcelus (1984)
Dynamic shift-share classic model on each consecutive pair of years, summed Barff & Knight (1988)
Krugman index `sum_i s[r,i] - s_ref[i]
Coefficient of specialisation `0.5 sum_i e[r,i]/e[r] - E[i]/E
Coefficient of localisation `0.5 sum_r e[r,i]/E[i] - e[r]/E
Locational Gini 2 x area between the localisation curve (regions by decreasing LQ) and the diagonal (Krugman reports the undoubled area, maximum 0.5) Hoover (1936); Krugman (1991, app. D)
Herfindahl sum_i s[r,i]^2 Hirschman (1964)
Ellison-Glaeser gamma = (G - (1 - sum x^2) H) / ((1 - sum x^2)(1 - H)), G = sum_r (s_r - x_r)^2 Ellison & Glaeser (1997)
Coagglomeration [G/(1 - sum x^2) - H - sum_j gamma_j w_j^2 (1 - H_j)] / (1 - sum_j w_j^2) Ellison & Glaeser (1997)
LQ basic employment max(e[r,i] - e[r] E[i]/E, 0) Isard (1960); Tiebout (1962)
Minimum requirements max(e[r,i] - m[i] e[r], 0), m[i] the smallest share among comparable regions Ullman & Dacey (1960)
Base multiplier total / basic Tiebout (1962)

Conventions and choices:

References:

Command line

shiftshare profile employment_2015.csv --csv lq.csv -o profile.json
shiftshare decompose employment_2015.csv employment_2023.csv --method esteban-marquillas \
    --national-base nation_2015.csv --national-end nation_2023.csv --csv components.csv
shiftshare dynamic emp_2019.csv emp_2020.csv emp_2021.csv emp_2022.csv
shiftshare base employment_2023.csv --method mr --csv basic.csv
shiftshare base employment_2023.csv --method assumption --basic-sectors Manufacturing,Mining
shiftshare flq employment_2023.csv --region Coast --delta 0.3 --coefficients national_A.csv
shiftshare eg plants_by_region.csv --herfindahl plant_herfindahl.csv

Tables are CSV (wide: first column region, one column per sector; or long: region, sector, employment/value columns; ,, ; or tab separated) or JSON. Sector vectors (national totals, Herfindahl values) are CSV sector,value rows or a JSON object. Results are printed as JSON or written with -o; --csv writes the detailed table.

Citation

If you use shiftshare in your work, please cite it (see CITATION.cff):

@software{eminoglu_shiftshare,
  author  = {Eminoğlu, Yusuf},
  title   = {shiftshare: regional economic analysis on region x sector employment tables},
  version = {0.1.2},
  doi     = {10.5281/zenodo.24235554},
  year    = {2026},
  url     = {https://gitlab.com/geophilo1/shiftshare_sdk}
}

and the original sources of the methods you use.

Related Geophilo SDKs

License

MIT. See LICENSE.

Other Geophilo SDKs