------------------------------------------------------------------------
    Run SS with minimization to fit chi_b and chi_n
------------------------------------------------------------------------
'''

# This is the simulation before getting the replacement rate values
sim_params = {}
for key in param_names:
    sim_params[key] = globals()[key]

#pickle.dump(dictionary, open("OUTPUT/Saved_moments/params_given.pkl", "w"))
#call(['python', 'SS.py'])
income_tax_params, wealth_tax_params, ellipse_params, ss_parameters, iterative_params = SS.create_steady_state_parameters(**sim_params)


ss_outputs = SS.run_steady_state(income_tax_params, ss_parameters, iterative_params, get_baseline, calibrate_model)


'''
------------------------------------------------------------------------
    Run the baseline TPI simulation
------------------------------------------------------------------------
'''

ss_outputs['get_baseline'] = get_baseline
income_tax_params, wealth_tax_params, ellipse_params, parameters, N_tilde, omega_stationary, K0, b_sinit, \
b_splus1init, L0, Y0, w0, r0, BQ0, T_H_0, tax0, c0, initial_b, initial_n = TPI.create_tpi_params(**sim_params)
ss_outputs['income_tax_params'] = income_tax_params
ss_outputs['wealth_tax_params'] = wealth_tax_params
ss_outputs['ellipse_params'] = ellipse_params
ss_outputs['parameters'] = parameters
Beispiel #2
0
def runner(output_base,
           input_dir,
           baseline=False,
           analytical_mtrs=True,
           reform={},
           user_params={},
           guid='',
           run_micro=True):

    from ogusa import parameters, wealth, labor, demographics, income
    from ogusa import txfunc

    tick = time.time()

    #Create output directory structure
    saved_moments_dir = os.path.join(output_base, "Saved_moments")
    ssinit_dir = os.path.join(output_base, "SSinit")
    tpiinit_dir = os.path.join(output_base, "TPIinit")
    dirs = [saved_moments_dir, ssinit_dir, tpiinit_dir]
    for _dir in dirs:
        try:
            print "making dir: ", _dir
            os.makedirs(_dir)
        except OSError as oe:
            pass

    if run_micro:
        txfunc.get_tax_func_estimate(baseline=baseline,
                                     analytical_mtrs=analytical_mtrs,
                                     reform=reform,
                                     guid=guid)
    print("in runner, baseline is ", baseline)
    run_params = ogusa.parameters.get_parameters(baseline=baseline, guid=guid)
    run_params['analytical_mtrs'] = analytical_mtrs

    # Modify ogusa parameters based on user input
    if 'frisch' in user_params:
        print "updating fricsh and associated"
        b_ellipse, upsilon = ogusa.elliptical_u_est.estimation(
            user_params['frisch'], run_params['ltilde'])
        run_params['b_ellipse'] = b_ellipse
        run_params['upsilon'] = upsilon
        run_params.update(user_params)

    # Modify ogusa parameters based on user input
    if 'g_y_annual' in user_params:
        print "updating g_y_annual and associated"
        g_y = (1 + user_params['g_y_annual'])**(
            float(ending_age - starting_age) / S) - 1
        run_params['g_y'] = g_y
        run_params.update(user_params)

    globals().update(run_params)

    from ogusa import SS, TPI
    # Generate Wealth data moments
    wealth.get_wealth_data(lambdas, J, flag_graphs, output_dir=input_dir)

    # Generate labor data moments
    labor.labor_data_moments(flag_graphs, output_dir=input_dir)

    get_baseline = True
    calibrate_model = False
    # List of parameter names that will not be changing (unless we decide to
    # change them for a tax experiment)

    param_names = [
        'S', 'J', 'T', 'BW', 'lambdas', 'starting_age', 'ending_age', 'beta',
        'sigma', 'alpha', 'nu', 'Z', 'delta', 'E', 'ltilde', 'g_y', 'maxiter',
        'mindist_SS', 'mindist_TPI', 'analytical_mtrs', 'b_ellipse',
        'k_ellipse', 'upsilon', 'chi_b_guess', 'chi_n_guess', 'etr_params',
        'mtrx_params', 'mtry_params', 'tau_payroll', 'tau_bq',
        'calibrate_model', 'retire', 'mean_income_data', 'g_n_vector',
        'h_wealth', 'p_wealth', 'm_wealth', 'get_baseline', 'omega', 'g_n_ss',
        'omega_SS', 'surv_rate', 'e', 'rho'
    ]
    '''
    ------------------------------------------------------------------------
        Run SS with minimization to fit chi_b and chi_n
    ------------------------------------------------------------------------
    '''

    # This is the simulation before getting the replacement rate values
    sim_params = {}
    glbs = globals()
    lcls = locals()
    for key in param_names:
        if key in glbs:
            sim_params[key] = glbs[key]
        else:
            sim_params[key] = lcls[key]

    sim_params['output_dir'] = input_dir
    sim_params['run_params'] = run_params

    income_tax_params, wealth_tax_params, ellipse_params, ss_parameters, iterative_params = SS.create_steady_state_parameters(
        **sim_params)

    ss_outputs = SS.run_steady_state(income_tax_params,
                                     ss_parameters,
                                     iterative_params,
                                     get_baseline,
                                     calibrate_model,
                                     output_dir=input_dir)
    '''
    ------------------------------------------------------------------------
        Run the baseline TPI simulation
    ------------------------------------------------------------------------
    '''

    ss_outputs['get_baseline'] = get_baseline
    sim_params['input_dir'] = input_dir
    income_tax_params, wealth_tax_params, ellipse_params, parameters, N_tilde, omega_stationary, K0, b_sinit, \
    b_splus1init, L0, Y0, w0, r0, BQ0, T_H_0, tax0, c0, initial_b, initial_n = TPI.create_tpi_params(**sim_params)
    ss_outputs['income_tax_params'] = income_tax_params
    ss_outputs['wealth_tax_params'] = wealth_tax_params
    ss_outputs['ellipse_params'] = ellipse_params
    ss_outputs['parameters'] = parameters
    ss_outputs['N_tilde'] = N_tilde
    ss_outputs['omega_stationary'] = omega_stationary
    ss_outputs['K0'] = K0
    ss_outputs['b_sinit'] = b_sinit
    ss_outputs['b_splus1init'] = b_splus1init
    ss_outputs['L0'] = L0
    ss_outputs['Y0'] = Y0
    ss_outputs['r0'] = r0
    ss_outputs['BQ0'] = BQ0
    ss_outputs['T_H_0'] = T_H_0
    ss_outputs['tax0'] = tax0
    ss_outputs['c0'] = c0
    ss_outputs['initial_b'] = initial_b
    ss_outputs['initial_n'] = initial_n
    ss_outputs['tau_bq'] = tau_bq
    ss_outputs['g_n_vector'] = g_n_vector
    ss_outputs['output_dir'] = input_dir

    with open("ss_outputs.pkl", 'wb') as fp:
        pickle.dump(ss_outputs, fp)

    w_path, r_path, T_H_path, BQ_path, Y_path = TPI.run_time_path_iteration(
        **ss_outputs)

    print "getting to here...."
    TPI.TP_solutions(w_path, r_path, T_H_path, BQ_path, **ss_outputs)
    print "took {0} seconds to get that part done.".format(time.time() - tick)
Beispiel #3
0
------------------------------------------------------------------------
    Run SS with minimization to fit chi_b and chi_n
------------------------------------------------------------------------
'''

