# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: 'Python 3.9.7 64-bit (''ussrbmi'': conda)'
#     name: python3
# ---

# # Basic Controls for Sex
# This section of the notebook is dedicated to:
# 1. Cleaning the data. 
# 2. Examining the mismatch in years between corruption and BMI data
# 3. Constructing a basic control for the proportion of men and women in leadership.

# +
# imports & function declarations
import pandas as pd
import statsmodels.api as sm
import numpy as np
import matplotlib.pyplot as plt

def regress(dep: pd.Series, indep):
    '''Wrapper for statsmodels regression. Takes in a dependent variable and one or more independent ones'''
    return sm.OLS(
        dep, sm.add_constant(
            indep)
    ).fit()
    

def simple_scatter(x: pd.Series, y: pd.Series, xlabel='', ylabel='', title='', regression_line=True):
    '''Wrapper for matplotlib scatter plot'''
    fig, ax = plt.subplots()
    ax.scatter(x, y)
    ax.set_ylabel(ylabel)
    ax.set_xlabel(xlabel)
    ax.set_title(title)
    if regression_line:
        m, b = np.polyfit(x, y, 1)
        ax.plot(x, m*x+b, color='orange')
        
    countries = x.index.values
    plt.show()
    

def annotate_scatter(x:pd.Series, y:pd.Series, annot: dict, x_adjust=0, y_adjust=0, xlabel='', ylabel='', title=''):
    '''Wrapper for matplotlib scatter plot but with annotations'''
    fig, ax = plt.subplots()
    ax.scatter(x, y)
    ax.set_ylabel(ylabel)
    ax.set_xlabel(xlabel)
    ax.set_title(title)
    m, b = np.polyfit(x, y, 1)
    ax.plot(x, m*x+b, color='orange')
    for i, txt in enumerate(x):
        ax.annotate(annot[i], (x[i] + x_adjust, y[i] + y_adjust))
    plt.show()
    

def regress_filtered(col: str):
    '''Regresses BMI on one measure of corruption (col)'''
    index = corruption[col]
    missing_filter = index.notna()
    filtered_bmi = bmis[missing_filter]['median_bmi']
    filtered_index = index[missing_filter]
    return regress(filtered_index, filtered_bmi).summary()


def plot_filtered(col: str, ylabel: str):
    '''Plots BMI against one measure of corruption (col)'''
    index = corruption[col]
    missing_filter = index.notna()
    filtered_bmi = bmis[missing_filter]['median_bmi']
    filtered_index = index[missing_filter]
    simple_scatter(filtered_bmi, filtered_index,
                   'Median estmated ministers\' body-mass index',
                   ylabel)
    

ABBREVIATIONS = {
    'Estonia': 'EST',
    'Lithuania': 'LTU',
    'Latvia': 'LVA',
    'Georgia': 'GEO',
    'Armenia': 'ARM',
    'Russia': 'RUS',
    'Moldova': 'MDA',
    'Belarus': 'BLR',
    'Kyrgyzstan': 'KGZ',
    'Azerbaijan': 'AZE',
    'Tajikistan': 'TJK',
    'Kazakhstan': 'KAZ',
    'Ukraine': 'UKR',
    'Turkmenistan': 'TKM',
    'Uzbekistan': 'UZB'
}

def abbrviate_countries(arr):
    '''Transforms an array of countries into their abbreviated forms'''
    return [ABBREVIATIONS[name] for name in arr]



# +
# import minister age and sex data

ministers = pd.read_csv('./ministers.csv', encoding="utf-16")
ministers.head()


# +
# clean minister age and sex data and find sex ratios
def filter_sex(sex: str) -> pd.Series:
    '''Filters out ministers by sex'''
    only_sex = ministers[ministers['sex'] == sex]
    return only_sex.groupby('country').count()['sex']
    
only_men = filter_sex('M')
only_women = filter_sex('F')

# calculate sex ratio and add to dataframe
sex_ratio = pd.DataFrame({'men': only_men, 'women': only_women}).fillna(0)
sex_ratio['women'] = sex_ratio['women'].astype(int)
sex_ratio['total'] = sex_ratio['men'] + sex_ratio['women']

sex_ratio['ratio'] = sex_ratio['men'] / sex_ratio['total']
sex_ratio.columns

