shiftshare 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- shiftshare-0.1.0/CHANGELOG.md +29 -0
- shiftshare-0.1.0/CITATION.cff +21 -0
- shiftshare-0.1.0/LICENSE +21 -0
- shiftshare-0.1.0/MANIFEST.in +9 -0
- shiftshare-0.1.0/PKG-INFO +223 -0
- shiftshare-0.1.0/README.md +187 -0
- shiftshare-0.1.0/examples/quickstart.py +71 -0
- shiftshare-0.1.0/pyproject.toml +111 -0
- shiftshare-0.1.0/setup.cfg +4 -0
- shiftshare-0.1.0/src/shiftshare/__init__.py +114 -0
- shiftshare-0.1.0/src/shiftshare/__main__.py +7 -0
- shiftshare-0.1.0/src/shiftshare/_common.py +265 -0
- shiftshare-0.1.0/src/shiftshare/_version.py +1 -0
- shiftshare-0.1.0/src/shiftshare/agglomeration.py +165 -0
- shiftshare-0.1.0/src/shiftshare/analysis.py +122 -0
- shiftshare-0.1.0/src/shiftshare/base.py +201 -0
- shiftshare-0.1.0/src/shiftshare/cli.py +202 -0
- shiftshare-0.1.0/src/shiftshare/decomposition.py +541 -0
- shiftshare-0.1.0/src/shiftshare/io.py +167 -0
- shiftshare-0.1.0/src/shiftshare/py.typed +0 -0
- shiftshare-0.1.0/src/shiftshare/quotients.py +195 -0
- shiftshare-0.1.0/src/shiftshare/specialization.py +168 -0
- shiftshare-0.1.0/src/shiftshare.egg-info/PKG-INFO +223 -0
- shiftshare-0.1.0/src/shiftshare.egg-info/SOURCES.txt +31 -0
- shiftshare-0.1.0/src/shiftshare.egg-info/dependency_links.txt +1 -0
- shiftshare-0.1.0/src/shiftshare.egg-info/entry_points.txt +2 -0
- shiftshare-0.1.0/src/shiftshare.egg-info/requires.txt +7 -0
- shiftshare-0.1.0/src/shiftshare.egg-info/top_level.txt +1 -0
- shiftshare-0.1.0/tests/conftest.py +22 -0
- shiftshare-0.1.0/tests/test_decomposition.py +156 -0
- shiftshare-0.1.0/tests/test_quotients.py +77 -0
- shiftshare-0.1.0/tests/test_structure.py +144 -0
- shiftshare-0.1.0/tests/test_table_io_cli.py +203 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## [Unreleased]
|
|
6
|
+
|
|
7
|
+
## [0.1.0] - 2026-11-15
|
|
8
|
+
### Added
|
|
9
|
+
- Location quotients: simple (SLQ), cross-industry (CILQ), Flegg (FLQ) with user-given
|
|
10
|
+
`delta` or `lambda*`, augmented FLQ (AFLQ), and LQ regionalisation of national
|
|
11
|
+
input-output coefficients.
|
|
12
|
+
- Shift-share: classic (Dunn 1960), Esteban-Marquillas (1972) with homothetic employment,
|
|
13
|
+
allocation effect and its four-way reading, Arcelus (1984) eight-component model and
|
|
14
|
+
dynamic shift-share (Barff & Knight 1988); all add up exactly to the observed change.
|
|
15
|
+
- Specialisation and localisation: Krugman index (against the nation, the rest of the
|
|
16
|
+
nation, pairwise), Hoover coefficients of localisation and specialisation, localisation
|
|
17
|
+
curve with locational Gini, Herfindahl index.
|
|
18
|
+
- Ellison-Glaeser (1997) agglomeration and coagglomeration indices.
|
|
19
|
+
- Economic base: assumption, location quotient and minimum requirements methods with the
|
|
20
|
+
base multiplier.
|
|
21
|
+
- `EmploymentTable` with labels; CSV (wide or long) and JSON reading; CSV and JSON writing.
|
|
22
|
+
- Command line: `shiftshare profile | decompose | dynamic | base | flq | eg`.
|
|
23
|
+
|
|
24
|
+
### Fixed (pre-release review)
|
|
25
|
+
- Krugman (1991) specialisation index now cited to chapter 3 rather than appendix D;
|
|
26
|
+
appendix D (locational Gini) is cited for the localisation curve, with a note that
|
|
27
|
+
Krugman reports the undoubled area (maximum 0.5).
|
|
28
|
+
- Hirschman (1964) page range corrected to 761-762; removed an unverified table reference
|
|
29
|
+
for the Esteban-Marquillas (1972) allocation types.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
message: "If you use this software, please cite it as below."
|
|
3
|
+
authors:
|
|
4
|
+
- family-names: "Eminoğlu"
|
|
5
|
+
given-names: "Yusuf"
|
|
6
|
+
email: "geospacephilo@gmail.com"
|
|
7
|
+
orcid: "https://orcid.org/0009-0005-6000-2934"
|
|
8
|
+
title: "shiftshare"
|
|
9
|
+
version: "0.1.0"
|
|
10
|
+
date-released: "2026-11-15"
|
|
11
|
+
license: "MIT"
|
|
12
|
+
repository-code: "https://gitlab.com/geophilo1/shiftshare_sdk"
|
|
13
|
+
url: "https://pypi.org/project/shiftshare/"
|
|
14
|
+
abstract: "Regional economic analysis on region by sector employment tables: simple, cross-industry, Flegg and augmented Flegg location quotients with input-output regionalisation; classic, Esteban-Marquillas, Arcelus and dynamic shift-share decompositions; Krugman specialisation, Hoover localisation and specialisation coefficients and locational Gini; the Ellison-Glaeser agglomeration and coagglomeration indices; and economic base multipliers by the assumption, location quotient and minimum requirements methods."
|
|
15
|
+
keywords:
|
|
16
|
+
- shift-share analysis
|
|
17
|
+
- location quotient
|
|
18
|
+
- regional economics
|
|
19
|
+
- economic base
|
|
20
|
+
- agglomeration
|
|
21
|
+
- urban planning
|
shiftshare-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Yusuf Eminoğlu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: shiftshare
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: 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.
|
|
5
|
+
Author-email: Yusuf Eminoğlu <geospacephilo@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://gitlab.com/geophilo1/shiftshare_sdk
|
|
8
|
+
Project-URL: Repository, https://gitlab.com/geophilo1/shiftshare_sdk
|
|
9
|
+
Project-URL: Issues, https://gitlab.com/geophilo1/shiftshare_sdk/-/work_items
|
|
10
|
+
Project-URL: Changelog, https://gitlab.com/geophilo1/shiftshare_sdk/-/blob/main/CHANGELOG.md
|
|
11
|
+
Keywords: shift-share,location-quotient,flq,regional-economics,regional-science,economic-base,base-multiplier,minimum-requirements,krugman-index,hoover,ellison-glaeser,agglomeration,specialization,urban-planning
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Operating System :: OS Independent
|
|
20
|
+
Classifier: Environment :: Console
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering
|
|
22
|
+
Classifier: Topic :: Office/Business :: Financial
|
|
23
|
+
Classifier: Intended Audience :: Science/Research
|
|
24
|
+
Classifier: Intended Audience :: Developers
|
|
25
|
+
Classifier: Typing :: Typed
|
|
26
|
+
Requires-Python: >=3.9
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
License-File: LICENSE
|
|
29
|
+
Requires-Dist: numpy>=1.21
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
32
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
33
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
34
|
+
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
|
|
37
|
+
# shiftshare
|
|
38
|
+
|
|
39
|
+
[](https://pypi.org/project/shiftshare/)
|
|
40
|
+
[](https://pypi.org/project/shiftshare/)
|
|
41
|
+
[](https://gitlab.com/geophilo1/shiftshare_sdk/-/pipelines)
|
|
42
|
+
[](https://gitlab.com/geophilo1/shiftshare_sdk/-/blob/main/LICENSE)
|
|
43
|
+
|
|
44
|
+
**Regional economic analysis on region x sector employment tables.**
|
|
45
|
+
|
|
46
|
+
`shiftshare` collects the standard tools of regional economic analysis used in planning
|
|
47
|
+
practice and regional science, working on a matrix of employment (or output, or
|
|
48
|
+
establishments) by region and sector:
|
|
49
|
+
|
|
50
|
+
- **Location quotients**: simple (SLQ), cross-industry (CILQ), Flegg (FLQ) with a
|
|
51
|
+
user-chosen `delta` or `lambda*`, augmented FLQ (AFLQ), and regionalisation of national
|
|
52
|
+
input-output coefficients.
|
|
53
|
+
- **Shift-share**: classic (Dunn 1960), Esteban-Marquillas (1972) with homothetic
|
|
54
|
+
employment and allocation effect, Arcelus (1984) eight-component model, and dynamic
|
|
55
|
+
shift-share (Barff & Knight 1988).
|
|
56
|
+
- **Specialisation and localisation**: Krugman specialisation index (against the nation,
|
|
57
|
+
the rest of the nation, or pairwise), Hoover coefficients of localisation and
|
|
58
|
+
specialisation, localisation curve with locational Gini, Herfindahl index.
|
|
59
|
+
- **Agglomeration**: Ellison-Glaeser (1997) index and coagglomeration index, plant
|
|
60
|
+
Herfindahl from plant sizes.
|
|
61
|
+
- **Economic base**: basic employment and base multiplier by the assumption, location
|
|
62
|
+
quotient and minimum requirements (Ullman & Dacey 1960) methods.
|
|
63
|
+
|
|
64
|
+
It needs only NumPy. Inputs can be NumPy arrays, nested lists, or labelled
|
|
65
|
+
`EmploymentTable`s read from CSV (wide or long) or JSON. A command-line tool is included.
|
|
66
|
+
|
|
67
|
+
## Installation
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
pip install shiftshare
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Requires Python 3.9 or newer.
|
|
74
|
+
|
|
75
|
+
## Quickstart
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
import numpy as np
|
|
79
|
+
import shiftshare as ss
|
|
80
|
+
|
|
81
|
+
# rows = regions, columns = sectors
|
|
82
|
+
base = np.array([[60, 40], [40, 60]], dtype=float)
|
|
83
|
+
end = np.array([[75, 40], [45, 70]], dtype=float)
|
|
84
|
+
|
|
85
|
+
ss.location_quotient(base) # [[1.2, 0.8], [0.8, 1.2]]
|
|
86
|
+
|
|
87
|
+
res = ss.classic(base, end) # Dunn (1960)
|
|
88
|
+
res.national_share # [[9, 6], [6, 9]]
|
|
89
|
+
res.industry_mix # [[3, -2], [2, -3]]
|
|
90
|
+
res.regional_shift # [[3, -4], [-3, 4]]
|
|
91
|
+
res.region_totals() # each component summed per region
|
|
92
|
+
|
|
93
|
+
em = ss.esteban_marquillas(base, end)
|
|
94
|
+
em.competitive, em.allocation # split of the regional shift
|
|
95
|
+
em.allocation_type() # "competitive advantage, specialized", ...
|
|
96
|
+
|
|
97
|
+
ss.arcelus(base, end).components() # eight components that add up to the change
|
|
98
|
+
ss.dynamic([base, end, end * 1.05]) # year-by-year shift-share, summed
|
|
99
|
+
|
|
100
|
+
ss.krugman_index(base, versus="rest") # [0.4, 0.4]
|
|
101
|
+
ss.coefficient_of_localization(base) # Hoover, per sector
|
|
102
|
+
ss.lq_method(base).multiplier # economic base multiplier, LQ method
|
|
103
|
+
ss.minimum_requirements(base).multiplier # Ullman & Dacey
|
|
104
|
+
ss.flq(base[0], base.sum(axis=0), delta=0.3) # FLQ matrix for region 0
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
With labels:
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
t = ss.read_table("employment_2015.csv") # wide: region,Agri,Manuf,... or long
|
|
111
|
+
t.label(ss.location_quotient(t), "lq") # [{"region":..., "sector":..., "lq":...}]
|
|
112
|
+
ss.profile(t) # LQs, specialisation, localisation, multipliers
|
|
113
|
+
ss.decompose(t, ss.read_table("employment_2023.csv"), "esteban-marquillas")
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
National totals default to the column sums of the matrix (the regions make up the
|
|
117
|
+
nation). When the regions are only part of the nation, pass the national sector totals as
|
|
118
|
+
`reference=` (structure measures) or `national_base=` / `national_end=` (shift-share).
|
|
119
|
+
|
|
120
|
+
## Features
|
|
121
|
+
|
|
122
|
+
| Area | Functions |
|
|
123
|
+
| --- | --- |
|
|
124
|
+
| Location quotients | `location_quotient`, `cross_industry_lq`, `flegg_lambda`, `flq`, `aflq`, `regionalize` |
|
|
125
|
+
| Shift-share | `classic`, `esteban_marquillas`, `arcelus`, `dynamic`, `growth_rates` |
|
|
126
|
+
| Specialisation | `krugman_index`, `krugman_pairwise`, `coefficient_of_specialization`, `herfindahl`, `sector_shares` |
|
|
127
|
+
| Localisation | `coefficient_of_localization`, `localization_curve` |
|
|
128
|
+
| Agglomeration | `ellison_glaeser`, `coagglomeration`, `raw_concentration`, `plant_herfindahl` |
|
|
129
|
+
| Economic base | `assumption_method`, `lq_method`, `minimum_requirements`, `base_multiplier` |
|
|
130
|
+
| Tables and I/O | `EmploymentTable`, `read_table`, `read_vector`, `write_csv`, `write_json`, `profile`, `decompose`, `decompose_dynamic` |
|
|
131
|
+
|
|
132
|
+
## Methods and sources
|
|
133
|
+
|
|
134
|
+
Notation: `e[r,i]` employment of sector `i` in region `r`, `e[r]` regional total, `E[i]`
|
|
135
|
+
national sector total, `E` national total; `0` base year, `1` end year; `G = E1/E0 - 1`,
|
|
136
|
+
`G[i] = E1[i]/E0[i] - 1`, `g[r] = e1[r]/e0[r] - 1`, `g[r,i] = e1[r,i]/e0[r,i] - 1`.
|
|
137
|
+
|
|
138
|
+
| Measure | Definition | Source |
|
|
139
|
+
| --- | --- | --- |
|
|
140
|
+
| SLQ | `(e[r,i]/e[r]) / (E[i]/E)` | Isard (1960); Miller & Blair (2009) |
|
|
141
|
+
| CILQ | `SLQ[i] / SLQ[j]` (supplying `i`, purchasing `j`) | Miller & Blair (2009) |
|
|
142
|
+
| FLQ | `lambda* CILQ[i,j]`, diagonal `lambda* SLQ[i]`, `lambda* = [log2(1 + RE/NE)]^delta`, `0 <= delta < 1` | Flegg, Webber & Elliott (1995) |
|
|
143
|
+
| AFLQ | `FLQ[i,j] log2(1 + SLQ[j])` where `SLQ[j] > 1` | Flegg & Webber (2000) |
|
|
144
|
+
| Regionalisation | `r[i,j] = a[i,j] min(LQ, 1)` | Miller & Blair (2009) |
|
|
145
|
+
| Classic shift-share | `NS = e0 G`, `IM = e0 (G[i] - G)`, `RS = e0 (g[r,i] - G[i])` | Dunn (1960) |
|
|
146
|
+
| 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) |
|
|
147
|
+
| 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) |
|
|
148
|
+
| Dynamic shift-share | classic model on each consecutive pair of years, summed | Barff & Knight (1988) |
|
|
149
|
+
| Krugman index | `sum_i |s[r,i] - s_ref[i]|`, 0 to 2 | Krugman (1991) |
|
|
150
|
+
| Coefficient of specialisation | `0.5 sum_i |e[r,i]/e[r] - E[i]/E|` | Hoover (1936); Isard (1960) |
|
|
151
|
+
| Coefficient of localisation | `0.5 sum_r |e[r,i]/E[i] - e[r]/E|` | Hoover (1936) |
|
|
152
|
+
| 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) |
|
|
153
|
+
| Herfindahl | `sum_i s[r,i]^2` | Hirschman (1964) |
|
|
154
|
+
| 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) |
|
|
155
|
+
| 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) |
|
|
156
|
+
| LQ basic employment | `max(e[r,i] - e[r] E[i]/E, 0)` | Isard (1960); Tiebout (1962) |
|
|
157
|
+
| Minimum requirements | `max(e[r,i] - m[i] e[r], 0)`, `m[i]` the smallest share among comparable regions | Ullman & Dacey (1960) |
|
|
158
|
+
| Base multiplier | `total / basic` | Tiebout (1962) |
|
|
159
|
+
|
|
160
|
+
Conventions and choices:
|
|
161
|
+
|
|
162
|
+
- Every shift-share decomposition adds up exactly to `e1 - e0` for every cell. Cells with
|
|
163
|
+
zero base employment have no growth rate; their change is booked as regional shift
|
|
164
|
+
(classic), as competitive effect with zero allocation (Esteban-Marquillas, flagged in
|
|
165
|
+
`undefined`), or in the regional industry-mix term (Arcelus).
|
|
166
|
+
- No calibration constants are built in. Flegg's `delta`, the plant Herfindahl for the
|
|
167
|
+
Ellison-Glaeser index, assumption-method basic sectors or fractions, and the comparable
|
|
168
|
+
region set and rank for minimum requirements are all supplied by the user.
|
|
169
|
+
|
|
170
|
+
References:
|
|
171
|
+
|
|
172
|
+
- Arcelus, F.J. (1984) An extension of shift-share analysis. *Growth and Change* 15(1), 3-8.
|
|
173
|
+
- Barff, R.A. and Knight, P.L. (1988) Dynamic shift-share analysis. *Growth and Change* 19(2), 1-10.
|
|
174
|
+
- Dunn, E.S. (1960) A statistical and analytical technique for regional analysis. *Papers and Proceedings of the Regional Science Association* 6, 97-112.
|
|
175
|
+
- 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.
|
|
176
|
+
- Esteban-Marquillas, J.M. (1972) A reinterpretation of shift-share analysis. *Regional and Urban Economics* 2(3), 249-255.
|
|
177
|
+
- 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.
|
|
178
|
+
- Flegg, A.T. and Webber, C.D. (2000) Regional size, regional specialization and the FLQ formula. *Regional Studies* 34(6), 563-569.
|
|
179
|
+
- Hirschman, A.O. (1964) The paternity of an index. *American Economic Review* 54(5), 761-762.
|
|
180
|
+
- Hoover, E.M. (1936) The measurement of industrial localization. *Review of Economics and Statistics* 18(4), 162-171.
|
|
181
|
+
- Isard, W. (1960) *Methods of Regional Analysis: An Introduction to Regional Science*. MIT Press.
|
|
182
|
+
- Krugman, P. (1991) *Geography and Trade*. MIT Press.
|
|
183
|
+
- Miller, R.E. and Blair, P.D. (2009) *Input-Output Analysis: Foundations and Extensions*, 2nd ed. Cambridge University Press.
|
|
184
|
+
- Tiebout, C.M. (1962) *The Community Economic Base Study*. Committee for Economic Development.
|
|
185
|
+
- 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.
|
|
186
|
+
|
|
187
|
+
## Command line
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
shiftshare profile employment_2015.csv --csv lq.csv -o profile.json
|
|
191
|
+
shiftshare decompose employment_2015.csv employment_2023.csv --method esteban-marquillas \
|
|
192
|
+
--national-base nation_2015.csv --national-end nation_2023.csv --csv components.csv
|
|
193
|
+
shiftshare dynamic emp_2019.csv emp_2020.csv emp_2021.csv emp_2022.csv
|
|
194
|
+
shiftshare base employment_2023.csv --method mr --csv basic.csv
|
|
195
|
+
shiftshare base employment_2023.csv --method assumption --basic-sectors Manufacturing,Mining
|
|
196
|
+
shiftshare flq employment_2023.csv --region Coast --delta 0.3 --coefficients national_A.csv
|
|
197
|
+
shiftshare eg plants_by_region.csv --herfindahl plant_herfindahl.csv
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
Tables are CSV (wide: first column region, one column per sector; or long: `region`,
|
|
201
|
+
`sector`, `employment`/`value` columns; `,`, `;` or tab separated) or JSON. Sector vectors
|
|
202
|
+
(national totals, Herfindahl values) are CSV `sector,value` rows or a JSON object. Results
|
|
203
|
+
are printed as JSON or written with `-o`; `--csv` writes the detailed table.
|
|
204
|
+
|
|
205
|
+
## Citation
|
|
206
|
+
|
|
207
|
+
If you use `shiftshare` in your work, please cite it (see `CITATION.cff`):
|
|
208
|
+
|
|
209
|
+
```bibtex
|
|
210
|
+
@software{eminoglu_shiftshare,
|
|
211
|
+
author = {Eminoğlu, Yusuf},
|
|
212
|
+
title = {shiftshare: regional economic analysis on region x sector employment tables},
|
|
213
|
+
version = {0.1.0},
|
|
214
|
+
year = {2026},
|
|
215
|
+
url = {https://gitlab.com/geophilo1/shiftshare_sdk}
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
and the original sources of the methods you use.
|
|
220
|
+
|
|
221
|
+
## License
|
|
222
|
+
|
|
223
|
+
MIT. See `LICENSE`.
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# shiftshare
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/shiftshare/)
|
|
4
|
+
[](https://pypi.org/project/shiftshare/)
|
|
5
|
+
[](https://gitlab.com/geophilo1/shiftshare_sdk/-/pipelines)
|
|
6
|
+
[](https://gitlab.com/geophilo1/shiftshare_sdk/-/blob/main/LICENSE)
|
|
7
|
+
|
|
8
|
+
**Regional economic analysis on region x sector employment tables.**
|
|
9
|
+
|
|
10
|
+
`shiftshare` collects the standard tools of regional economic analysis used in planning
|
|
11
|
+
practice and regional science, working on a matrix of employment (or output, or
|
|
12
|
+
establishments) by region and sector:
|
|
13
|
+
|
|
14
|
+
- **Location quotients**: simple (SLQ), cross-industry (CILQ), Flegg (FLQ) with a
|
|
15
|
+
user-chosen `delta` or `lambda*`, augmented FLQ (AFLQ), and regionalisation of national
|
|
16
|
+
input-output coefficients.
|
|
17
|
+
- **Shift-share**: classic (Dunn 1960), Esteban-Marquillas (1972) with homothetic
|
|
18
|
+
employment and allocation effect, Arcelus (1984) eight-component model, and dynamic
|
|
19
|
+
shift-share (Barff & Knight 1988).
|
|
20
|
+
- **Specialisation and localisation**: Krugman specialisation index (against the nation,
|
|
21
|
+
the rest of the nation, or pairwise), Hoover coefficients of localisation and
|
|
22
|
+
specialisation, localisation curve with locational Gini, Herfindahl index.
|
|
23
|
+
- **Agglomeration**: Ellison-Glaeser (1997) index and coagglomeration index, plant
|
|
24
|
+
Herfindahl from plant sizes.
|
|
25
|
+
- **Economic base**: basic employment and base multiplier by the assumption, location
|
|
26
|
+
quotient and minimum requirements (Ullman & Dacey 1960) methods.
|
|
27
|
+
|
|
28
|
+
It needs only NumPy. Inputs can be NumPy arrays, nested lists, or labelled
|
|
29
|
+
`EmploymentTable`s read from CSV (wide or long) or JSON. A command-line tool is included.
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install shiftshare
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Requires Python 3.9 or newer.
|
|
38
|
+
|
|
39
|
+
## Quickstart
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
import numpy as np
|
|
43
|
+
import shiftshare as ss
|
|
44
|
+
|
|
45
|
+
# rows = regions, columns = sectors
|
|
46
|
+
base = np.array([[60, 40], [40, 60]], dtype=float)
|
|
47
|
+
end = np.array([[75, 40], [45, 70]], dtype=float)
|
|
48
|
+
|
|
49
|
+
ss.location_quotient(base) # [[1.2, 0.8], [0.8, 1.2]]
|
|
50
|
+
|
|
51
|
+
res = ss.classic(base, end) # Dunn (1960)
|
|
52
|
+
res.national_share # [[9, 6], [6, 9]]
|
|
53
|
+
res.industry_mix # [[3, -2], [2, -3]]
|
|
54
|
+
res.regional_shift # [[3, -4], [-3, 4]]
|
|
55
|
+
res.region_totals() # each component summed per region
|
|
56
|
+
|
|
57
|
+
em = ss.esteban_marquillas(base, end)
|
|
58
|
+
em.competitive, em.allocation # split of the regional shift
|
|
59
|
+
em.allocation_type() # "competitive advantage, specialized", ...
|
|
60
|
+
|
|
61
|
+
ss.arcelus(base, end).components() # eight components that add up to the change
|
|
62
|
+
ss.dynamic([base, end, end * 1.05]) # year-by-year shift-share, summed
|
|
63
|
+
|
|
64
|
+
ss.krugman_index(base, versus="rest") # [0.4, 0.4]
|
|
65
|
+
ss.coefficient_of_localization(base) # Hoover, per sector
|
|
66
|
+
ss.lq_method(base).multiplier # economic base multiplier, LQ method
|
|
67
|
+
ss.minimum_requirements(base).multiplier # Ullman & Dacey
|
|
68
|
+
ss.flq(base[0], base.sum(axis=0), delta=0.3) # FLQ matrix for region 0
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
With labels:
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
t = ss.read_table("employment_2015.csv") # wide: region,Agri,Manuf,... or long
|
|
75
|
+
t.label(ss.location_quotient(t), "lq") # [{"region":..., "sector":..., "lq":...}]
|
|
76
|
+
ss.profile(t) # LQs, specialisation, localisation, multipliers
|
|
77
|
+
ss.decompose(t, ss.read_table("employment_2023.csv"), "esteban-marquillas")
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
National totals default to the column sums of the matrix (the regions make up the
|
|
81
|
+
nation). When the regions are only part of the nation, pass the national sector totals as
|
|
82
|
+
`reference=` (structure measures) or `national_base=` / `national_end=` (shift-share).
|
|
83
|
+
|
|
84
|
+
## Features
|
|
85
|
+
|
|
86
|
+
| Area | Functions |
|
|
87
|
+
| --- | --- |
|
|
88
|
+
| Location quotients | `location_quotient`, `cross_industry_lq`, `flegg_lambda`, `flq`, `aflq`, `regionalize` |
|
|
89
|
+
| Shift-share | `classic`, `esteban_marquillas`, `arcelus`, `dynamic`, `growth_rates` |
|
|
90
|
+
| Specialisation | `krugman_index`, `krugman_pairwise`, `coefficient_of_specialization`, `herfindahl`, `sector_shares` |
|
|
91
|
+
| Localisation | `coefficient_of_localization`, `localization_curve` |
|
|
92
|
+
| Agglomeration | `ellison_glaeser`, `coagglomeration`, `raw_concentration`, `plant_herfindahl` |
|
|
93
|
+
| Economic base | `assumption_method`, `lq_method`, `minimum_requirements`, `base_multiplier` |
|
|
94
|
+
| Tables and I/O | `EmploymentTable`, `read_table`, `read_vector`, `write_csv`, `write_json`, `profile`, `decompose`, `decompose_dynamic` |
|
|
95
|
+
|
|
96
|
+
## Methods and sources
|
|
97
|
+
|
|
98
|
+
Notation: `e[r,i]` employment of sector `i` in region `r`, `e[r]` regional total, `E[i]`
|
|
99
|
+
national sector total, `E` national total; `0` base year, `1` end year; `G = E1/E0 - 1`,
|
|
100
|
+
`G[i] = E1[i]/E0[i] - 1`, `g[r] = e1[r]/e0[r] - 1`, `g[r,i] = e1[r,i]/e0[r,i] - 1`.
|
|
101
|
+
|
|
102
|
+
| Measure | Definition | Source |
|
|
103
|
+
| --- | --- | --- |
|
|
104
|
+
| SLQ | `(e[r,i]/e[r]) / (E[i]/E)` | Isard (1960); Miller & Blair (2009) |
|
|
105
|
+
| CILQ | `SLQ[i] / SLQ[j]` (supplying `i`, purchasing `j`) | Miller & Blair (2009) |
|
|
106
|
+
| FLQ | `lambda* CILQ[i,j]`, diagonal `lambda* SLQ[i]`, `lambda* = [log2(1 + RE/NE)]^delta`, `0 <= delta < 1` | Flegg, Webber & Elliott (1995) |
|
|
107
|
+
| AFLQ | `FLQ[i,j] log2(1 + SLQ[j])` where `SLQ[j] > 1` | Flegg & Webber (2000) |
|
|
108
|
+
| Regionalisation | `r[i,j] = a[i,j] min(LQ, 1)` | Miller & Blair (2009) |
|
|
109
|
+
| Classic shift-share | `NS = e0 G`, `IM = e0 (G[i] - G)`, `RS = e0 (g[r,i] - G[i])` | Dunn (1960) |
|
|
110
|
+
| 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) |
|
|
111
|
+
| 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) |
|
|
112
|
+
| Dynamic shift-share | classic model on each consecutive pair of years, summed | Barff & Knight (1988) |
|
|
113
|
+
| Krugman index | `sum_i |s[r,i] - s_ref[i]|`, 0 to 2 | Krugman (1991) |
|
|
114
|
+
| Coefficient of specialisation | `0.5 sum_i |e[r,i]/e[r] - E[i]/E|` | Hoover (1936); Isard (1960) |
|
|
115
|
+
| Coefficient of localisation | `0.5 sum_r |e[r,i]/E[i] - e[r]/E|` | Hoover (1936) |
|
|
116
|
+
| 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) |
|
|
117
|
+
| Herfindahl | `sum_i s[r,i]^2` | Hirschman (1964) |
|
|
118
|
+
| 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) |
|
|
119
|
+
| 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) |
|
|
120
|
+
| LQ basic employment | `max(e[r,i] - e[r] E[i]/E, 0)` | Isard (1960); Tiebout (1962) |
|
|
121
|
+
| Minimum requirements | `max(e[r,i] - m[i] e[r], 0)`, `m[i]` the smallest share among comparable regions | Ullman & Dacey (1960) |
|
|
122
|
+
| Base multiplier | `total / basic` | Tiebout (1962) |
|
|
123
|
+
|
|
124
|
+
Conventions and choices:
|
|
125
|
+
|
|
126
|
+
- Every shift-share decomposition adds up exactly to `e1 - e0` for every cell. Cells with
|
|
127
|
+
zero base employment have no growth rate; their change is booked as regional shift
|
|
128
|
+
(classic), as competitive effect with zero allocation (Esteban-Marquillas, flagged in
|
|
129
|
+
`undefined`), or in the regional industry-mix term (Arcelus).
|
|
130
|
+
- No calibration constants are built in. Flegg's `delta`, the plant Herfindahl for the
|
|
131
|
+
Ellison-Glaeser index, assumption-method basic sectors or fractions, and the comparable
|
|
132
|
+
region set and rank for minimum requirements are all supplied by the user.
|
|
133
|
+
|
|
134
|
+
References:
|
|
135
|
+
|
|
136
|
+
- Arcelus, F.J. (1984) An extension of shift-share analysis. *Growth and Change* 15(1), 3-8.
|
|
137
|
+
- Barff, R.A. and Knight, P.L. (1988) Dynamic shift-share analysis. *Growth and Change* 19(2), 1-10.
|
|
138
|
+
- Dunn, E.S. (1960) A statistical and analytical technique for regional analysis. *Papers and Proceedings of the Regional Science Association* 6, 97-112.
|
|
139
|
+
- 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.
|
|
140
|
+
- Esteban-Marquillas, J.M. (1972) A reinterpretation of shift-share analysis. *Regional and Urban Economics* 2(3), 249-255.
|
|
141
|
+
- 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.
|
|
142
|
+
- Flegg, A.T. and Webber, C.D. (2000) Regional size, regional specialization and the FLQ formula. *Regional Studies* 34(6), 563-569.
|
|
143
|
+
- Hirschman, A.O. (1964) The paternity of an index. *American Economic Review* 54(5), 761-762.
|
|
144
|
+
- Hoover, E.M. (1936) The measurement of industrial localization. *Review of Economics and Statistics* 18(4), 162-171.
|
|
145
|
+
- Isard, W. (1960) *Methods of Regional Analysis: An Introduction to Regional Science*. MIT Press.
|
|
146
|
+
- Krugman, P. (1991) *Geography and Trade*. MIT Press.
|
|
147
|
+
- Miller, R.E. and Blair, P.D. (2009) *Input-Output Analysis: Foundations and Extensions*, 2nd ed. Cambridge University Press.
|
|
148
|
+
- Tiebout, C.M. (1962) *The Community Economic Base Study*. Committee for Economic Development.
|
|
149
|
+
- 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.
|
|
150
|
+
|
|
151
|
+
## Command line
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
shiftshare profile employment_2015.csv --csv lq.csv -o profile.json
|
|
155
|
+
shiftshare decompose employment_2015.csv employment_2023.csv --method esteban-marquillas \
|
|
156
|
+
--national-base nation_2015.csv --national-end nation_2023.csv --csv components.csv
|
|
157
|
+
shiftshare dynamic emp_2019.csv emp_2020.csv emp_2021.csv emp_2022.csv
|
|
158
|
+
shiftshare base employment_2023.csv --method mr --csv basic.csv
|
|
159
|
+
shiftshare base employment_2023.csv --method assumption --basic-sectors Manufacturing,Mining
|
|
160
|
+
shiftshare flq employment_2023.csv --region Coast --delta 0.3 --coefficients national_A.csv
|
|
161
|
+
shiftshare eg plants_by_region.csv --herfindahl plant_herfindahl.csv
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Tables are CSV (wide: first column region, one column per sector; or long: `region`,
|
|
165
|
+
`sector`, `employment`/`value` columns; `,`, `;` or tab separated) or JSON. Sector vectors
|
|
166
|
+
(national totals, Herfindahl values) are CSV `sector,value` rows or a JSON object. Results
|
|
167
|
+
are printed as JSON or written with `-o`; `--csv` writes the detailed table.
|
|
168
|
+
|
|
169
|
+
## Citation
|
|
170
|
+
|
|
171
|
+
If you use `shiftshare` in your work, please cite it (see `CITATION.cff`):
|
|
172
|
+
|
|
173
|
+
```bibtex
|
|
174
|
+
@software{eminoglu_shiftshare,
|
|
175
|
+
author = {Eminoğlu, Yusuf},
|
|
176
|
+
title = {shiftshare: regional economic analysis on region x sector employment tables},
|
|
177
|
+
version = {0.1.0},
|
|
178
|
+
year = {2026},
|
|
179
|
+
url = {https://gitlab.com/geophilo1/shiftshare_sdk}
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
and the original sources of the methods you use.
|
|
184
|
+
|
|
185
|
+
## License
|
|
186
|
+
|
|
187
|
+
MIT. See `LICENSE`.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"""shiftshare quickstart on a small made-up economy (no input files needed).
|
|
2
|
+
|
|
3
|
+
Run: python examples/quickstart.py
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import numpy as np
|
|
9
|
+
|
|
10
|
+
import shiftshare as ss
|
|
11
|
+
|
|
12
|
+
SECTORS = ["Agriculture", "Manufacturing", "Trade", "Services"]
|
|
13
|
+
REGIONS = ["Coast", "Valley", "Uplands"]
|
|
14
|
+
|
|
15
|
+
# Employment (jobs) by region x sector in the base and end years.
|
|
16
|
+
BASE = np.array(
|
|
17
|
+
[
|
|
18
|
+
[1200, 5400, 3100, 8300],
|
|
19
|
+
[4100, 2600, 1900, 3400],
|
|
20
|
+
[2900, 900, 800, 1500],
|
|
21
|
+
],
|
|
22
|
+
dtype=float,
|
|
23
|
+
)
|
|
24
|
+
END = np.array(
|
|
25
|
+
[
|
|
26
|
+
[1100, 6200, 3500, 9800],
|
|
27
|
+
[3700, 2700, 2100, 3900],
|
|
28
|
+
[2500, 1000, 900, 1700],
|
|
29
|
+
],
|
|
30
|
+
dtype=float,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def main() -> None:
|
|
35
|
+
t0 = ss.EmploymentTable(BASE, REGIONS, SECTORS)
|
|
36
|
+
|
|
37
|
+
print("Location quotients (base year)")
|
|
38
|
+
lq = ss.location_quotient(t0)
|
|
39
|
+
for r, row in zip(REGIONS, lq):
|
|
40
|
+
print(f" {r:8s} " + " ".join(f"{v:5.2f}" for v in row))
|
|
41
|
+
|
|
42
|
+
print("\nClassic shift-share (Dunn 1960), regional totals")
|
|
43
|
+
res = ss.classic(BASE, END)
|
|
44
|
+
tot = res.region_totals()
|
|
45
|
+
for k, r in enumerate(REGIONS):
|
|
46
|
+
print(
|
|
47
|
+
f" {r:8s} change {tot['change'][k]:7.0f} = NS {tot['national_share'][k]:7.1f}"
|
|
48
|
+
f" + IM {tot['industry_mix'][k]:7.1f} + RS {tot['regional_shift'][k]:7.1f}"
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
em = ss.esteban_marquillas(BASE, END)
|
|
52
|
+
print("\nEsteban-Marquillas allocation effect by region:", em.allocation.sum(axis=1).round(1))
|
|
53
|
+
|
|
54
|
+
print("\nSpecialisation and economic base")
|
|
55
|
+
k = ss.krugman_index(BASE, versus="rest")
|
|
56
|
+
mult = ss.lq_method(BASE).multiplier
|
|
57
|
+
mr = ss.minimum_requirements(BASE).multiplier
|
|
58
|
+
for i, r in enumerate(REGIONS):
|
|
59
|
+
print(f" {r:8s} Krugman {k[i]:.3f} base multiplier LQ {mult[i]:.2f} MR {mr[i]:.2f}")
|
|
60
|
+
|
|
61
|
+
print("\nHoover coefficient of localisation by sector")
|
|
62
|
+
for s, v in zip(SECTORS, ss.coefficient_of_localization(BASE)):
|
|
63
|
+
print(f" {s:13s} {v:.3f}")
|
|
64
|
+
|
|
65
|
+
# FLQ for the Coast region with a user-chosen delta (no default is built in).
|
|
66
|
+
q = ss.flq(BASE[0], BASE.sum(axis=0), delta=0.3)
|
|
67
|
+
print("\nFLQ (Coast, delta = 0.3), diagonal:", np.diag(q).round(3))
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
if __name__ == "__main__":
|
|
71
|
+
main()
|