Ejemplo n.º 1
0
def test_run_small():
    from ogusa.scripts.execute import runner
    # Monkey patch enforcement flag since small data won't pass checks
    SS.ENFORCE_SOLUTION_CHECKS = False
    TPI.ENFORCE_SOLUTION_CHECKS = False
    output_base = "./OUTPUT"
    input_dir = "./OUTPUT"
    user_params = {'frisch': 0.41, 'debt_ratio_ss': 0.4}
    runner(output_base=output_base,
           baseline_dir=input_dir,
           test=True,
           time_path=False,
           baseline=True,
           user_params=user_params,
           run_micro=False,
           small_open=False,
           budget_balance=False)
    runner(output_base=output_base,
           baseline_dir=input_dir,
           test=True,
           time_path=True,
           baseline=True,
           user_params=user_params,
           run_micro=False,
           small_open=False,
           budget_balance=False)
Ejemplo n.º 2
0
def run_micro_macro(reform, user_params, guid):

    start_time = time.time()

    REFORM_DIR = "./OUTPUT_REFORM_" + guid
    BASELINE_DIR = "./OUTPUT_BASELINE_" + guid

    # Add start year from reform to user parameters
    if isinstance(reform, tuple):
        start_year = sorted(reform[0].keys())[0]
    else:
        start_year = sorted(reform.keys())[0]
    user_params['start_year'] = start_year

    with open("log_{}.log".format(guid), 'w') as f:
        f.write("guid: {}\n".format(guid))
        f.write("reform: {}\n".format(reform))
        f.write("user_params: {}\n".format(user_params))

    '''
    ------------------------------------------------------------------------
        Run baseline
    ------------------------------------------------------------------------
    '''
    output_base = BASELINE_DIR
    kwargs={'output_base':output_base, 'baseline_dir':BASELINE_DIR,
            'test':False, 'time_path':True, 'baseline':True,
            'analytical_mtrs':False, 'age_specific':False,
            'user_params':user_params,'guid':guid,
            'run_micro':True, 'small_open': False, 'budget_balance':False, 'baseline_spending':False}
    #p2 = Process(target=runner, kwargs=kwargs)
    #p2.start()
    runner(**kwargs)

    '''
    ------------------------------------------------------------------------
        Run reform
    ------------------------------------------------------------------------
    '''

    output_base = REFORM_DIR
    kwargs={'output_base':output_base, 'baseline_dir':BASELINE_DIR,
            'test':False, 'time_path':True, 'baseline':False,
            'analytical_mtrs':False, 'age_specific':False,
            'user_params':user_params,'guid':guid,
            'run_micro':True, 'small_open': False, 'budget_balance':False, 'baseline_spending':False}
    #p1 = Process(target=runner, kwargs=kwargs)
    #p1.start()
    runner(**kwargs)

    #p1.join()
    #p2.join()

    time.sleep(0.5)
    ans = postprocess.create_diff(baseline_dir=BASELINE_DIR, policy_dir=REFORM_DIR)
    print "total time was ", (time.time() - start_time)

    return ans
Ejemplo n.º 3
0
def test_run_small():
    from ogusa.scripts.execute import runner
    # Monkey patch enforcement flag since small data won't pass checks
    SS.ENFORCE_SOLUTION_CHECKS = False
    TPI.ENFORCE_SOLUTION_CHECKS = False
    output_base = "./OUTPUT"
    input_dir = "./OUTPUT"
    user_params = {'frisch':0.41, 'debt_ratio_ss':0.4}
    runner(output_base=output_base, baseline_dir=input_dir, test=True, time_path=False, baseline=True, user_params=user_params, run_micro=False, small_open=False, budget_balance=False)
    runner(output_base=output_base, baseline_dir=input_dir, test=True, time_path=True, baseline=True, user_params=user_params, run_micro=False, small_open=False, budget_balance=False)