# This is the simulation before getting the replacement rate values
sim_params = {}
for key in param_names:
    sim_params[key] = globals()[key]

#pickle.dump(dictionary, open("OUTPUT/Saved_moments/params_given.pkl", "w"))
#call(['python', 'SS.py'])
income_tax_params, wealth_tax_params, ellipse_params, ss_parameters, iterative_params = SS.create_steady_state_parameters(
    **sim_params)

ss_outputs = SS.run_steady_state(ss_parameters, iterative_params, get_baseline,
                                 calibrate_model)
'''
------------------------------------------------------------------------
    Run the baseline TPI simulation
------------------------------------------------------------------------
'''

ss_outputs['get_baseline'] = get_baseline
income_tax_params, wealth_tax_params, ellipse_params, parameters, N_tilde, omega_stationary, K0, b_sinit, \
b_splus1init, L0, Y0, w0, r0, BQ0, T_H_0, tax0, c0, initial_b, initial_n = TPI.create_tpi_params(**sim_params)
ss_outputs['income_tax_params'] = income_tax_params
ss_outputs['wealth_tax_params'] = wealth_tax_params
ss_outputs['ellipse_params'] = ellipse_params
ss_outputs['parameters'] = parameters
ss_outputs['N_tilde'] = N_tilde
ss_outputs['omega_stationary'] = omega_stationary
Beispiel #4
0
def test_sstpi():
    import tempfile
    import pickle
    import numpy as np
    import numpy as np
    import cPickle as pickle
    import os

    import ogusa

    ogusa.parameters.DATASET = "REAL"

    from ogusa.utils import comp_array
    from ogusa.utils import comp_scalar
    from ogusa.utils import dict_compare
    from ogusa.utils import pickle_file_compare

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

    globals().update(ogusa.parameters.get_parameters())

    # Generate Wealth data moments
    output_dir = TEST_OUTPUT
    input_dir = "./OUTPUT"
    wealth.get_wealth_data(lambdas, J, flag_graphs, output_dir)

    # Generate labor data moments
    labor.labor_data_moments(flag_graphs, output_dir=output_dir)

    get_baseline = True
    calibrate_model = False

    # List of parameter names that will not be changing (unless we decide to
    # change them for a tax experiment)
    param_names = [
        "S",
        "J",
        "T",
        "lambdas",
        "starting_age",
        "ending_age",
        "beta",
        "sigma",
        "alpha",
        "nu",
        "Z",
        "delta",
        "E",
        "ltilde",
        "g_y",
        "maxiter",
        "mindist_SS",
        "mindist_TPI",
        "b_ellipse",
        "k_ellipse",
        "upsilon",
        "a_tax_income",
        "chi_b_guess",
        "chi_n_guess",
        "b_tax_income",
        "c_tax_income",
        "d_tax_income",
        "tau_payroll",
        "tau_bq",
        "calibrate_model",
        "retire",
        "mean_income_data",
        "g_n_vector",
        "h_wealth",
        "p_wealth",
        "m_wealth",
        "get_baseline",
        "omega",
        "g_n_ss",
        "omega_SS",
        "surv_rate",
        "e",
        "rho",
    ]

    """
    ------------------------------------------------------------------------
        Run SS with minimization to fit chi_b and chi_n
    ------------------------------------------------------------------------
    """

    # This is the simulation before getting the replacement rate values
    sim_params = {}
    for key in param_names:
        try:
            sim_params[key] = locals()[key]
        except KeyError:
            sim_params[key] = globals()[key]

    sim_params["output_dir"] = output_dir
    sim_params["input_dir"] = input_dir
    income_tax_params, wealth_tax_params, ellipse_params, ss_parameters, iterative_params = SS.create_steady_state_parameters(
        **sim_params
    )

    ss_outputs = SS.run_steady_state(
        ss_parameters, iterative_params, get_baseline, calibrate_model, output_dir=output_dir
    )

    """
    ------------------------------------------------------------------------
        Run the baseline TPI simulation
    ------------------------------------------------------------------------
    """

    ss_outputs["get_baseline"] = get_baseline
    income_tax_params, wealth_tax_params, ellipse_params, parameters, N_tilde, omega_stationary, K0, b_sinit, b_splus1init, L0, Y0, w0, r0, BQ0, T_H_0, tax0, c0, initial_b, initial_n = TPI.create_tpi_params(
        **sim_params
    )
    ss_outputs["output_dir"] = output_dir
    ss_outputs["income_tax_params"] = income_tax_params
    ss_outputs["wealth_tax_params"] = wealth_tax_params
    ss_outputs["ellipse_params"] = ellipse_params
    ss_outputs["parameters"] = parameters
    ss_outputs["N_tilde"] = N_tilde
    ss_outputs["omega_stationary"] = omega_stationary
    ss_outputs["K0"] = K0
    ss_outputs["b_sinit"] = b_sinit
    ss_outputs["b_splus1init"] = b_splus1init
    ss_outputs["L0"] = L0
    ss_outputs["Y0"] = Y0
    ss_outputs["r0"] = r0
    ss_outputs["BQ0"] = BQ0
    ss_outputs["T_H_0"] = T_H_0
    ss_outputs["tax0"] = tax0
    ss_outputs["c0"] = c0
    ss_outputs["initial_b"] = initial_b
    ss_outputs["initial_n"] = initial_n
    ss_outputs["tau_bq"] = tau_bq
    ss_outputs["g_n_vector"] = g_n_vector
    TPI.run_time_path_iteration(**ss_outputs)

    # Platform specific exceptions:
    if sys.platform == "darwin":
        exceptions = {"tax_path": 0.08, "c_path": 0.02, "b_mat": 0.0017, "solutions": 0.005}
    else:
        exceptions = {}

    # compare results to test data
    for old, new in zip(oldfiles, newfiles):
        print "trying a pair"
        print old, new
        assert pickle_file_compare(old, new, exceptions=exceptions, relative=True)
        print "next pair"
