do_optimizing = False  # Set to True to reestimate the distribution of time preference rates

if do_optimizing:  # If you want to rerun the cstwMPC estimation, change do_optimizing to True
    # Finite value requires discount factor from combined pure and mortality-induced
    # discounting to be less than one, so maximum DiscFac is 1/LivPrb
    DiscFacMax = 1 / Params.init_cjSOE['LivPrb'][0]  #
    param_range = [0.995, -0.0001 + DiscFacMax]
    spread_range = [0.00195, 0.0205]  #

    if Params.do_param_dist:  # If configured to estimate the distribution
        LorenzBool = True
        # Run the param-dist estimation
        paramDistObjective = lambda spread: cstwMPC.findLorenzDistanceAtTargetKY(
            Economy=EstimationEconomy,
            param_name=Params.param_name,
            param_count=Params.pref_type_count,
            center_range=param_range,
            spread=spread,
            dist_type=Params.dist_type)  # Distribution of DiscFac
        t_start = clock()

        spread_estimate = golden(paramDistObjective,
                                 brack=spread_range,
                                 tol=1e-4)
        center_estimate = EstimationEconomy.center_save
        t_end = clock()
    else:  # Run the param-point estimation only
        paramPointObjective = lambda center: cstwMPC.getKYratioDifference(
            Economy=EstimationEconomy,
            param_name=Params.param_name,
            param_count=Params.pref_type_count,
Esempio n. 2
0
        if param_name == 'CRRA':
            param_range = [0.2, 70.0]
            spread_range = [0.00001, 1.0]
        elif param_name == 'DiscFac':
            param_range = [0.95, 0.995]
            spread_range = [0.006, 0.008]
        else:
            print('Parameter range for ' + param_name +
                  ' has not been defined!')

        if do_param_dist:
            # Run the param-dist estimation
            paramDistObjective = lambda spread: findLorenzDistanceAtTargetKY(
                Economy=EstimationEconomy,
                param_name=param_name,
                param_count=pref_type_count,
                center_range=param_range,
                spread=spread,
                dist_type=dist_type)
            t_start = clock()
            spread_estimate = (minimize_scalar(paramDistObjective,
                                               bracket=spread_range,
                                               tol=1e-4,
                                               method='brent')).x
            center_estimate = EstimationEconomy.center_save
            t_end = clock()
        else:
            # Run the param-point estimation only
            paramPointObjective = lambda center: getKYratioDifference(
                Economy=EstimationEconomy,
                param_name=param_name,