Ejemplo n.º 4
0
def run_micro_macro(user_params, reform=None, baseline_dir=BASELINE_DIR,
                    reform_dir=REFORM_DIR, guid='', data=PUF_PATH,
                    ok_to_run_baseline=True):

    start_time = time.time()

    T_shifts = np.zeros(50)
    T_shifts[2:10] = 0.01
    T_shifts[10:40]= -0.01
    G_shifts = np.zeros(6)
    G_shifts[0:3]  = -0.01
    G_shifts[3:6]  = -0.005
    user_params = {'frisch':0.41, 'start_year':2017, 'debt_ratio_ss':1.0, 'T_shifts':T_shifts, 'G_shifts':G_shifts}

    '''
    ------------------------------------------------------------------------
        Run baseline
    ------------------------------------------------------------------------
    '''
    print('path exists', not os.path.exists(baseline_dir), ok_to_run_baseline)
    if not os.path.exists(baseline_dir) and ok_to_run_baseline:
        output_base = baseline_dir
        input_dir = baseline_dir
        kwargs={'output_base':baseline_dir, 'baseline_dir':baseline_dir,
                'test':False, 'time_path':True, 'baseline':True,
                'analytical_mtrs':False, 'age_specific':True,
                'user_params':user_params,'guid':'baseline',
                'run_micro':True, 'small_open': False, 'budget_balance':False,
                'baseline_spending':False, 'data': data}
        #p1 = Process(target=runner, kwargs=kwargs)
        #p1.start()
        runner(**kwargs)


    '''
    ------------------------------------------------------------------------
        Run reform
    ------------------------------------------------------------------------
    '''
    output_base = reform_dir
    input_dir = reform_dir
    kwargs={'output_base':output_base, 'baseline_dir':baseline_dir,
            'test':False, 'time_path':True, 'baseline':False,
            'analytical_mtrs':False, 'age_specific':True,
            'user_params':user_params,'guid':guid, 'reform':reform ,
            'run_micro':True, 'small_open': False, 'budget_balance':False,
            'baseline_spending':False, 'data': data}
    runner(**kwargs)

    ans = postprocess.create_diff(baseline_dir=baseline_dir, policy_dir=reform_dir)

    print "total time was ", (time.time() - start_time)
    print 'Percentage changes in aggregates:', ans
Ejemplo n.º 5
0
def run_micro_macro(user_params, reform=None, baseline_dir=BASELINE_DIR,
                    reform_dir=REFORM_DIR, guid='', data=PUF_PATH,
                    ok_to_run_baseline=True):

    start_time = time.time()

    T_shifts = np.zeros(50)
    T_shifts[2:10] = 0.01
    T_shifts[10:40]= -0.01
    G_shifts = np.zeros(6)
    G_shifts[0:3]  = -0.01
    G_shifts[3:6]  = -0.005
    user_params = {'frisch':0.41, 'start_year':2017, 'debt_ratio_ss':1.0, 'T_shifts':T_shifts, 'G_shifts':G_shifts}

    '''
    ------------------------------------------------------------------------
        Run baseline
    ------------------------------------------------------------------------
    '''
    print('path exists', not os.path.exists(baseline_dir), ok_to_run_baseline)
    if not os.path.exists(baseline_dir) and ok_to_run_baseline:
        output_base = baseline_dir
        input_dir = baseline_dir
        kwargs={'output_base':baseline_dir, 'baseline_dir':baseline_dir,
                'test':False, 'time_path':True, 'baseline':True,
                'analytical_mtrs':False, 'age_specific':True,
                'user_params':user_params,'guid':'baseline',
                'run_micro':True, 'small_open': False, 'budget_balance':False,
                'baseline_spending':False, 'data': data}
        #p1 = Process(target=runner, kwargs=kwargs)
        #p1.start()
        runner(**kwargs)


    '''
    ------------------------------------------------------------------------
        Run reform
    ------------------------------------------------------------------------
    '''
    output_base = reform_dir
    input_dir = reform_dir
    kwargs={'output_base':output_base, 'baseline_dir':baseline_dir,
            'test':False, 'time_path':True, 'baseline':False,
            'analytical_mtrs':False, 'age_specific':True,
            'user_params':user_params,'guid':guid, 'reform':reform ,
            'run_micro':True, 'small_open': False, 'budget_balance':False,
            'baseline_spending':False, 'data': data}
    runner(**kwargs)

    ans = postprocess.create_diff(baseline_dir=baseline_dir, policy_dir=reform_dir)

    print "total time was ", (time.time() - start_time)
    print 'Percentage changes in aggregates:', ans