# +
# import and clean WHO BMI data
bmi = pd.read_csv('./WHO-BMI.csv', encoding="utf-8", index_col=0)

def clean_bmi(row: pd.Series) -> pd.Series:
    '''Cleans up and numberfies the numerical strings in a row. e.g. "26.5 [26.0-27.1]" to 26.5'''
    replaced = row.str.replace(r' \[\d{1,2}.?\d{1,2}-\d{1,2}.?\d{1,2}]', '', regex=True)
    return replaced.astype(float)


for r in bmi.columns:
    bmi[r] = clean_bmi(bmi[r])
    
# bmi data is easier to deal with reversed
bmi = bmi.iloc[:, ::-1]

# gets only first columns i.e. 2017 data
bmi_2017 = bmi[['2016Both sexes', '2016Male', '2016Female']]
bmi_2017.head(15)

# -

# ## Graphing BMIs over time
# There was some concern in the review process that using slightly out of date BMI data would be a problem for my results. The corruption data is all from 2017, while the latest WHO BMI data is from 2016. However, these charts illustrate two things.
# 1. BMI is on a steady, and within the past few years, comparable upswing
# 2. BMI increases very slowly over time, so 2016's values are likely to be very similar to 2017's.

# +
# graph male and female BMIs over time
male_cols = [el for el in bmi.columns if "Male" in el]
female_cols = [el for el in bmi.columns if "Female" in el]
both_cols = [el for el in bmi.columns if "Both" in el]

def strip_to_year(col):
    return col[:4]

male_bmi_time = bmi.loc[:,male_cols].rename(strip_to_year, axis=1).T
female_bmi_time = bmi.loc[:, female_cols].rename(
    strip_to_year, axis=1).T
m_plot = male_bmi_time.plot(legend=False)
m_plot.legend(bbox_to_anchor=(0, -0.15, 1, 0), loc=2,
                 ncol=2, mode="expand", borderaxespad=0)
m_plot.set_xlabel('Year')
m_plot.set_ylabel('Mean Male BMI (WHO)')

f_plot = female_bmi_time.plot(legend=False)
f_plot.legend(bbox_to_anchor=(0, -0.15, 1, 0), loc=2,
              ncol=2, mode="expand", borderaxespad=0)
f_plot.set_xlabel('Year')
f_plot.set_ylabel('Mean Female BMI (WHO)')

# -

# merge bmi data and minister data
bmi_with_ministers = pd.merge(
    sex_ratio, bmi_2017, left_index=True, right_on='Country')
bmi_with_ministers = bmi_with_ministers.rename({'men': 'men_in_gov', 'women': 'women_in_gov', 'total': 'minister_count', 'ratio': 'minister_sex_ratio', 'Country': 'country', '2016Both sexes': 'both_sexes_bmi', '2016Male': 'male_bmi', '2016Female': 'female_bmi'}, axis = 1)
bmi_with_ministers.head(15)

# +
# puts median minister data (taken from Blavatskyy's paper) into dataframe with minister and BMI data
median_ministers = {
    'Estonia': 28.7,
    'Lithuania': 30.3,
    'Latvia': 30.7,
    'Georgia': 30.9,
    'Armenia': 32.1,
    'Russia': 32.5,
    'Moldova': 32.7,
    'Belarus': 32.9,
    'Kyrgyzstan': 33.3,
    'Azerbaijan': 33.3,
    'Tajikistan': 33.6,
    'Kazakhstan': 33.8,
    'Ukraine': 34.4,
    'Turkmenistan': 34.7,
    'Uzbekistan': 35.5
}

bmi_with_ministers['median_minister_bmi'] = bmi_with_ministers.index.map(median_ministers)
bmi_with_ministers.head(15)


# +
# creates sex-adjusted BMI by weighing the proportion of men and women in leadership
men_ratio = bmi_with_ministers['minister_sex_ratio']
women_ratio = 1 - men_ratio
men_bmi = bmi_with_ministers['male_bmi']
women_bmi = bmi_with_ministers['female_bmi']
total_num = bmi_with_ministers['minister_count']
adjusted_bmi = ((men_ratio * men_bmi) + (women_ratio * women_bmi))
bmi_with_ministers['adjusted_bmi'] = adjusted_bmi

bmi_with_ministers.head(15)

# +
# regresses adjusted BMI on minister BMI
adjusted_minister_country_relation = regress(adjusted_bmi, bmi_with_ministers['median_minister_bmi'])

