Exemple #1
0
def stochsimul(run = True):
    
    sys.path.append(str(__projectdir__ / Path('dsgesetup')))
    from rbc_simple import getinputdict
    inputdict = getinputdict()
    inputdict['savefolder'] = __projectdir__ / Path('python2dynare/temp/stochsimul/')

    # add model
    sys.path.append(str(__projectdir__ / Path('submodules/dsge-perturbation/')))
    from dsgesetup_func import getmodel_inputdict
    inputdict = getmodel_inputdict(inputdict) 

    # add shocksddict
    inputdict['shocksddict'] = {'epsilon_a': 0.01}
    sys.path.append(str(__projectdir__ / Path('submodules/dsge-perturbation/')))
    from getshocks_func import getshocksddict_inputdict
    inputdict = getshocksddict_inputdict(inputdict)

    # python2dynare
    inputdict['python2dynare_simulation'] = 'extended_path(periods=100,solver_periods=100);'
    sys.path.append(str(__projectdir__ / Path('submodules/dsge-perturbation/')))
    from python2dynare_func import python2dynare_inputdict
    python2dynare_inputdict(inputdict)

    # run dynare
    if run is True:
        # run dynare
        sys.path.append(str(__projectdir__ / Path('submodules/dsge-perturbation/')))
        from python2dynare_func import rundynare_inputdict
        rundynare_inputdict(inputdict)
        # get irfs
        sys.path.append(str(__projectdir__ / Path('submodules/dsge-perturbation/')))
        from python2dynare_func import getirfs_dynare_inputdict
        getirfs_dynare_inputdict(inputdict)
Exemple #2
0
def stochsimul(run=True):

    sys.path.append(str(__projectdir__ / Path('dsgesetup')))
    from rbc_simple import getinputdict
    inputdict = getinputdict()
    inputdict['savefolder'] = __projectdir__ / Path(
        'python2dynare/temp/stochsimul/')

    # add model
    sys.path.append(str(__projectdir__ /
                        Path('submodules/dsge-perturbation/')))
    from dsgesetup_func import getmodel_inputdict
    inputdict = getmodel_inputdict(inputdict)

    # add shocksddict
    sys.path.append(str(__projectdir__ /
                        Path('submodules/dsge-perturbation/')))
    from getshocks_func import getshocksddict_inputdict
    inputdict = getshocksddict_inputdict(inputdict)

    # python2dynare
    inputdict['python2dynare_simulation'] = 'stoch_simul(order=1);'
    sys.path.append(str(__projectdir__ /
                        Path('submodules/dsge-perturbation/')))
    from python2dynare_func import python2dynare_inputdict
    python2dynare_inputdict(inputdict)

    # run dynare
    if run is True:
        # run dynare
        sys.path.append(
            str(__projectdir__ / Path('submodules/dsge-perturbation/')))
        from python2dynare_func import rundynare_inputdict
        rundynare_inputdict(inputdict)
def simul(run=False, shockpathspecify=False):
    """
    If run = True, need to specify inputdict['dynarepath'] and (if you want to use Octave) inputdict['runwithoctave'] = True
    """

    sys.path.append(str(__projectdir__ / Path('dsgesetup')))
    from rbc_simple import getinputdict
    inputdict = getinputdict()
    inputdict['savefolder'] = __projectdir__ / Path(
        'python2dynare/temp/simul_shockpath/')

    # add model
    sys.path.append(str(__projectdir__ /
                        Path('submodules/dsge-perturbation/')))
    from dsgesetup_func import getmodel_inputdict
    inputdict = getmodel_inputdict(inputdict)

    # add pathshock
    if shockpathspecify is True:
        inputdict['shockpath'] = np.array([[1, 1, 1] + [0] * 17]).transpose()
    else:
        inputdict['pathsimperiods'] = 20
        inputdict['pathsimperiods_noshock'] = 10
        sys.path.append(
            str(__projectdir__ / Path('submodules/dsge-perturbation/')))
        from getshocks_func import getshockpath_inputdict
        inputdict = getshockpath_inputdict(inputdict)

    # python2dynare
    inputdict['python2dynare_simulation'] = 'simul(periods = 300);'
    sys.path.append(str(__projectdir__ /
                        Path('submodules/dsge-perturbation/')))
    from python2dynare_func import python2dynare_inputdict
    python2dynare_inputdict(inputdict)

    # run dynare
    if run is True:
        # run dynare
        sys.path.append(
            str(__projectdir__ / Path('submodules/dsge-perturbation/')))
        from python2dynare_func import rundynare_inputdict
        rundynare_inputdict(inputdict)
        # get irfs
        sys.path.append(
            str(__projectdir__ / Path('submodules/dsge-perturbation/')))
        from python2dynare_func import getirfs_dynare_inputdict
        getirfs_dynare_inputdict(inputdict)