Ejemplo n.º 6
0
def run_micro_macro(reform, user_params, guid):

    guid = ''
    start_time = time.time()

    REFORM_DIR = "./OUTPUT_REFORM_" + guid
    BASELINE_DIR = "./OUTPUT_BASELINE_" + guid

    # Add start year from reform to user parameters
    start_year = sorted(reform.keys())[0]
    user_params['start_year'] = start_year

    with open("log_{}.log".format(guid), 'w') as f:
        f.write("guid: {}\n".format(guid))
        f.write("reform: {}\n".format(reform))
        f.write("user_params: {}\n".format(user_params))


    '''
    ------------------------------------------------------------------------
        Run baseline
    ------------------------------------------------------------------------
    '''
    output_base = BASELINE_DIR
    kwargs={'output_base':output_base, 'baseline_dir':BASELINE_DIR, 'test':True,
            'time_path':True, 'baseline':True, 'analytical_mtrs':False,
            'user_params':user_params, 'age_specific':False, 'run_micro':False,
            'guid':guid}
    runner(**kwargs)

    '''
    ------------------------------------------------------------------------
        Run reform
    ------------------------------------------------------------------------
    '''

    output_base = REFORM_DIR
    kwargs={'output_base':output_base, 'baseline_dir':BASELINE_DIR,
            'test':True, 'time_path':True, 'baseline':False,
            'analytical_mtrs':False, 'reform':reform, 'user_params':user_params,
            'age_specific':False, 'guid': guid, 'run_micro':False}
    runner(**kwargs)

    time.sleep(0.5)
    ans = postprocess.create_diff(baseline_dir=BASELINE_DIR, policy_dir=REFORM_DIR)
    print("total time was ", (time.time() - start_time))

    return ans
Ejemplo n.º 7
0
def test_frisch(frisch):
    from ogusa.scripts.execute import runner
    output_base = os.path.join(CUR_PATH, "OUTPUT")
    input_dir = os.path.join(CUR_PATH, "OUTPUT")
    user_params = {'frisch': frisch, 'debt_ratio_ss': 1.0}
    runner(output_base=output_base,
           baseline_dir=input_dir,
           test=False,
           time_path=False,
           baseline=True,
           age_specific=True,
           user_params=user_params,
           run_micro=False,
           small_open=False,
           budget_balance=False,
           data=PUF_PATH)
Ejemplo n.º 8
0
def run_micro_macro(reform, user_params, guid, solution_checks, run_micro):

    # Turn off checks for now
    SS.ENFORCE_SOLUTION_CHECKS = solution_checks
    TPI.ENFORCE_SOLUTION_CHECKS = solution_checks

    start_time = time.time()

    reform_dir = "./OUTPUT_REFORM" + guid
    baseline_dir = "./OUTPUT_BASELINE" + guid

    # Add start year from reform to user parameters
    start_year = sorted(reform.keys())[0]
    user_params['start_year'] = start_year

    input_dir = baseline_dir

    kwargs={'output_base':baseline_dir, 'baseline_dir':baseline_dir,
            'baseline':True, 'analytical_mtrs':False, 'age_specific':False,
            'user_params':user_params, 'guid':guid, 'run_micro':run_micro}

    #p1 = Process(target=runner, kwargs=kwargs)
    #p1.start()
    runner(**kwargs)

    kwargs={'output_base':reform_dir, 'baseline_dir':baseline_dir,
             'baseline':False, 'analytical_mtrs':False, 'user_params':user_params,
             'reform':reform, 'age_specific':False, 'guid':guid,'run_micro':run_micro}

    #p2 = Process(target=runner, kwargs=kwargs)
    #p2.start()
    runner(**kwargs)

    #p1.join()
    #print("just joined")
    #p2.join()

    #time.sleep(0.5)

    ans = postprocess.create_diff(baseline_dir=baseline_dir, policy_dir=reform_dir)

    print("total time was ", (time.time() - start_time))
    print(ans)

    return ans