adjusted_minister_country_relation.summary()


# +
# regresses unadjusted country BMI on minister BMI
unadjusted_minister_country_relation = regress(
    bmi_with_ministers['both_sexes_bmi'],
    bmi_with_ministers['median_minister_bmi']
    )

unadjusted_minister_country_relation.summary()


# +
# plots adjusted and unadjusted BMI on minister BMI

simple_scatter(
    bmi_with_ministers['median_minister_bmi'], 
    adjusted_bmi, 
    'Median Estimated Ministers\' BMI', 
    'Sex-Adjusted Country BMI', 
    'Sex-Adjusted BMI and Median Minister BMI'
    )

simple_scatter(
    bmi_with_ministers['median_minister_bmi'],
    bmi_with_ministers['both_sexes_bmi'],
    'Median Estimated Ministers\' BMI',
    'WHO Mean BMI 2016',
    'Unadjusted BMI and Minister BMI'
    )

# -

# finds difference between mean male and female BMIs in each country
bmi_diff = bmi_with_ministers['male_bmi'] - bmi_with_ministers['female_bmi']
print(bmi_diff.mean())
print(bmi_diff)

# # Basic Controls for Age
# This section is dedicated to controlling the data for the age of the ministers

# +
# finds mean and median age of ministers in each country
# too many Tajik ministers missing ages to use country's data
ministers_age = ministers[ministers['country'] != 'Tajikistan']
ministers_age = ministers_age[ministers_age['age'].notna()]
grouped_ministers_age = ministers_age.groupby('country')
mean_age = grouped_ministers_age['age'].mean()
median_age = grouped_ministers_age['age'].median()

print(mean_age, median_age)

# +
# creates dataframe of age data

# from UN World Population Prospects 2015
ages_2015 = {
    'Azerbaijan': 33.8,
    'Armenia': 30.3,
    'Georgia': 37.7,
    'Kazakhstan': 29.4,
    'Kyrgyzstan': 25.1,
    # 'Tajikistan': 22.0,
    'Turkmenistan': 25.6,
    'Uzbekistan': 26.2,
    'Belarus': 39.5,
    'Moldova': 35.6,
    'Russia': 38.6,
    'Ukraine': 40.0,
    'Estonia': 41.6,
    'Latvia': 42.6,
    'Lithuania': 42.7,
}

country_ages = pd.Series(ages_2015)
age_data = pd.concat([country_ages, mean_age, median_age], axis=1)
age_data.set_axis(['mean_country_age', 'mean_minister_age', 'median_minister_age'], axis=1, inplace=True)
age_data

# +
# compare politicians BMI and ages
med_minister_bmi = bmi_with_ministers.drop('Tajikistan')
print(med_minister_bmi.median_minister_bmi)
print(age_data.mean_minister_age)

annotate_scatter(
    med_minister_bmi.median_minister_bmi,
    age_data.mean_minister_age,
    abbrviate_countries(age_data['mean_minister_age'].index.values),
    0.1, 0.1, 'Median Estimated Minister BMI', 'Mean Minister Age'
    )

# -

regress(age_data['mean_minister_age'].sort_index(), med_minister_bmi.median_minister_bmi.sort_index()).summary()

# regresses mean minister age on mean country age
mean_age_relationship = regress(age_data['mean_minister_age'], age_data['mean_country_age'])
mean_age_relationship.summary()

# makes scatter plot of minister age and mean country age
annotate_scatter(age_data['mean_minister_age'], 
                 age_data['mean_country_age'],
                 abbrviate_countries(age_data['mean_country_age'].index.values),
                 0.1,0.1,
                 'Mean Minister Age', 'UN Mean Country Age', 'Mean Age of Ministers and Citizens')


corruption = pd.read_csv('corruption.csv').set_index('country')
corruption.drop('Tajikistan', inplace=True)
corruption

annotate_scatter(age_data['mean_minister_age'],
                 corruption['corruption perception index'],
                 abbrviate_countries(age_data['mean_country_age'].index.values),
                 0.25,0.25,
                 'Mean Minister Age', 'Corruption Perception Index', 'Mean Age of Ministers and Citizens')


