Skip to main content

Revealed Comparative Advantage Calculator

PyPI - Version DOI

This is the repository associated with the manuscript Competitiveness analysis to identify marginal suppliers in consequential LCA: A seaweed case.

The repository is designed as a Python library to help users calculate Revealed Comparative Advantage (RCA) using BACI trade data.

📖 Background Knowledge

BACI Dataset

The BACI (from CEPII) dataset offers detailed information on bilateral trade flows for 200 countries, broken down by product (covering 5,000 products). The data spans various time periods, ranging from 2 to 28 years, depending on the specific dataset. Each year's data is stored in a separate CSV file. Each file contains six columns: t = year, i = exporter, j = importer, k = product, v = value, and q = quantity, and comprises over one million rows of data.

This library can calculate RCA for both quantity (metric tons) and value (thousand USD).

Revealed Comparative Advantage (RCA)

In international economics, the RCA is a metric that evaluating the relative advantage or disadvantage of a certain country in a certain class of goods or services as evidenced by trade flows. It is based on the Ricardian comparative advantage concept. WIKI

Formula

$RCA^i_j = \left( \frac{X^i_j}{X^i_n} \middle/ \frac{X^w_j}{X^w_n} \right)$ Where:

  • $X^i_j$: Export value of commodity i from a country to country j.
  • $X^i_n$: Total export value of commodity i from all exporting countries to country j.
  • $X^w_j$: Total export value of all commodities from a country to country j.
  • $X^w_n$: Total export value of all commodities from all exporting to country j.
  • $RCA^i_j$: Comparative advantage of commodity i of a country in country j.

Reference:
Competitiveness of Indonesian Non-Human Consumption Seaweed in the China Market.pdf

✨ Features

(applicable to all BACI dataset versions)

  1. Get the data for specific products from the BACI dataset.
  2. Calculate RCA in batches.
  3. Convert country codes into country names.

👩‍💻 Quick Start

Requirements

  • This project was developed using Python 3.12.9.

Option 1. Install via pip

  1. Open your local terminal.
    (For windows, search for "Terminal/Prompt/PowerShell"; for macOS, search for "Terminal")

  2. Install the library.

    pip install rca_batch_calc
    
  3. Follow the instructions in Example to use the library.

Option 2. Clone and run from GitHub

  1. Open your local terminal.
    (For windows, search for "Terminal/Prompt/PowerShell"; for macOS, search for "Terminal")
  2. Clone this repository into your local computer
git clone https://github.com/Annedrew/Revealed-Comparative-Advantage-Calculator.git
  1. Navigate into the project folder:
cd Revealed-Comparative-Advantage-Calculator
  1. Install dependencies:
pip install pandas
  1. Follow the instructions in Example to use the library.

💬 Contact

If you encounter any issues or would like to contribute to the library, please contact:

Funding

Ravalnath Shikhare’s contribution is funded by the FunSea Project (Horizon Europe BlueBio Partnership, grant number 3157-00016B). Ning An’s contribution is funded by the ALIGNED project (Horizon Europe, grant number 101059430). Massimo Pizzol’s contribution is funded by both FunSea and ALIGNED.

Acknowledgements

The work was partially supported by DeiC National HPC (g.a. DeiC-AAU-L1-402401).

Conflict of Interest statement

The authors declare no conflict of interest.

Metadata

Release files for rca-batch-calc 0.1.6

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

Source distribution (sdist)

Source distribution for rca-batch-calc 0.1.6
File Size Uploaded Provenance
rca_batch_calc-0.1.6.tar.gz 9.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for rca-batch-calc 0.1.6
File Interpreter ABI Platform
rca_batch_calc-0.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 19.1 kB

Release files / rca_batch_calc-0.1.6.tar.gz

Download URL rca_batch_calc-0.1.6.tar.gz
Size 9.9 kB
Tags Source
SHA-256 checksum
How to use checksums
6b215961e23d00a8994361fcdf196f131533538cf8626cf402d0907c869ae6e7
BLAKE2b-256 checksum
How to use checksums
93beaa81af4ac10a42727a2ec479d51fe6373f3b3a29cb2c7fdca393b27f75d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / rca_batch_calc-0.1.6-py3-none-any.whl

Download URL rca_batch_calc-0.1.6-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aa3564a00bffea767eaae23cec749c1107682c8d0153f31b0d5671abb5e36978
BLAKE2b-256 checksum
How to use checksums
3a86ecbff5dc80f918ab7bb7f5e0b4f68b4e19f4c6ef7293c4ba4252079edb06
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Security for rca-batch-calc 0.1.6

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.

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