Beta Convergence Of Economic Growth-Evidence from 1990-2014
Setup
# Load computational modules
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import plotly.express as px
import plotly.graph_objects as go
import statsmodels.api as sm
import statsmodels.formula.api as smf
Import data
df = pd.read_csv('/work/data/dat.csv')
df
data_definitions = pd.read_csv('/work/data/dat-definitions.csv')
data_definitions
Transform data
df1 = df[['country', 'year', 'region', 'hi1990', 'isocode','log_GDPpc']]
df1
dfw = df1.pivot_table(
index=['country','region','hi1990','isocode'],
columns='year',
values='log_GDPpc').reset_index(drop=False)
# Make sure the column names are strings
dfw.columns = dfw.columns.astype(str)
dfw
dfw['growth']=dfw['2014']-dfw['1990']
dfw
Describe data
df1.describe().round(2)
dfw.describe().round(2)
Data Visualization
px.line(df1, x='year', y='log_GDPpc', color='country', facet_col= 'region')
px.line(df1, x='year', y='log_GDPpc', color='country', facet_col= 'hi1990')
px.choropleth(
df1,
locations="isocode",
color="log_GDPpc",
hover_name="country",
animation_frame="year",
color_continuous_scale='RdBu_r',
projection="natural earth")
px.choropleth(
dfw,
locations="isocode",
color="growth",
hover_name="country",
color_continuous_scale='RdBu_r',
projection="natural earth")
px.box(
df1,
x="log_GDPpc",
color="hi1990",
hover_name= 'country',
animation_frame = 'year'
)
px.box(
df1,
x="log_GDPpc",
color="region",
hover_name= 'country',
animation_frame = 'year'
)
px.box(
dfw,
x="growth",
color="region",
hover_name= 'country'
)
Regression analysis
px.scatter(
dfw,
x='1990',
y='growth',
color="hi1990",
hover_name="country",
trendline="ols")
px.scatter(
dfw,
x='1990',
y='growth',
color="region",
hover_name="country",
trendline="ols")