コード例 #1
0
def test_comparison():

    population_dataframe = create_testing_population_dataframe(year_start=2001,
                                                               year_end=2261,
                                                               population=2)
    profiles_dataframe = create_constant_profiles_dataframe(
        population_dataframe, tax=1)

    r = 0.00
    g = 0.00
    n = 0.00

    simulation = Simulation()
    simulation.population = population_dataframe
    simulation.population_alt = population_dataframe

    simulation.profiles = profiles_dataframe

    net_gov_wealth = -10
    net_gov_spending = 0
    taxes_list = ['tax']
    payments_list = ['sub']

    simulation.set_population_projection(year_length=simulation.year_length,
                                         method="exp_growth")
    simulation.set_tax_projection(method="per_capita", rate=g)
    simulation.set_growth_rate(g)
    simulation.set_discount_rate(r)
    simulation.set_population_growth_rate(n)
    simulation.set_gov_wealth(net_gov_wealth)
    simulation.set_gov_spendings(net_gov_spending, default=True)
    simulation.create_cohorts()
    simulation.create_present_values(typ='tax')

    simulation.cohorts_alt = simulation.cohorts

    simulation.cohorts_alt.loc[
        [x == 2102 for x in simulation.cohorts_alt.index.get_level_values(2)],
        'tax'] = (-100)
    simulation.create_present_values(typ='tax', default=False)

    ipl_base = simulation.compute_ipl(typ='tax')
    ipl_alt = simulation.compute_ipl(typ='tax', default=False, precision=False)

    #Saving the decomposed ipl:
    to_save = simulation.break_down_ipl(typ='tax', default=False, threshold=60)

    #     to_save = age_class_pv
    xls = "C:/Users/Utilisateur/Documents/GitHub/ga/src/countries/france/sources/Carole_Bonnet/choc_test_alt.xlsx"

    to_save.to_excel(xls, 'ipl')
    print ipl_base
    print ipl_alt
    assert ipl_base == -105232
コード例 #2
0
def test_comparison():
    
    population_dataframe = create_testing_population_dataframe(year_start=2001, year_end=2261, population=2)
    profiles_dataframe = create_constant_profiles_dataframe(population_dataframe, tax=1)
    
    r = 0.00
    g = 0.00
    n = 0.00
    
    simulation = Simulation()    
    simulation.population = population_dataframe
    simulation.population_alt = population_dataframe
    
    simulation.profiles = profiles_dataframe
    
    net_gov_wealth = -10
    net_gov_spending = 0
    taxes_list = ['tax']
    payments_list = ['sub']
    
    simulation.set_population_projection(year_length=simulation.year_length, method="exp_growth")
    simulation.set_tax_projection(method="per_capita", rate=g)
    simulation.set_growth_rate(g)
    simulation.set_discount_rate(r)
    simulation.set_population_growth_rate(n)
    simulation.set_gov_wealth(net_gov_wealth)
    simulation.set_gov_spendings(net_gov_spending, default=True)
    simulation.create_cohorts()
    simulation.create_present_values(typ='tax')
    
    simulation.cohorts_alt = simulation.cohorts
    
    simulation.cohorts_alt.loc[[x==2102 for x in simulation.cohorts_alt.index.get_level_values(2)], 'tax'] = (-100)
    simulation.create_present_values(typ='tax', default=False)
    
    ipl_base = simulation.compute_ipl(typ='tax')
    ipl_alt = simulation.compute_ipl(typ='tax', default=False, precision=False)
    
    #Saving the decomposed ipl:
    to_save = simulation.break_down_ipl(typ='tax', default=False, threshold=60)
       
#     to_save = age_class_pv
    xls = os.path.join(SRC_PATH, 'test_comparison.xlsx')

    to_save.to_excel(xls, 'ipl')
    print ipl_base
    print ipl_alt
    assert ipl_base == -105232
