Skip to main content

shiftshare

PyPI Python pipeline License: MIT

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:

  • Location quotients: simple (SLQ), cross-industry (CILQ), Flegg (FLQ) with a user-chosen delta or lambda*, augmented FLQ (AFLQ), and regionalisation of national input-output coefficients.
  • Shift-share: classic (Dunn 1960), Esteban-Marquillas (1972) with homothetic employment and allocation effect, Arcelus (1984) eight-component model, and dynamic shift-share (Barff & Knight 1988).
  • Specialisation and localisation: Krugman specialisation index (against the nation, the rest of the nation, or pairwise), Hoover coefficients of localisation and specialisation, localisation curve with locational Gini, Herfindahl index.
  • Agglomeration: Ellison-Glaeser (1997) index and coagglomeration index, plant Herfindahl from plant sizes.
  • Economic base: basic employment and base multiplier by the assumption, location quotient and minimum requirements (Ullman & Dacey 1960) methods.

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:

  • Every shift-share decomposition adds up exactly to e1 - e0 for every cell. Cells with zero base employment have no growth rate; their change is booked as regional shift (classic), as competitive effect with zero allocation (Esteban-Marquillas, flagged in undefined), or in the regional industry-mix term (Arcelus).
  • No calibration constants are built in. Flegg's delta, the plant Herfindahl for the Ellison-Glaeser index, assumption-method basic sectors or fractions, and the comparable region set and rank for minimum requirements are all supplied by the user.

References:

  • Arcelus, F.J. (1984) An extension of shift-share analysis. Growth and Change 15(1), 3-8.
  • Barff, R.A. and Knight, P.L. (1988) Dynamic shift-share analysis. Growth and Change 19(2), 1-10.
  • Dunn, E.S. (1960) A statistical and analytical technique for regional analysis. Papers and Proceedings of the Regional Science Association 6, 97-112.
  • Ellison, G. and Glaeser, E.L. (1997) Geographic concentration in U.S. manufacturing industries: a dartboard approach. Journal of Political Economy 105(5), 889-927.
  • Esteban-Marquillas, J.M. (1972) A reinterpretation of shift-share analysis. Regional and Urban Economics 2(3), 249-255.
  • Flegg, A.T., Webber, C.D. and Elliott, M.V. (1995) On the appropriate use of location quotients in generating regional input-output tables. Regional Studies 29(6), 547-561.
  • Flegg, A.T. and Webber, C.D. (2000) Regional size, regional specialization and the FLQ formula. Regional Studies 34(6), 563-569.
  • Hirschman, A.O. (1964) The paternity of an index. American Economic Review 54(5), 761-762.
  • Hoover, E.M. (1936) The measurement of industrial localization. Review of Economics and Statistics 18(4), 162-171.
  • Isard, W. (1960) Methods of Regional Analysis: An Introduction to Regional Science. MIT Press.
  • Krugman, P. (1991) Geography and Trade. MIT Press.
  • Miller, R.E. and Blair, P.D. (2009) Input-Output Analysis: Foundations and Extensions, 2nd ed. Cambridge University Press.
  • Tiebout, C.M. (1962) The Community Economic Base Study. Committee for Economic Development.
  • Ullman, E.L. and Dacey, M.F. (1960) The minimum requirements approach to the urban economic base. Papers and Proceedings of the Regional Science Association 6, 175-194.

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.0},
  year    = {2026},
  url     = {https://gitlab.com/geophilo1/shiftshare_sdk}
}

and the original sources of the methods you use.

License

MIT. See LICENSE.

Metadata

Release files for shiftshare 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for shiftshare 0.1.0
File Size Uploaded Provenance Actions
shiftshare-0.1.0.tar.gz 40.7 kB Without provenance Details for shiftshare-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for shiftshare 0.1.0
File Interpreter ABI Platform Actions
shiftshare-0.1.0-py3-none-any.whl Python 3 none any Details for shiftshare-0.1.0-py3-none-any.whl

Total release size: 75.1 kB

Release files / shiftshare-0.1.0.tar.gz

Download URL shiftshare-0.1.0.tar.gz
Size 40.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e4d273cf98d32bf712bfe6068c1a735960c2f3f55aba254838866c80339808b0
BLAKE2b-256 checksum
How to use checksums
23bd9b332c7582ed1750937608ac6320f10a129fcf4417a34fbd8b187d88f74a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.18

Release files / shiftshare-0.1.0-py3-none-any.whl

Download URL shiftshare-0.1.0-py3-none-any.whl
Size 34.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fe4dff4aab39a4cdc850c24e5095456007416fb0dcd5637417bbec99e61db07b
BLAKE2b-256 checksum
How to use checksums
76fcdc8ea89a0c943b0c99aa206dc1caa6fe38e5ac6c7c53e7ae598cbd5eeae0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.18

Security for shiftshare 0.1.0

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page