Ejemplo n.º 9
0
def run_micro_macro(reform, user_params, guid, solution_checks, run_micro):

    # Turn off checks for now
    SS.ENFORCE_SOLUTION_CHECKS = solution_checks
    TPI.ENFORCE_SOLUTION_CHECKS = solution_checks

    start_time = time.time()

    reform_dir = "./OUTPUT_REFORM" + guid
    baseline_dir = "./OUTPUT_BASELINE" + guid

    # Add start year from reform to user parameters
    start_year = sorted(reform.keys())[0]
    user_params['start_year'] = start_year

    input_dir = baseline_dir

    kwargs={'output_base':baseline_dir, 'baseline_dir':baseline_dir,
            'baseline':True, 'analytical_mtrs':False, 'age_specific':False,
            'user_params':user_params, 'guid':guid, 'run_micro':run_micro}

    #p1 = Process(target=runner, kwargs=kwargs)
    #p1.start()
    runner(**kwargs)

    kwargs={'output_base':reform_dir, 'baseline_dir':baseline_dir,
             'baseline':False, 'analytical_mtrs':False, 'user_params':user_params,
             'reform':reform, 'age_specific':False, 'guid':guid,'run_micro':run_micro}

    #p2 = Process(target=runner, kwargs=kwargs)
    #p2.start()
    runner(**kwargs)

    #p1.join()
    #print("just joined")
    #p2.join()

    #time.sleep(0.5)

    ans = postprocess.create_diff(baseline_dir=baseline_dir, policy_dir=reform_dir)

    print("total time was ", (time.time() - start_time))
    print(ans)

    return ans
Ejemplo n.º 10
0
def test_diff_start_year(year):
    from ogusa.scripts.execute import runner
    # Monkey patch enforcement flag since small data won't pass checks
    SS.ENFORCE_SOLUTION_CHECKS = False
    TPI.ENFORCE_SOLUTION_CHECKS = False
    output_base = os.path.join(CUR_PATH, "STARTYEAR_OUTPUT")
    input_dir = os.path.join(CUR_PATH, "STARTYEAR_OUTPUT")
    user_params = {'frisch': 0.41, 'debt_ratio_ss': 1.0, 'start_year': year}
    runner(output_base=output_base,
           baseline_dir=input_dir,
           test=True,
           time_path=True,
           baseline=True,
           age_specific=False,
           user_params=user_params,
           run_micro=True,
           small_open=False,
           budget_balance=False,
           data=PUF_PATH)
Ejemplo n.º 11
0
'''
A 'smoke test' for the ogusa package. Uses a fake data set to run the
baseline
'''

import cPickle as pickle
import os
import numpy as np
import time

import ogusa
ogusa.parameters.DATASET = 'SMALL'

import ogusa.SS
import ogusa.TPI
from ogusa import parameters, wealth, labor, demographics, income, SS, TPI

from ogusa import txfunc

#txfunc.get_tax_func_estimate(baseline=True)

from ogusa.scripts.execute import runner


if __name__ == "__main__":
    output_base = "./OUTPUT_BASELINE"
    input_dir = "./OUTPUT_BASELINE"
    runner(output_base=output_base, input_dir=input_dir, baseline=True)
