Skip to main content

Numerical solution algorithm to invert a quality of life measure.

Project description

ABRSQOL

About

This toolkit implements a numerical solution algorithm to invert a quality of life (QoL) from observed data in various programming languages. The QoL measure is based on Ahlfeldt, Bald, Roth, Seidel (2024): Measuring quality of life under spatial frictions. Unlike the traditional Rosen-Roback measure, this measure accounts for mobility frictions—generated by idiosyncratic tastes and local ties—and trade frictions—generated by trade costs and non-tradable services, thereby reducing non-classical measurement error.

Notice that quality of life is identified up to a constant. Therefore, the inverted QoL measures measure has a relative interpretation only. We normalize the QoL relative to the first observation in the data set. It is straightforward to rescale the QoL measure to any other location or any other value (such as the mean or median in the distribution of QoL across locations).

When using this toolkit in your work, please cite Gabriel M. Ahlfeldt, Fabian Bald, Duncan Roth, Tobias Seidel (forthcoming): Measuring quality of life under spatial frictions

Installation

To install the Python package of the ABRSQOL-toolkit from github, run the following command in your python environment, run the following command in you anaconda shell.

pip install "git+https://git@github.com/Ahlfeldt/ABRSQOL-toolkit.git#subdirectory=Python&egg=ABRSQOL"

In case an error occurs at the installation (error: metadata-generation-failed), it is likely caused by incompatabile versions of setuptools and packaging. This can be fixed by upgrading packaging to compatible versions:

pip install --upgrade setuptools>=74.1.1
pip install --upgrade packaging>=22.0

Or by downgrading setuptools:

pip install --upgrade setuptools==70.0.0

Notice that you must also install 'git' available at https://git-scm.com/ for the installation to work.

You may then load it by running:

import ABRSQOL

Examples

Example 1: load testdata, run QoL inversion with default parameters, store result as 'QoL' variable, view result

testdata = ABRSQOL.testdata
testdata['QoL'] = ABRSQOL.invert_quality_of_life(df=testdata)
testdata.head()

Example 2: load your data from csv, run inversion, save result as csv

my_dataframe = read.csv("path/to/your/csv_filename.csv")
my_dataframe['quality_of_life'] = ABRSQOL.invert_quality_of_life(
  # supply your dataset as a dataframe
  df=my_dataframe,
  # specify the corresponding variable name for your dataset
  w = 'wage',
  p_H = 'floor_space_price',
  P_t = 'tradable_goods_price',
  p_n = 'local_services_price',
  L = 'residence_pop',
  L_b = 'L_b',
  # freely adjust remaining parameters
  alpha = 0.7,
  beta = 0.5,
  gamma = 3,
  xi = 5.5,
  conv = 0.3,
  tolerance = 1e-11,
  maxiter = 50000
)
# Write output to target folder (just replace the path)
from pandas import write_csv
write_csv(my_dataframe, 'C:/FOLDER/my_data_with_qol.csv')

Example 3: Reference variables in your dataset by using the column index

my_dataframe['QoL'] = ABRSQOL.invert_quality_of_life(
  df=my_dataframe,
  w = 1,
  p_H = 3,
  P_t = 4,
  p_n = 2,
  L = 6,
  L_b = 5
)

Example 4: Having named the variables in your data according to the default parameters, you can omit specifying variable names

my_dataframe['QoL'] = ABRSQOL.invert_quality_of_life(
  df=my_dataframe,
  alpha = 0.7,
  beta = 0.5,
  gamma = 3,
  xi = 5.5,
  conv = 0.5
)

Ready-to-use script

If you are new to Python, you may find it useful to execute the Example.py (or Example.ipynb) script saved in this folder. It will install the package, load the testing data set, generate a quality-of-life index, and save it to your working directory. It should be straightforward to adapt the script to your data and preferred parameter values.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

abrsqol-1.0.0.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ABRSQOL-1.0.0-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file abrsqol-1.0.0.tar.gz.

File metadata

  • Download URL: abrsqol-1.0.0.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for abrsqol-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e5c4cc71d3886e11af97683d04227eda0c6f1c482ab8b934d4ee7c87549d21e7
MD5 3c9d540a6d4722f116dfdf33591419ac
BLAKE2b-256 6f60e6fe8e6fe2bc25c24c52bff089d78a3361e5529e5ae44d6b8e461afee6fb

See more details on using hashes here.

File details

Details for the file ABRSQOL-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: ABRSQOL-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 13.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for ABRSQOL-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 68bcf8bdf0d28448c8aa294c5a2b1da6c0f5ca46615e02ad6f9af8e2ae819db0
MD5 2d128c9903abfa11fcefa0c503058391
BLAKE2b-256 14f05541ebfab3fd14208d41e4288e67337143270f975331caf26fce242c0b2c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page