コード例 #3
0
def test_comparison():
    
    print 'Entering the comparison function'
    
    simulation = Simulation()
    population_scenario_alt = "projpop0760_FECbasESPbasMIGbas"
    population_scenario = "projpop0760_FECbasESPbasMIGbas"
    simulation.load_population(population_filename, population_scenario)
    simulation.load_population(population_filename, population_scenario_alt, default=False)
    
    # Adding missing population data between 1996 and 2007 :
    store_pop = HDFStore(os.path.join(SRC_PATH, 'countries', country, 'sources',
                                           'Carole_Bonnet', 'pop_1996_2006.h5'))
    corrected_pop = store_pop['population']
    simulation.population = concat([corrected_pop, simulation.population])
    simulation.population_alt = concat([corrected_pop.iloc[0:101, :], corrected_pop.iloc[1111:1212,:]]) #concat([corrected_pop, simulation.population_alt])
    
    #Loading profiles :
    simulation.load_profiles(profiles_filename)
    
    year_length = 250
    simulation.set_year_length(nb_year=year_length)
    """
    Default Hypothesis set : 
    actualization rate r = 3%
    growth rate g = 1%
    net_gov_wealth = -3217.7e+09 (unit : Franc Français (FRF) of 1996)
    non ventilated government spendings in 1996 : 1094e+09 FRF
    """

    r = 0.03
    g = 0.01
    n = 0.00
    pi = 0.01
    net_gov_wealth = -3217.7e+09
    year_gov_spending = (1094)*1e+09
    taxes_list = ['tva', 'tipp', 'cot', 'irpp', 'impot', 'property']
    payments_list = ['chomage', 'retraite', 'revsoc', 'maladie', 'educ']
    
    simulation.set_population_projection(year_length=simulation.year_length, method="exp_growth")
    simulation.set_tax_projection(method="desynchronized", rate=g, inflation_rate=pi, typ=taxes_list, payments_list=payments_list)
    simulation.set_growth_rate(g)
    simulation.set_discount_rate(r) 
    simulation.set_population_growth_rate(n)
    simulation.create_cohorts()
    simulation.set_gov_wealth(net_gov_wealth)
    simulation.set_gov_spendings(year_gov_spending, default=True, compute=True)


    simulation.cohorts.compute_net_transfers(name = 'net_transfers', taxes_list = taxes_list, payments_list = payments_list)
    simulation.create_present_values('net_transfers', default=True)
    
    """
    Alternate Hypothesis set : 
    actualization rate r = 3%
    growth rate g = 1%
    net_gov_wealth = -3217.7e+09 (unit : Franc Français (FRF) of 1996)
    non ventilated government spendings in 1996 : 1094e+09 FRF
    """

    r_alt = 0.03
    g_alt = 0.01
    n_alt = 0.00
    pi_alt = 0.01
    net_gov_wealth_alt = -3217.7e+09
    year_gov_spending_alt = (1094)*1e+09

    simulation.set_tax_projection(method="desynchronized", rate=g_alt, inflation_rate=pi_alt, typ=taxes_list, payments_list=payments_list)
    simulation.set_growth_rate(g_alt, default=False)
    simulation.set_discount_rate(r_alt, default=False) 
    simulation.set_population_growth_rate(n_alt, default=False)
    simulation.create_cohorts(default=False)
    simulation.set_gov_wealth(net_gov_wealth_alt, default=False)
    simulation.set_gov_spendings(year_gov_spending_alt, default=False, compute=True)
    
    #simulation.cohorts_alt.loc[(0,0,2014):, 'cot'] *= (1+0.1)
    simulation.cohorts_alt.compute_net_transfers(name = 'net_transfers', taxes_list = taxes_list, payments_list = payments_list)
    simulation.create_present_values('net_transfers', default=False)


    #Creating age classes
    cohorts_age_class = simulation.create_age_class(typ = 'net_transfers', step = 5)
    cohorts_age_class._types = [u'tva', u'tipp', u'cot', u'irpp', u'impot', u'property', u'chomage', u'retraite', u'revsoc', u'maladie', u'educ', u'net_transfers']
    age_class_pv_fe = cohorts_age_class.xs((1, 1996), level = ['sex', 'year'])
    
    cohorts_age_class_alt = simulation.create_age_class(typ = 'net_transfers', step = 5, default=False)
    cohorts_age_class_alt._types = [u'tva', u'tipp', u'cot', u'irpp', u'impot', u'property', u'chomage', u'retraite', u'revsoc', u'maladie', u'educ', u'net_transfers']
    age_class_pv_fe_alt = cohorts_age_class_alt.xs((1, 1996), level = ['sex', 'year'])
    
    print "AGE CLASS PV"
    print age_class_pv_fe.head(20)
    print age_class_pv_fe_alt.head(20)
    
    # Calculating the Intertemporal Public Liability
    ipl = simulation.compute_ipl(typ = 'net_transfers')
    ipl_alt = simulation.compute_ipl(typ = 'net_transfers', default = False)


    print "------------------------------------"
    print "IPL par défaut =", ipl
    print "IPL alternatif =", ipl_alt
    print "share of the GDP : ", ipl/8050.6e+09*100, "%"
    print "-alternative share-", ipl_alt/8050.6e+09*100, "%"
    print "------------------------------------"
    
    print "INTERNAL CHECKS :"
    print simulation.net_gov_spendings, simulation.net_gov_spendings_alt
    print simulation.net_gov_wealth, simulation.net_gov_wealth_alt
    
    
    #Plotting
    age_class_pv = cohorts_age_class.xs(1996, level = "year").unstack(level="sex")
    age_class_pv = age_class_pv['net_transfers']
    age_class_pv.columns = ['men' , 'women']
        
    age_class_pv_alt = cohorts_age_class_alt.xs(1996, level = "year").unstack(level="sex")
    age_class_pv_alt = age_class_pv_alt['net_transfers']
    age_class_pv_alt.columns = ['men_alt' , 'women_alt']
    
    age_class_pv['men_alt'] = age_class_pv_alt['men_alt'] ; age_class_pv['women_alt'] = age_class_pv_alt['women_alt']
    age_class_pv.plot(style = '--') ; plt.legend()
