Comments (5)
Ah, this issue is much simpler than I expected. I didn't notice earlier, but you're using 2-digit SITC codes. The calculations for ECI in the Atlas are based on 4-digit SITC codes. This explains most of the discrepancy that you're seeing. Any remaining differences are due to the fact that on the Atlas, we restrict the set of countries to ones with reliable data for ECI calculations. Learn more about Atlas data here
Closing as not an issue.
from py-ecomplexity.
I did mention earlier that there would be some remaining differences. Atlas data uses a set of processes that clean the trade data based on bilateral reporting, and restrict the set of countries used for ECI calculations. More here. If you have specific questions about the Atlas data itself, I would suggest that you request help from the Atlas team here.
from py-ecomplexity.
Thanks for bringing this to our attention. We'll look into this.
Here is code to reproduce the issue:
import pandas as pd
import numpy as np
import seaborn as sns
from ecomplexity import ecomplexity
# Import trade data from CID Atlas
data_url = "https://intl-atlas-downloads.s3.amazonaws.com/country_sitcproduct2digit_year.csv.zip"
data = pd.read_csv(data_url, compression="zip", low_memory=False)
data.head()
# Calculate eci's
data = data[['year','location_code','sitc_product_code','export_value','sitc_eci']]
data = data[data.year==data.year.max()]
trade_cols = {'time':'year', 'loc':'location_code', 'prod':'sitc_product_code', 'val':'export_value'}
cdata = ecomplexity(data, trade_cols)
cdata = cdata[['location_code','eci','sitc_eci']].drop_duplicates(['location_code'])
# Compare against Atlas
sns.scatterplot('sitc_eci','eci', data=cdata)
from py-ecomplexity.
@shreyasgm
Thank you for your generous and quick reply. I have just tried the 4-digit SITC dataset using your python script as follows.
import pandas as pd
import numpy as np
import seaborn as sns
from ecomplexity import ecomplexity
# Import trade data from CID Atlas
data = pd.read_csv('../data/country_partner_sitcproduct4digit_year_2017.zip', compression="zip", low_memory=False)
data.head()
# Calculate eci's
data = data[['year','location_code','sitc_product_code','export_value','sitc_eci']]
data = data[data.year==data.year.max()]
trade_cols = {'time':'year', 'loc':'location_code', 'prod':'sitc_product_code', 'val':'export_value'}
cdata = ecomplexity(data, trade_cols)
cdata = cdata[['location_code','eci','sitc_eci']].drop_duplicates(['location_code'])
# Compare against Atlas
# To download gdp data from wordbank
# https://data.worldbank.org/indicator/ny.gdp.pcap.cd?most_recent_year_desc=true
df_gdp = pd.read_csv('./GDP/API_NY.GDP.PCAP.CD_DS2_en_csv_v2_41089.csv', sep = '\t')
year =2017
df_g = df_gdp[['Country Code', str(year)]]
gdp_dict =dict(zip(df_g['Country Code'],df_g[str(year)]))
cdata['gdp'] = [gdp_dict[name] if name in gdp_dict else 0.0 for name in cdata['location_code']]
# Compare against Atlas
df = cdata[cdata['gdp'] >0]
sns.scatterplot('eci','gdp', data=df, label = 'eci computed with ecomplexity')
sns.scatterplot('sitc_eci','gdp', data=df, label = 'sitc_eci given by Hidalgo')
plt.yscale('log')
plt.legend()
plt.xlabel('ECI', fontsize = 15)
plt.ylabel('GDP', fontsize = 15)
plt.title('2017');
I think this problem has been largely solved following your suggestion. Thank you for your comments.
from py-ecomplexity.
@shreyasgm Thank you for your kindly reply. I have benefited a lot from your insightful and comprehensive answers which have well addressed my question. The idea of ECI is very inspiring and it could be applied to many other areas. Thanks again for your maintaining of this wonderful Python package. Best regards. C.J.
from py-ecomplexity.
Related Issues (20)
- Improve performance using numba HOT 1
- this has an R version here HOT 4
- Explicitly specify "name" in MultiIndex.from_product HOT 1
- Help with the subnational data HOT 1
- Is COG equal to OG? HOT 1
- RCA calculation HOT 2
- PCI calculation. HOT 3
- I got confusing ranking results from the sample code HOT 4
- ecomplexity output does not conform with atlas dataverse results using R reticulate HOT 5
- RPOP - Handling zeros in diversity / ubiquity HOT 2
- Possible mistake in the code of ecomplexity.py HOT 2
- PCI normalization using wrong mean and standard deviation. HOT 3
- Implement knn for density calculations
- Add log-supermodularity checks and warnings if non-conformant HOT 1
- Allow for custom proximity matrix HOT 1
- Install problem and some question HOT 1
- Fail to install HOT 1
- Using knn option gives integer density outputs HOT 1
- Handle column label conflicts
- name 'ecomplexity' is not defined HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from py-ecomplexity.