Beispiel #5
0
def test_sstpi():
    import tempfile
    import pickle
    import numpy as np
    import numpy as np
    import pickle as pickle
    import os

    import ogusa
    ogusa.parameters.DATASET = 'REAL'

    from ogusa.utils import comp_array
    from ogusa.utils import comp_scalar
    from ogusa.utils import dict_compare
    from ogusa.utils import pickle_file_compare

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

    globals().update(ogusa.parameters.get_parameters())

    # Generate Wealth data moments
    output_dir = TEST_OUTPUT
    input_dir = "./OUTPUT"
    wealth.get_wealth_data(lambdas, J, flag_graphs, output_dir)

    # Generate labor data moments
    labor.labor_data_moments(flag_graphs, output_dir=output_dir)

    get_baseline = True
    calibrate_model = False

    # List of parameter names that will not be changing (unless we decide to
    # change them for a tax experiment)
    param_names = [
        'S', 'J', 'T', 'lambdas', 'starting_age', 'ending_age', 'beta',
        'sigma', 'alpha', 'nu', 'Z', 'delta', 'E', 'ltilde', 'g_y', 'maxiter',
        'mindist_SS', 'mindist_TPI', 'b_ellipse', 'k_ellipse', 'upsilon',
        'a_tax_income', 'chi_b_guess', 'chi_n_guess', 'b_tax_income',
        'c_tax_income', 'd_tax_income', 'tau_payroll', 'tau_bq',
        'calibrate_model', 'retire', 'mean_income_data', 'g_n_vector',
        'h_wealth', 'p_wealth', 'm_wealth', 'get_baseline', 'omega', 'g_n_ss',
        'omega_SS', 'surv_rate', 'e', 'rho'
    ]
    '''
    ------------------------------------------------------------------------
        Run SS with minimization to fit chi_b and chi_n
    ------------------------------------------------------------------------
    '''

    # This is the simulation before getting the replacement rate values
    sim_params = {}
    for key in param_names:
        try:
            sim_params[key] = locals()[key]
        except KeyError:
            sim_params[key] = globals()[key]

    sim_params['output_dir'] = output_dir
    sim_params['input_dir'] = input_dir
    income_tax_params, wealth_tax_params, ellipse_params, ss_parameters, \
        iterative_params = SS.create_steady_state_parameters(**sim_params)

    ss_outputs = SS.run_steady_state(ss_parameters,
                                     iterative_params,
                                     get_baseline,
                                     calibrate_model,
                                     output_dir=output_dir)
    '''
    ------------------------------------------------------------------------
        Run the baseline TPI simulation
    ------------------------------------------------------------------------
    '''

    ss_outputs['get_baseline'] = get_baseline
    income_tax_params, wealth_tax_params, ellipse_params, parameters, N_tilde, omega_stationary, K0, b_sinit, \
        b_splus1init, L0, Y0, w0, r0, BQ0, T_H_0, tax0, c0, initial_b, initial_n = TPI.create_tpi_params(
            **sim_params)
    ss_outputs['output_dir'] = output_dir
    ss_outputs['income_tax_params'] = income_tax_params
    ss_outputs['wealth_tax_params'] = wealth_tax_params
    ss_outputs['ellipse_params'] = ellipse_params
    ss_outputs['parameters'] = parameters
    ss_outputs['N_tilde'] = N_tilde
    ss_outputs['omega_stationary'] = omega_stationary
    ss_outputs['K0'] = K0
    ss_outputs['b_sinit'] = b_sinit
    ss_outputs['b_splus1init'] = b_splus1init
    ss_outputs['L0'] = L0
    ss_outputs['Y0'] = Y0
    ss_outputs['r0'] = r0
    ss_outputs['BQ0'] = BQ0
    ss_outputs['T_H_0'] = T_H_0
    ss_outputs['tax0'] = tax0
    ss_outputs['c0'] = c0
    ss_outputs['initial_b'] = initial_b
    ss_outputs['initial_n'] = initial_n
    ss_outputs['tau_bq'] = tau_bq
    ss_outputs['g_n_vector'] = g_n_vector
    TPI.run_time_path_iteration(**ss_outputs)

    # Platform specific exceptions:
    if sys.platform == "darwin":
        exceptions = {
            'tax_path': 0.08,
            'c_path': 0.02,
            'b_mat': 0.0017,
            'solutions': 0.005
        }
    else:
        exceptions = {}

    # compare results to test data
    for old, new in zip(oldfiles, newfiles):
        print("trying a pair")
        print(old, new)
        assert pickle_file_compare(old,
                                   new,
                                   exceptions=exceptions,
                                   relative=True)
        print("next pair")