annotate_scatter(age_data['mean_minister_age'],
                 corruption['control_of_corruption'],
                 abbrviate_countries(age_data['mean_country_age'].index.values),
                 0.1,0.01,
                 'Mean Minister Age', 'Control of Corruption', 'Mean Age of Ministers and Citizens')


annotate_scatter(age_data['mean_minister_age'],
                 corruption['IDEA absence of corruption'],
                 abbrviate_countries(
                     age_data['mean_country_age'].index.values),
                 0.1, 0.01,
                 'Mean Minister Age', 'IDEA Absence of Corruption', 'Mean Age of Ministers and Citizens')


regress(corruption['corruption perception index'].sort_index(),
        age_data['mean_minister_age'].sort_index()).summary()


regress(
    corruption['control_of_corruption'].sort_index(), 
    age_data['mean_minister_age'].sort_index()
    ).summary()


regress(
    corruption['IDEA absence of corruption'].sort_index(),
    age_data['mean_minister_age'].sort_index()
).summary()


# # Reproducibility
# This section is dedicated to reproducing Blavatskyy's results with his method

# +
# get BMI of each minister -- commented out because it takes forever to run
# from bmipredictor import BMIPredictor
# bmi_predictor = BMIPredictor()
# # this is a test prediction
# # bmi_predictor.predict(
# #     'http://npg.si.edu/sites/default/files/blog_obama_martin_schoeller.jpg')

# estimated_bmi = ministers['image'].apply(lambda img : bmi_predictor.predict('./2017-images/' + img))
# estimated_bmi.head(20)

# # save BMI to CSV so we don't need to do ML over and over
# ministers['estimated_bmi'] = estimated_bmi
# ministers.to_csv('ministers2.csv')


# +
estimated_ministers = pd.read_csv('ministers2.csv')
# remove buggy extra index col
estimated_ministers = estimated_ministers[['name', 'age', 'sex', 'country', 'image', 'estimated_bmi']]
median_bmi = estimated_ministers[['country', 'estimated_bmi']].groupby('country').median().rename({'estimated_bmi': 'median_bmi'}, axis=1)
mean_bmis = estimated_ministers[['country', 'estimated_bmi']].groupby('country').mean().rename({'estimated_bmi': 'mean_bmi'}, axis=1)

bmis = pd.concat([median_bmi, mean_bmis], axis = 1)
bmis['reported_median_bmis'] = pd.Series(median_ministers)

bmis[['median_bmi', 'mean_bmi', 'reported_median_bmis']].sort_values('reported_median_bmis').round(1)
# -

corruption = pd.read_csv('corruption.csv').set_index('country')
corruption

regress_filtered('control_of_corruption')

plot_filtered('control_of_corruption', 'World Bank Control of Corruption')

regress_filtered('corruption perception index')

plot_filtered('corruption perception index', ylabel='Transparency International Corruption Perception Index')

regress_filtered('basel anti money laundering')

plot_filtered('basel anti money laundering', ylabel='Basel Anti Money Laundering Index')

regress_filtered('IDEA absence of corruption')

plot_filtered('IDEA absence of corruption', 'IDEA Absence of Corruption Index')


regress_filtered('Index of public integrity')

plot_filtered('Index of public integrity', 'Index of Public Integrity')

# # Test for difference between women in gov and not

# +
# bmi_with_ministers
mean_f_minister_bmi = estimated_ministers[ministers.sex == 'F'].groupby('country').mean().estimated_bmi
mean_f_bmi = bmi['2016Female']
mean_f_bmi.drop('Azerbaijan', inplace=True) # Azerbaijan has no female ministers

mean_f_bmi.index = mean_f_minister_bmi.index
f_bmi_comparison = pd.concat([mean_f_minister_bmi, bmi['2016Female']], axis=1, sort=True)
f_bmi_comparison

# -

# # Building Standardized BMI

# +
# get data from (non-comitted) .sav files from the Health in Times of Transition 2010 survey
# takes a while to run
hitt1 = pd.read_spss('./Data/EAB_2_26 10 14.sav')

hitt1_country_abbr = hitt1['COUNTRIES']
hitt1_sex = hitt1['V010']
hitt1_age = hitt1['V011']
hitt1_height = hitt1['V024']
hitt1_weight = hitt1['V025']

hitt1_trimmed = pd.concat([
    hitt1_country_abbr,
    hitt1_sex,
    hitt1_age,
    pd.to_numeric(hitt1_height),
    pd.to_numeric(hitt1_weight),
], axis=1)