Ejemplo n.º 12
0
def run_micro_macro(user_params):
    # Grab a reform JSON file already in Tax-Calculator
    # In this example the 'reform' is a change to 2017 law (the
    # baseline policy is tax law in 2018)
    rec = Records.cps_constructor()
    pol = Policy()
    calc = Calculator(policy=pol, records=rec)
    ref = calc.read_json_param_objects('2017_law.json', None)
    reform = ref['policy']

    # Define parameters to use for multiprocessing
    client = Client(processes=False)
    num_workers = multiprocessing.cpu_count()
    print('Number of workers = ', num_workers)
    start_time = time.time()

    # Set some model parameters
    # See parameters.py for description of these parameters
    T_shifts = np.zeros(50)
    T_shifts[2:10] = 0.01
    T_shifts[10:40] = -0.01
    G_shifts = np.zeros(6)
    G_shifts[0:3] = -0.01
    G_shifts[3:6] = -0.005
    small_open = False
    # small_open = dict(world_int_rate=0.04)
    # Alternatively small_open can be False/None
    # if False/None then 0.04 is used
    user_params = {
        'frisch': 0.41,
        'start_year': 2018,
        'tau_b': (0.21 * 0.55) * (0.017 / 0.055),
        'debt_ratio_ss': 1.0,
        'T_shifts': T_shifts,
        'G_shifts': G_shifts,
        'small_open': small_open
    }
    '''
    ------------------------------------------------------------------------
    Run baseline policy first
    ------------------------------------------------------------------------
    '''
    output_base = BASELINE_DIR
    input_dir = BASELINE_DIR
    kwargs = {
        'output_base': output_base,
        'baseline_dir': BASELINE_DIR,
        'test': False,
        'time_path': True,
        'baseline': True,
        'constant_rates': False,
        'analytical_mtrs': False,
        'age_specific': True,
        'user_params': user_params,
        'guid': '_example',
        'run_micro': True,
        'small_open': small_open,
        'budget_balance': False,
        'baseline_spending': False,
        'data': 'cps',
        'client': client,
        'num_workers': num_workers
    }

    start_time = time.time()
    runner(**kwargs)
    print('run time = ', time.time() - start_time)
    '''
    ------------------------------------------------------------------------
    Run reform policy
    ------------------------------------------------------------------------
    '''
    user_params = {
        'frisch': 0.41,
        'start_year': 2018,
        'tau_b': (0.35 * 0.55) * (0.017 / 0.055),
        'debt_ratio_ss': 1.0,
        'T_shifts': T_shifts,
        'G_shifts': G_shifts,
        'small_open': small_open
    }
    output_base = REFORM_DIR
    input_dir = REFORM_DIR
    guid_iter = 'reform_' + str(0)
    kwargs = {
        'output_base': output_base,
        'baseline_dir': BASELINE_DIR,
        'test': False,
        'time_path': True,
        'baseline': False,
        'constant_rates': False,
        'analytical_mtrs': False,
        'age_specific': True,
        'user_params': user_params,
        'guid': '_example',
        'reform': reform,
        'run_micro': True,
        'small_open': small_open,
        'budget_balance': False,
        'baseline_spending': False,
        'data': 'cps',
        'client': client,
        'num_workers': num_workers
    }

    # return ans - the percentage changes in macro aggregates and prices
    # due to policy changes from the baseline to the reform
    ans = postprocess.create_diff(baseline_dir=BASELINE_DIR,
                                  policy_dir=REFORM_DIR)

    print("total time was ", (time.time() - start_time))
    print('Percentage changes in aggregates:', ans)
Ejemplo n.º 13
0
def run_micro_macro(user_params,
                    reform=None,
                    baseline_dir=BASELINE_DIR,
                    reform_dir=REFORM_DIR,
                    guid='',
                    data=PUF_PATH):

    start_time = time.time()

    T_shifts = np.zeros(50)
    T_shifts[2:10] = 0.01
    T_shifts[10:40] = -0.01
    G_shifts = np.zeros(6)
    G_shifts[0:3] = -0.01
    G_shifts[3:6] = -0.005
    small_open = dict(world_int_rate=0.04)  # Alternatively
    # small_open can be False/None
    # (if False/None then 0.04 is used)
    user_params = {
        'frisch': 0.41,
        'start_year': 2017,
        'tau_b': 0.20,
        'debt_ratio_ss': 1.0,
        'T_shifts': T_shifts,
        'G_shifts': G_shifts,
        'small_open': small_open
    }
    '''
    ------------------------------------------------------------------------
        Run SS for Baseline first - so can run baseline and reform in parallel if want
    ------------------------------------------------------------------------
    '''
    output_base = BASELINE_DIR
    input_dir = BASELINE_DIR
    kwargs = {
        'output_base': output_base,
        'baseline_dir': BASELINE_DIR,
        'test': False,
        'time_path': True,
        'baseline': True,
        'analytical_mtrs': False,
        'age_specific': True,
        'user_params': user_params,
        'guid': '',
        'run_micro': False,
        'small_open': small_open,
        'budget_balance': False,
        'baseline_spending': False
    }
    runner(**kwargs)
    '''
    ------------------------------------------------------------------------
        Run baseline
    ------------------------------------------------------------------------
    '''

    if not os.path.exists(baseline_dir):
        output_base = baseline_dir
        input_dir = baseline_dir
        kwargs = {
            'output_base': output_base,
            'baseline_dir': baseline_dir,
            'test': False,
            'time_path': True,
            'baseline': True,
            'analytical_mtrs': False,
            'age_specific': True,
            'user_params': user_params,
            'guid': 'baseline',
            'run_micro': True,
            'small_open': small_open,
            'budget_balance': False,
            'baseline_spending': False,
            'data': data
        }
        runner(**kwargs)
    '''
    ------------------------------------------------------------------------
        Run reform
    ------------------------------------------------------------------------
    '''
    output_base = reform_dir
    input_dir = reform_dir
    guid_iter = 'reform_' + str(0)
    user_params = {
        'frisch': 0.41,
        'start_year': 2017,
        'tau_b': 0.20,
        'debt_ratio_ss': 1.0,
        'T_shifts': T_shifts,
        'G_shifts': G_shifts,
        'small_open': small_open
    }
    kwargs = {
        'output_base': output_base,
        'baseline_dir': baseline_dir,
        'test': False,
        'time_path': True,
        'baseline': False,
        'analytical_mtrs': False,
        'age_specific': True,
        'user_params': user_params,
        'guid': guid,
        'reform': reform,
        'run_micro': True,
        'small_open': small_open,
        'budget_balance': False,
        'baseline_spending': False,
        'data': data
    }
    runner(**kwargs)

    ans = postprocess.create_diff(baseline_dir=baseline_dir,
                                  policy_dir=reform_dir)

    print "total time was ", (time.time() - start_time)
    print 'Percentage changes in aggregates:', ans