#     age_class_pv_alt.plot(style = '--') ; plt.legend()
    plt.axhline(linewidth=2, color='black')
    plt.show()

#     #Plotting profiles :
#     profiles_to_plot = simulation.cohorts.xs(90, level = "age").unstack(level="sex")
#     profiles_to_plot = profiles_to_plot['net_transfers']
#     profiles_to_plot.columns = ['men' , 'women']
#       
#     profiles_to_plot_alt = simulation.cohorts_alt.xs(90, level = "age").unstack(level="sex")
#     profiles_to_plot_alt = profiles_to_plot_alt['net_transfers']
#     profiles_to_plot_alt.columns = ['men_alt' , 'women_alt']
#   
#     profiles_to_plot['men_alt'] = profiles_to_plot_alt['men_alt'] ; profiles_to_plot['women_alt'] = profiles_to_plot_alt['women_alt']
#     profiles_to_plot.plot(style = '--') ; plt.legend()
# #     age_class_pv_alt.plot(style = '--') ; plt.legend()
#     plt.axhline(linewidth=2, color='black')
    
#     cohorts_age_class.xs(2020, level = "year").unstack(level="sex").plot(subplots=True)
#     plt.show()

    #Saving the decomposed ipl:
    to_save = simulation.break_down_ipl(typ='net_transfers', default=False, threshold=60)
       
#     to_save = age_class_pv
    xls = "C:/Users/Utilisateur/Documents/GitHub/ga/src/countries/france/sources/Carole_Bonnet/stationnaire_alt.xlsx"
         
    to_save.to_excel(xls, 'ipl')