hitt1_trimmed.rename(columns={
    'COUNTRIES': 'country',
    'V010': 'sex',
    'V011': 'age',
    'V024': 'height',
    'V025': 'weight'
}, inplace=True)

# formula from https://www.cdc.gov/nccdphp/dnpao/growthcharts/training/bmiage/page5_1.html
hitt1_trimmed['bmi'] = (
    (hitt1_trimmed['weight'] / (hitt1_trimmed['height']**2)) * 10000).round(1)
hitt1_trimmed.drop(['height', 'weight'], axis=1, inplace=True)

abbrv_transform = {
    'MD': 'Moldova',
    'BY': 'Belarus',
    'RU': 'Russia',
    'KG': 'Kyrgyzstan',
    'KZ': 'Kazakhstan',
    'UA': 'Ukraine',
    'AM': 'Armenia',
    'GE': 'Georgia',
    'AZ': 'Azerbaijan'
}

hitt1_trimmed['country'] = hitt1_trimmed.replace({'country': abbrv_transform})
hitt1_trimmed.to_csv('./Data/hitt_trimmed.csv')

# -

# uses saved cleaned data from above
hitt = pd.read_csv('./Data/hitt_trimmed.csv')
# remove missing data
print(hitt.shape)
hitt = hitt.dropna()
print(hitt.shape)
hitt.head()

simple_scatter(hitt['age'], hitt['bmi'], 'Age', 'BMI')


# removal of outliers: BMI > 50
hitt = hitt[hitt['bmi'] < 50]
simple_scatter(hitt['age'], hitt['bmi'], 'Age', 'BMI', regression_line=False)


plt.bar(hitt['age'], height=hitt['bmi'])  # density=False would make counts
plt.ylabel('BMI')
plt.xlabel('Age')


# transforms sex into numerical binary variable
hitt['is_female'] = (hitt['sex'] == 'Female').astype(int)
hitt['agesex'] = hitt['is_female'] * hitt['age']
for el in ['bmi','age', 'is_female']:
    print(hitt[el].size)

# first regression: BMI on age and sex
age_sex_X = [hitt['age'], hitt['is_female']]
age_sex_X = sm.add_constant(age_sex_X)
age_sex_regress = sm.OLS.from_formula(formula='bmi ~ age + is_female', data=hitt).fit()
age_sex_regress.summary()


# second regression: BMI on age, sex, and interaction
age_sex_regress2 = sm.OLS.from_formula(
    formula='bmi ~ age + is_female + agesex', data=hitt).fit()
age_sex_regress2.summary()


# +
# prepare minister data for regression estimation
estimated_ministers_wot = estimated_ministers[estimated_ministers['country'] != 'Tajikistan']
print(estimated_ministers_wot.shape)
estimated_ministers_trimmed = estimated_ministers_wot[~np.isnan(estimated_ministers_wot.age)]
estimated_ministers_trimmed = estimated_ministers_trimmed[~np.isnan(estimated_ministers_trimmed.age)]

estimated_ministers_trimmed['is_female'] = (estimated_ministers_trimmed['sex'] == 'F').astype(int)
estimated_ministers_trimmed['agesex'] = estimated_ministers_trimmed['is_female'] * estimated_ministers_trimmed['age']


# +
# first regression on just age and sex

def first_regression(row) -> int:
    age = row.age
    is_female = row.is_female
    return age_sex_regress.params.Intercept + (age_sex_regress.params.age * age) + (age_sex_regress.params.is_female * is_female)


ministers_results = estimated_ministers_trimmed
ministers_results['first_reg'] = ministers_results.apply(
    first_regression, axis=1)

ministers_results


# +
# check results of normalization against corruption measures
first_means = ministers_results.groupby('country').first_reg.mean()
corruption_minus_tajikstan = corruption.drop('Tajikistan')

def first_reg_scatter(measure, ylabel):
    annotate_scatter(
        first_means, 
        corruption_minus_tajikstan[measure], 
        abbrviate_countries(corruption_minus_tajikstan.index), 
        x_adjust=0.01, y_adjust=0.01, 
        xlabel="Mean Controlled Minister BMI (First Regression)", 
        ylabel=ylabel
        )