Ejemplo n.º 14
0
def run_ogusa(client,
              num_workers,
              tax_func_type,
              age_specific,
              guid,
              reform,
              user_params={}):
    '''
    Runs OG-USA model - both baseline and reform
    '''
    start_time = time.time()
    '''
    ------------------------------------------------------------------------
    Run Baseline First - this will be 2018 Law
    ------------------------------------------------------------------------
    '''
    output_base = os.path.join(BASELINE_DIR, guid)
    baseline_dir = os.path.join(BASELINE_DIR, guid)
    # Set corporate income tax rate
    user_params['tau_b'] = (0.21 * 0.55) * (0.017 / 0.055)
    kwargs = {
        'output_base': output_base,
        'baseline_dir': baseline_dir,
        'test': False,
        'time_path': True,
        'baseline': True,
        'constant_rates': False,
        'tax_func_type': tax_func_type,
        'analytical_mtrs': False,
        'age_specific': age_specific,
        'user_params': user_params,
        'guid': guid,
        'reform': {},
        'run_micro': True,
        'data': 'puf',
        'small_open': small_open,
        'budget_balance': False,
        'baseline_spending': False,
        'client': client,
        'num_workers': num_workers
    }
    runner(**kwargs)
    '''
    ------------------------------------------------------------------------
    Run Reform Second - this will be 2017 Law
    ------------------------------------------------------------------------
    '''
    output_base = os.path.join(REFORM_DIR, guid)
    # Set corporate income tax rate
    user_params['tau_b'] = (0.35 * 0.55) * (0.017 / 0.055)
    kwargs = {
        'output_base': output_base,
        'baseline_dir': baseline_dir,
        'test': False,
        'time_path': True,
        'baseline': False,
        'constant_rates': False,
        'tax_func_type': tax_func_type,
        'analytical_mtrs': False,
        'age_specific': age_specific,
        'user_params': user_params,
        'guid': guid,
        'reform': reform,
        'run_micro': True,
        'data': 'puf',
        'small_open': small_open,
        'budget_balance': False,
        'baseline_spending': False,
        'client': client,
        'num_workers': num_workers
    }
    runner(**kwargs)
    print('run time = ', time.time() - start_time)