Beispiel #6
0
def runner(output_base, input_dir, baseline=False, analytical_mtrs=True, age_specific=False, reform={}, user_params={}, guid='', run_micro=True):

    from ogusa import parameters, wealth, labor, demographics, income
    from ogusa import txfunc

    tick = time.time()

    #Create output directory structure
    saved_moments_dir = os.path.join(output_base, "Saved_moments")
    ssinit_dir = os.path.join(output_base, "SSinit")
    tpiinit_dir = os.path.join(output_base, "TPIinit")
    dirs = [saved_moments_dir, ssinit_dir, tpiinit_dir]
    for _dir in dirs:
        try:
            print "making dir: ", _dir
            os.makedirs(_dir)
        except OSError as oe:
            pass

    if run_micro:
        txfunc.get_tax_func_estimate(baseline=baseline, analytical_mtrs=analytical_mtrs, age_specific=age_specific, reform=reform, guid=guid)
    print ("in runner, baseline is ", baseline)
    run_params = ogusa.parameters.get_parameters(baseline=baseline, guid=guid)
    run_params['analytical_mtrs'] = analytical_mtrs

    # Modify ogusa parameters based on user input
    if 'frisch' in user_params:
        print "updating fricsh and associated"
        b_ellipse, upsilon = ogusa.elliptical_u_est.estimation(user_params['frisch'],
                                                               run_params['ltilde'])
        run_params['b_ellipse'] = b_ellipse
        run_params['upsilon'] = upsilon
        run_params.update(user_params)

    # Modify ogusa parameters based on user input
    if 'g_y_annual' in user_params:
        print "updating g_y_annual and associated"
        g_y = (1 + user_params['g_y_annual'])**(float(ending_age - starting_age) / S) - 1
        run_params['g_y'] = g_y
        run_params.update(user_params)

    globals().update(run_params)

    from ogusa import SS, TPI
    # Generate Wealth data moments
    wealth.get_wealth_data(lambdas, J, flag_graphs, output_dir=input_dir)

    # Generate labor data moments
    labor.labor_data_moments(flag_graphs, output_dir=input_dir)

    
    get_baseline = True
    calibrate_model = False
    # List of parameter names that will not be changing (unless we decide to
    # change them for a tax experiment)

    param_names = ['S', 'J', 'T', 'BW', 'lambdas', 'starting_age', 'ending_age',
                'beta', 'sigma', 'alpha', 'nu', 'Z', 'delta', 'E',
                'ltilde', 'g_y', 'maxiter', 'mindist_SS', 'mindist_TPI',
                'analytical_mtrs', 'b_ellipse', 'k_ellipse', 'upsilon',
                'chi_b_guess', 'chi_n_guess','etr_params','mtrx_params',
                'mtry_params','tau_payroll', 'tau_bq', 'calibrate_model',
                'retire', 'mean_income_data', 'g_n_vector',
                'h_wealth', 'p_wealth', 'm_wealth', 'get_baseline',
                'omega', 'g_n_ss', 'omega_SS', 'surv_rate', 'e', 'rho']


    '''
    ------------------------------------------------------------------------
        Run SS with minimization to fit chi_b and chi_n
    ------------------------------------------------------------------------
    '''

    # This is the simulation before getting the replacement rate values
    sim_params = {}
    glbs = globals()
    lcls = locals()
    for key in param_names:
        if key in glbs:
            sim_params[key] = glbs[key]
        else:
            sim_params[key] = lcls[key]

    sim_params['output_dir'] = input_dir
    sim_params['run_params'] = run_params

    income_tax_params, wealth_tax_params, ellipse_params, ss_parameters, iterative_params = SS.create_steady_state_parameters(**sim_params)

    ss_outputs = SS.run_steady_state(income_tax_params, ss_parameters, iterative_params, get_baseline, calibrate_model, output_dir=input_dir)


    '''
    ------------------------------------------------------------------------
        Run the baseline TPI simulation
    ------------------------------------------------------------------------
    '''

    ss_outputs['get_baseline'] = get_baseline
    sim_params['input_dir'] = input_dir
    income_tax_params, wealth_tax_params, ellipse_params, parameters, N_tilde, omega_stationary, K0, b_sinit, \
    b_splus1init, L0, Y0, w0, r0, BQ0, T_H_0, tax0, c0, initial_b, initial_n = TPI.create_tpi_params(**sim_params)
    ss_outputs['income_tax_params'] = income_tax_params
    ss_outputs['wealth_tax_params'] = wealth_tax_params
    ss_outputs['ellipse_params'] = ellipse_params
    ss_outputs['parameters'] = parameters
    ss_outputs['N_tilde'] = N_tilde
    ss_outputs['omega_stationary'] = omega_stationary
    ss_outputs['K0'] = K0
    ss_outputs['b_sinit'] = b_sinit
    ss_outputs['b_splus1init'] = b_splus1init
    ss_outputs['L0'] = L0
    ss_outputs['Y0'] = Y0
    ss_outputs['r0'] = r0
    ss_outputs['BQ0'] = BQ0
    ss_outputs['T_H_0'] = T_H_0
    ss_outputs['tax0'] = tax0
    ss_outputs['c0'] = c0
    ss_outputs['initial_b'] = initial_b
    ss_outputs['initial_n'] = initial_n
    ss_outputs['tau_bq'] = tau_bq
    ss_outputs['g_n_vector'] = g_n_vector
    ss_outputs['output_dir'] = input_dir


    with open("ss_outputs.pkl", 'wb') as fp:
        pickle.dump(ss_outputs, fp)

    w_path, r_path, T_H_path, BQ_path, Y_path = TPI.run_time_path_iteration(**ss_outputs)


    print "getting to here...."
    TPI.TP_solutions(w_path, r_path, T_H_path, BQ_path, **ss_outputs)
    print "took {0} seconds to get that part done.".format(time.time() - tick)