first_reg_scatter('control_of_corruption', "World Bank Control of Corruption")
first_reg_scatter('corruption perception index',
                  "Corruption Perception Index")
first_reg_scatter('IDEA absence of corruption',
                  "IDEA Absence of Corruption")

bmi_means_2016 = bmi['2016Both sexes'].drop('Tajikistan')

annotate_scatter(
    first_means,
    bmi_means_2016,
    abbrviate_countries(first_means.index),
    0.01, 0.01,
    'Mean Controlled Minister BMI (First Regression)',
    'WHO 2016 Mean BMI'
)

# -

regress(corruption_minus_tajikstan['control_of_corruption'], first_means).summary()

regress(
    corruption_minus_tajikstan['corruption perception index'], first_means).summary()


regress(corruption_minus_tajikstan['IDEA absence of corruption'], first_means).summary()


regress(bmi_means_2016, first_means).summary()


# +
# second regression on age, sex, age^2, age*sex, and age^2*sex
def second_regression(row) -> int:
    return age_sex_regress2.params.Intercept + (age_sex_regress2.params.is_female * row.is_female) + (age_sex_regress2.params.age * row.age) + (age_sex_regress2.params.agesex * row.agesex)

    
ministers_results['second_reg'] = ministers_results.apply(
    second_regression, axis=1)

ministers_results


# +
# graph estimated BMI against regressed BMI
# simple_scatter(ministers_results.estimated_bmi, ministers_results.first_reg, 'Estimated Photographic BMI', 'Controlled BMI (First Regression)', 'Estimated BMI and First Regression Results')
# simple_scatter(ministers_results.estimated_bmi, ministers_results.second_reg, 'Estimated Photographic BMI', 'Controlled BMI (Second Regression)', 'Estimated BMI and Second Regression Results')

fig1, ax1 = plt.subplots()
colors={0: 'blue', 1: 'red'}

ax1.scatter(ministers_results.estimated_bmi, ministers_results.first_reg, c=ministers_results.is_female.map(colors))
ax1.set_xlabel('Estimated Photographic BMI')
ax1.set_ylabel('Controlled BMI (First Regression)')
m1, b1 = np.polyfit(ministers_results.estimated_bmi,
                  ministers_results.first_reg, 1)
ax1.plot(ministers_results.estimated_bmi, m1 *
         ministers_results.estimated_bmi+b1, color='orange')

fig1, ax2 = plt.subplots()

ax2.scatter(ministers_results.estimated_bmi,
            ministers_results.second_reg, c=ministers_results.is_female.map(colors))
m2, b2 = np.polyfit(ministers_results.estimated_bmi,
                  ministers_results.second_reg, 1)
ax2.plot(ministers_results.estimated_bmi, m2 *
         ministers_results.estimated_bmi+b2, color='orange')
ax2.set_xlabel('Estimated Photographic BMI')
ax2.set_ylabel('Controlled BMI (Second Regression)')


# +
second_means = ministers_results.groupby('country').second_reg.mean()
corruption_minus_tajikstan = corruption.drop('Tajikistan')


def second_reg_scatter(measure, ylabel):
    annotate_scatter(
        second_means,
        corruption_minus_tajikstan[measure],
        abbrviate_countries(corruption_minus_tajikstan.index),
        x_adjust=0.01, y_adjust=0.01,
        xlabel="Mean Controlled Minister BMI (Second Regression)",
        ylabel=ylabel
    )


second_reg_scatter('control_of_corruption', "World Bank Control of Corruption")
second_reg_scatter('corruption perception index',
                  "Corruption Perception Index")
second_reg_scatter('IDEA absence of corruption',
                  "IDEA Absence of Corruption")

bmi_means_2016 = bmi['2016Both sexes'].drop('Tajikistan')

annotate_scatter(
    second_means,
    bmi_means_2016,
    abbrviate_countries(first_means.index),
    0.01, 0.01,
    'Mean Controlled Minister BMI (Second Regression)',
    'WHO 2016 Mean BMI'
)

# -

regress(
    corruption_minus_tajikstan['control_of_corruption'], second_means).summary()


regress(
    corruption_minus_tajikstan['corruption perception index'], second_means).summary()


regress(
    corruption_minus_tajikstan['IDEA absence of corruption'], second_means).summary()


regress(bmi_means_2016, second_means).summary()


StarcoderdataJupyterScriptsDedupFiltered