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 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.1.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.1-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: abrsqol-1.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 7cfd28613865adb9472180252c0ab1a713f9aae0659b69497535f63ddabf0478
MD5 03be725dd8a344b43930134426825b1a
BLAKE2b-256 5a6e28d562fe68b2f152ce3ebd3288d20db2bb9d15d7085c772a31c6ff6271de

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ABRSQOL-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 14.1 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 98b7846293078659d952c30ab5afdf5a7703b9caccb4b26c7d433ad8b7e1aee0
MD5 bd551c419179662a5a841832a7e71f2e
BLAKE2b-256 f5a9b5eefcf70637ffe6b9d2887452956e0f218184e5631f2285fc4a504e7500

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