Ejemplo n.º 1
0
def simlinear():
    
    sys.path.append(str(__projectdir__ / Path('dsgesetup')))
    from rbc_simple import getinputdict
    inputdict = getinputdict()

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

    # get policy function
    sys.path.append(str(__projectdir__ / Path('submodules/dsge-perturbation/')))
    from dsge_bkdiscrete_func import polfunc_inputdict
    inputdict = polfunc_inputdict(inputdict)

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

    # simulate path
    sys.path.append(str(__projectdir__ / Path('submodules/dsge-perturbation/')))
    from simlineardsge_func import simpathlinear_inputdict
    inputdict = simpathlinear_inputdict(inputdict)

    # path of non log-linearized variable
    print(inputdict['expssvarpath'])

    # standard deviation of consumption
    print(np.std(inputdict['varpath'][:, inputdict['stateshockcontrolposdict']['c']]))
Ejemplo n.º 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
    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)
Ejemplo n.º 3
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 getmodel():
    from rbc_simple import getinputdict
    inputdict = getinputdict()

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

    return(inputdict)
Ejemplo n.º 5
0
def polfunc():
    
    sys.path.append(str(__projectdir__ / Path('dsgesetup')))
    from rbc_simple import getinputdict
    inputdict = getinputdict()

    inputdict['savefolder'] = __projectdir__ / Path('dsge_bkdiscrete/temp_bkfull/')

    # add model
    sys.path.append(str(__projectdir__ / Path('submodules/dsge-perturbation/')))
    from dsge_bkdiscrete_func import discretelineardsgefull
    inputdict = discretelineardsgefull(inputdict) 
Ejemplo n.º 6
0
def irfcompare():

    DELTAlist = [0, 0.1, 1]
    inputdictlist = []
    for DELTA in DELTAlist:
        p = {'DELTA': DELTA}
        sys.path.append(str(__projectdir__ / Path('dsgesetup')))
        from rbc_simple import getinputdict
        inputdictlist.append(getinputdict(p=p))

    sys.path.append(str(__projectdir__ /
                        Path('submodules/dsge-perturbation/')))
    from dsge_bkdiscrete_func import irfmultiplemodels
    irfmultiplemodels(DELTAlist, inputdictlist, ['A', 'C', 'K'], 'epsilon_a')
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)
def polfunc():

    sys.path.append(str(__projectdir__ / Path('dsgesetup')))
    from rbc_simple import getinputdict
    inputdict = getinputdict()

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

    # get policy function
    sys.path.append(str(__projectdir__ /
                        Path('submodules/dsge-perturbation/')))
    from dsge_bkdiscrete_func import polfunc_inputdict
    inputdict = polfunc_inputdict(inputdict)

    print(inputdict['hx'])
    print(inputdict['gx'])