Exemple #4
0
def dynare_extendedpath(p=None, run=False):
    """
    Solve model by extended path.
    The extended path method in Dynare assumes agents at t only know shocks at t.

    If I could input the shockpath, this should yield the same as occbin/myoccbin.
    But I don't see to be able to do that - I have to specify the shock s.d. instead.
    """
    if p is None:
        p = getp_default()

    p['monetary'] = 'taylor-zlb'
    inputdict = getinputdict(p)

    inputdict['savefolder'] = os.path.join(__projectdir__,
                                           'regimes/temp/extendedpath/')

    # add model
    sys.path.append(str(__projectdir__ /
                        Path('submodules/dsge-perturbation/')))
    from dsgesetup_func import getmodel_inputdict
    inputdict = getmodel_inputdict(inputdict)

    # add shock path
    inputdict['shocksddict'] = copy.deepcopy(shocksddict_default)

    # generate python2dynare
    inputdict[
        'python2dynare_simulation'] = 'extended_path(periods = 20,solver_periods=100);'
    sys.path.append(str(__projectdir__ /
                        Path('submodules/dsge-perturbation/')))
    from python2dynare_func import python2dynare_inputdict
    python2dynare_inputdict(inputdict)

    # run dynare
    if run is True:
        # run dynare
        sys.path.append(
            str(__projectdir__ / Path('submodules/dsge-perturbation/')))
        from python2dynare_func import rundynare_inputdict
        rundynare_inputdict(inputdict)
        # get irfs
        sys.path.append(
            str(__projectdir__ / Path('submodules/dsge-perturbation/')))
        from python2dynare_func import getirfs_dynare_inputdict
        getirfs_dynare_inputdict(inputdict)
Exemple #5
0
def dynare_simul(p=None, run=False):
    """
    Use the Dynare simul method to solve given the constraint.
    This method implies that at time t, agents anticipate the values of future shocks.
    Thus, this method does not produce the same results as occbin which assumes that agents only know the values of shocks today.
    """
    if p is None:
        p = getp_default()

    p['monetary'] = 'taylor-zlb'
    inputdict = getinputdict(p)

    inputdict['savefolder'] = os.path.join(__projectdir__,
                                           'regimes/temp/perfect_foresight/')

    # add model
    sys.path.append(str(__projectdir__ /
                        Path('submodules/dsge-perturbation/')))
    from dsgesetup_func import getmodel_inputdict
    inputdict = getmodel_inputdict(inputdict)

    # add shock path
    inputdict['shockpath'] = shockpath_default

    # generate python2dynare
    inputdict['python2dynare_simulation'] = 'simul(periods = 20);'
    sys.path.append(str(__projectdir__ /
                        Path('submodules/dsge-perturbation/')))
    from python2dynare_func import python2dynare_inputdict
    python2dynare_inputdict(inputdict)

    # run dynare
    if run is True:
        # run dynare
        sys.path.append(
            str(__projectdir__ / Path('submodules/dsge-perturbation/')))
        from python2dynare_func import rundynare_inputdict
        rundynare_inputdict(inputdict)
        # get irfs
        sys.path.append(
            str(__projectdir__ / Path('submodules/dsge-perturbation/')))
        from python2dynare_func import getirfs_dynare_inputdict
        getirfs_dynare_inputdict(inputdict)