Beispiel #7
0
def runner_SS(output_base, baseline_dir, baseline=False, analytical_mtrs=True, age_specific=False, reform={}, user_params={}, guid='', run_micro=True):

    from ogusa import parameters, wealth, labor, demographics, income
    from ogusa import txfunc

    tick = time.time()

    #Create output directory structure
    saved_moments_dir = os.path.join(output_base, "Saved_moments")
    ssinit_dir = os.path.join(output_base, "SSinit")
    tpiinit_dir = os.path.join(output_base, "TPIinit")
    dirs = [saved_moments_dir, ssinit_dir, tpiinit_dir]
    for _dir in dirs:
        try:
            print "making dir: ", _dir
            os.makedirs(_dir)
        except OSError as oe:
            pass

    if run_micro:
        txfunc.get_tax_func_estimate(baseline=baseline, analytical_mtrs=analytical_mtrs, age_specific=age_specific, 
                                     start_year=user_params['start_year'], reform=reform, guid=guid)
    print ("in runner, baseline is ", baseline)
    run_params = ogusa.parameters.get_parameters(baseline=baseline, guid=guid)
    run_params['analytical_mtrs'] = analytical_mtrs

    # Modify ogusa parameters based on user input
    if 'frisch' in user_params:
        print "updating fricsh and associated"
        b_ellipse, upsilon = ogusa.elliptical_u_est.estimation(user_params['frisch'],
                                                               run_params['ltilde'])
        run_params['b_ellipse'] = b_ellipse
        run_params['upsilon'] = upsilon
        run_params.update(user_params)

    # Modify ogusa parameters based on user input
    if 'g_y_annual' in user_params:
        print "updating g_y_annual and associated"
        g_y = (1 + user_params['g_y_annual'])**(float(ending_age - starting_age) / S) - 1
        run_params['g_y'] = g_y
        run_params.update(user_params)

    globals().update(run_params)

    from ogusa import SS, TPI
    # Generate Wealth data moments
    wealth.get_wealth_data(lambdas, J, flag_graphs, output_dir=output_base)

    # Generate labor data moments
    labor.labor_data_moments(flag_graphs, output_dir=output_base)

    
    get_baseline = True
    calibrate_model = True
    # List of parameter names that will not be changing (unless we decide to
    # change them for a tax experiment)

    param_names = ['S', 'J', 'T', 'BW', 'lambdas', 'starting_age', 'ending_age',
                'beta', 'sigma', 'alpha', 'nu', 'Z', 'delta', 'E',
                'ltilde', 'g_y', 'maxiter', 'mindist_SS', 'mindist_TPI',
                'analytical_mtrs', 'b_ellipse', 'k_ellipse', 'upsilon',
                'chi_b_guess', 'chi_n_guess','etr_params','mtrx_params',
                'mtry_params','tau_payroll', 'tau_bq', 'calibrate_model',
                'retire', 'mean_income_data', 'g_n_vector',
                'h_wealth', 'p_wealth', 'm_wealth', 'get_baseline',
                'omega', 'g_n_ss', 'omega_SS', 'surv_rate', 'e', 'rho']


    '''
    ------------------------------------------------------------------------
        Run SS
    ------------------------------------------------------------------------
    '''

    sim_params = {}
    glbs = globals()
    lcls = locals()
    for key in param_names:
        if key in glbs:
            sim_params[key] = glbs[key]
        else:
            sim_params[key] = lcls[key]

    sim_params['output_dir'] = output_base
    sim_params['run_params'] = run_params

    income_tax_params, wealth_tax_params, ellipse_params, ss_parameters, iterative_params = SS.create_steady_state_parameters(**sim_params)

    ss_outputs = SS.run_steady_state(income_tax_params, ss_parameters, iterative_params, baseline, 
                                     calibrate_model, output_dir=output_base, baseline_dir=baseline_dir)