Ejemplo n.º 15
0
def run_micro_macro(user_params):

    # reform = {
    # 2015: {
    #     '_II_rt1': [.09],
    #     '_II_rt2': [.135],
    #     '_II_rt3': [.225],
    #     '_II_rt4': [.252],
    #     '_II_rt5': [.297],
    #     '_II_rt6': [.315],
    #     '_II_rt7': [0.3564],
    # }, }

    # reform = {
    # 2015: {
    #     '_II_rt1': [0.045]
    # }, }

    reform = {2017: {'_II_rt5': [.3], '_II_rt6': [.3], '_II_rt7': [0.3]}}

    start_time = time.time()

    T_shifts = np.zeros(50)
    T_shifts[2:10] = 0.01
    T_shifts[10:40] = -0.01
    G_shifts = np.zeros(6)
    G_shifts[0:3] = -0.01
    G_shifts[3:6] = -0.005
    user_params = {
        'frisch': 0.41,
        'start_year': 2017,
        'debt_ratio_ss': 1.0,
        'T_shifts': T_shifts,
        'G_shifts': G_shifts
    }
    '''
    ------------------------------------------------------------------------
        Run SS for Baseline first - so can run baseline and reform in parallel if want
    ------------------------------------------------------------------------
    '''
    # output_base = BASELINE_DIR
    # input_dir = BASELINE_DIR
    # kwargs={'output_base':output_base, 'baseline_dir':BASELINE_DIR,
    #        'test':False, 'time_path':False, 'baseline':True, 'analytical_mtrs':False, 'age_specific':True,
    #        'user_params':user_params,'guid':'',
    #        'run_micro':False, 'small_open':False, 'budget_balance':False, 'baseline_spending':False}
    # #p1 = Process(target=runner, kwargs=kwargs)
    # #p1.start()
    # runner(**kwargs)
    # # quit()
    '''
    ------------------------------------------------------------------------
        Run baseline
    ------------------------------------------------------------------------
    '''

    output_base = BASELINE_DIR
    input_dir = BASELINE_DIR
    kwargs = {
        'output_base': output_base,
        'baseline_dir': BASELINE_DIR,
        'test': True,
        'time_path': True,
        'baseline': True,
        'analytical_mtrs': False,
        'age_specific': True,
        'user_params': user_params,
        'guid': '',
        'run_micro': False,
        'small_open': False,
        'budget_balance': False,
        'baseline_spending': False
    }
    #p1 = Process(target=runner, kwargs=kwargs)
    #p1.start()
    runner(**kwargs)
    '''
    ------------------------------------------------------------------------
        Run reform
    ------------------------------------------------------------------------
    '''
    output_base = REFORM_DIR
    input_dir = REFORM_DIR
    guid_iter = 'reform_' + str(0)
    kwargs = {
        'output_base': output_base,
        'baseline_dir': BASELINE_DIR,
        'test': True,
        'time_path': True,
        'baseline': False,
        'analytical_mtrs': False,
        'age_specific': True,
        'user_params': user_params,
        'guid': '_alt',
        'reform': reform,
        'run_micro': False,
        'small_open': False,
        'budget_balance': False,
        'baseline_spending': False
    }
    #p2 = Process(target=runner, kwargs=kwargs)
    #p2.start()
    runner(**kwargs)

    #p1.join()
    # print "just joined"
    #p2.join()

    # time.sleep(0.5)

    ans = postprocess.create_diff(baseline_dir=BASELINE_DIR,
                                  policy_dir=REFORM_DIR)

    print("total time was ", (time.time() - start_time))
    print('Percentage changes in aggregates:', ans)
Ejemplo n.º 16
0
def run_micro_macro(user_params):

    # reform = {
    # 2015: {
    #     '_II_rt1': [.09],
    #     '_II_rt2': [.135],
    #     '_II_rt3': [.225],
    #     '_II_rt4': [.252],
    #     '_II_rt5': [.297],
    #     '_II_rt6': [.315],
    #     '_II_rt7': [0.3564],
    # }, }

    # reform = {
    # 2015: {
    #     '_II_rt1': [0.045]
    # }, }

    reform = {
    2017: {
       '_II_rt5': [.3],
       '_II_rt6': [.3],
       '_II_rt7': [0.3],
    }, }


    start_time = time.time()

    T_shifts = np.zeros(50)
    T_shifts[2:10] = 0.01
    T_shifts[10:40]= -0.01
    G_shifts = np.zeros(6)
    G_shifts[0:3]  = -0.01
    G_shifts[3:6]  = -0.005
    user_params = {'frisch':0.41, 'start_year':2017, 'debt_ratio_ss':1.0, 'T_shifts':T_shifts, 'G_shifts':G_shifts}

    '''
    ------------------------------------------------------------------------
        Run SS for Baseline first - so can run baseline and reform in parallel if want
    ------------------------------------------------------------------------
    '''
    # output_base = BASELINE_DIR
    # input_dir = BASELINE_DIR
    # kwargs={'output_base':output_base, 'baseline_dir':BASELINE_DIR,
    #        'test':False, 'time_path':False, 'baseline':True, 'analytical_mtrs':False, 'age_specific':True,
    #        'user_params':user_params,'guid':'',
    #        'run_micro':False, 'small_open':False, 'budget_balance':False, 'baseline_spending':False}
    # #p1 = Process(target=runner, kwargs=kwargs)
    # #p1.start()
    # runner(**kwargs)
    # # quit()


    '''
    ------------------------------------------------------------------------
        Run baseline
    ------------------------------------------------------------------------
    '''


    output_base = BASELINE_DIR
    input_dir = BASELINE_DIR
    kwargs={'output_base':output_base, 'baseline_dir':BASELINE_DIR,
            'test':True, 'time_path':True, 'baseline':True,
            'analytical_mtrs':False, 'age_specific':True,
            'user_params':user_params,'guid':'',
            'run_micro':False, 'small_open': False, 'budget_balance':False, 'baseline_spending':False}
    #p1 = Process(target=runner, kwargs=kwargs)
    #p1.start()
    runner(**kwargs)


    '''
    ------------------------------------------------------------------------
        Run reform
    ------------------------------------------------------------------------
    '''
    output_base = REFORM_DIR
    input_dir = REFORM_DIR
    guid_iter = 'reform_' + str(0)
    kwargs={'output_base':output_base, 'baseline_dir':BASELINE_DIR,
            'test':True, 'time_path':True, 'baseline':False,
            'analytical_mtrs':False, 'age_specific':True,
            'user_params':user_params,'guid':'_alt', 'reform':'' ,
            'run_micro':False, 'small_open': True, 'budget_balance':False,
            'baseline_spending':True}
    #p2 = Process(target=runner, kwargs=kwargs)
    #p2.start()
    runner(**kwargs)







    #p1.join()
    # print "just joined"
    #p2.join()

    # time.sleep(0.5)

    ans = postprocess.create_diff(baseline_dir=BASELINE_DIR, policy_dir=REFORM_DIR)

    print "total time was ", (time.time() - start_time)
    print 'Percentage changes in aggregates:', ans
Ejemplo n.º 17
0
'''
A 'smoke test' for the ogusa package. Uses a fake data set to run the
baseline
'''

import pickle as pickle
import os
import numpy as np
import time

import ogusa
ogusa.parameters.DATASET = 'SMALL'

import ogusa.SS
import ogusa.TPI
from ogusa import parameters, wealth, labor, demographics, income, SS, TPI

from ogusa import txfunc

#txfunc.get_tax_func_estimate(baseline=True)

from ogusa.scripts.execute import runner

if __name__ == "__main__":
    output_base = "./OUTPUT_BASELINE"
    input_dir = "./OUTPUT_BASELINE"
    runner(output_base=output_base, input_dir=input_dir, baseline=True)
Ejemplo n.º 18
0
import ogusa.TPI
from ogusa import parameters, wealth, labor, demographics, income, SS, TPI

from ogusa import txfunc

#txfunc.get_tax_func_estimate(baseline=False)

from ogusa.scripts.execute import runner

if __name__ == "__main__":
    output_base = "./OUTPUT"
    input_dir = "./OUTPUT"

    reform = {
        2015: {
            '_II_rt1': [.09],
            '_II_rt2': [.135],
            '_II_rt3': [.225],
            '_II_rt4': [.252],
            '_II_rt5': [.297],
            '_II_rt6': [.315],
            '_II_rt7': [0.3564],
        },
    }

    runner(output_base=output_base,
           input_dir=input_dir,
           baseline=False,
           reform=reform,
           run_micro=False)
Ejemplo n.º 19
0
import ogusa
ogusa.parameters.DATASET = 'SMALL'

import ogusa.SS
import ogusa.TPI
from ogusa import parameters, wealth, labor, demographics, income, SS, TPI

from ogusa import txfunc

#txfunc.get_tax_func_estimate(baseline=False)

from ogusa.scripts.execute import runner

if __name__ == "__main__":
    output_base = "./OUTPUT"
    input_dir = "./OUTPUT"

    reform = {
                2015: {
                    '_II_rt1': [.09],
                    '_II_rt2': [.135],
                    '_II_rt3': [.225],
                    '_II_rt4': [.252],
                    '_II_rt5': [.297],
                    '_II_rt6': [.315],
                    '_II_rt7': [0.3564],
                    },
              }

    runner(output_base=output_base, input_dir=input_dir, baseline=False, reform=reform, run_micro=False)