Exemple #1
0
    def test_modfile_solve(self):

        from dolo import solve_decision_rule, dynare_import

        model = dynare_import('examples/dynare_modfiles/example1.mod')

        dr = solve_decision_rule(model, order=1)
    def test_modfile_solve(self):

        from dolo import solve_decision_rule, dynare_import

        model = dynare_import('examples/dynare_modfiles/example1.mod')

        dr = solve_decision_rule(model, order=1)
    def test_modfile_solve(self):

        from dolo import solve_decision_rule, dynare_import

        model = dynare_import('examples/dynare_modfiles/example1.mod')

        dr = solve_decision_rule(model, order=1)

        # at first order the decision rule is such that:
        # y_{t} - ybar = A (y_{t-1} - ybar) + B e_t

        print(dr['ys'])
        print(dr['g_a'])
        print(dr['g_e'])

        # it can be compared directly to dynare's decision rules
        # warning: Dynare's ordering is special
        print(dr.ghx)
        print(dr.ghu)
    def test_dynare_compatibility(self):

        from dolo import solve_decision_rule, dynare_import

        model = dynare_import('examples/dynare_modfiles/example1.mod')

        dr = solve_decision_rule(model, order=1)

        # at first order the decision rule is such that:
        # y_{t} - ybar = A (y_{t-1} - ybar) + B e_t

        from dolo.numeric.decision_rules import DynareDecisionRule
        dr = DynareDecisionRule(dr, model)
        print(dr['ys'])
        print(dr['g_a'])
        print(dr['g_e'])

        # it can be compared directly to dynare's decision rules
        # warning: Dynare's ordering is special
        print(dr.ghx)
        print(dr.ghu)
Exemple #5
0
    def open(self):
        filename = QtGui.QFileDialog.getOpenFileName()
        filename = str(filename)
        try:
            f = file(filename)
            txt = f.read()
        finally:
            f.close()
        try:
            model = dolo.dynare_import(filename)
            model.check_consistency(verbose=True)
            n = len(model.equations)
            q = len(self.widgets)
            if n > q:
                for i in range(n - q):
                    self.add_widget()
            elif n < q:
                for i in range(q - n):
                    self.delete_widget(0)
            for n, eq in enumerate(model.equations):
                tt = str(eq)
                tt = tt.replace('**', '^')
                tt = tt.replace('==', '=')
                self.widgets[n].set_text(tt)
            self.ui.lineEdit_var.setText(
                str.join(' ', [str(v) for v in model.variables]))
            self.ui.lineEdit_parameters.setText(
                str.join(' ', [str(v) for v in model.parameters]))
            self.ui.lineEdit_shocks.setText(
                str.join(' ', [str(v) for v in model.shocks]))

            # parameters values
            parms_text = ''
            for p in model.parameters:
                pv = model.parameters_values[p]
                parms_text += '{0} = {1};\n'.format(p, pv)
            self.ui.plainTextEdit.setPlainText(parms_text)
            initval_text = ''
            for v in model.init_values:
                vv = model.init_values[v]
                initval_text += '{0} = {1};\n'.format(v, vv)
            self.ui.plainTextEdit_2.setPlainText(initval_text)

            if model.covariances:
                cov_text = ''
                for i, si in enumerate(model.shocks):
                    for j, sj in enumerate(model.shocks):
                        v = model.covariances[i, j]
                        vt = str(v).replace('**', '^')
                        if v == 0:
                            pass
                        elif i > j:
                            pass
                        elif i < j:
                            cov_text += 'var {0},{1} = {2};\n'.format(
                                si, sj, vt)
                        else:
                            cov_text += 'var {0} = {1};\n'.format(si, vt)
                self.ui.plainTextEdit_3.setPlainText(cov_text)

        except Exception as e:
            print 'Import failed.'
            print e
        model_info += '    out1 = mod;\n'

        text = text.format(
            eq_bounds_block = eq_bounds_block,
            mfname = fname if fname else 'mf_' + model.fname,
            eq_fun_block=eq_f_block,
            state_trans_block=eq_g_block,
            exp_fun_block=eq_h_block,
#            solution = solution,
            model_info = model_info
        )

        return text


def eqdiff(leq,lvars):
    resp = []
    for eq in leq:
        el = [ eq.diff(v) for v in lvars]
        resp += [el]
    return resp


if __name__ == "__main__":
    from dolo import dynare_import
    model = dynare_import('../../../examples/global_models/optimal_growth.mod')
    model.check()
    mfcp = MirFacCompiler(model)
    print mfcp.process_output_recs()
    #print mfcp.process_output_python()
Exemple #7
0
        model_info += '    out1 = mod;\n'

        text = text.format(
            eq_bounds_block = eq_bounds_block,
            mfname = fname if fname else 'mf_' + model.fname,
            eq_fun_block=eq_f_block,
            state_trans_block=eq_g_block,
            exp_fun_block=eq_h_block,
#            solution = solution,
            model_info = model_info
        )

        return text


def eqdiff(leq,lvars):
    resp = []
    for eq in leq:
        el = [ eq.diff(v) for v in lvars]
        resp += [el]
    return resp


if __name__ == "__main__":
    from dolo import dynare_import
    model = dynare_import('../../../examples/global_models/optimal_growth.mod')
    model.check()
    mfcp = MirFacCompiler(model)
    print mfcp.process_output_recs()
    #print mfcp.process_output_python()
Exemple #8
0
    def open(self):
        filename = QtGui.QFileDialog.getOpenFileName()
        filename = str(filename)
        try:
            f = file( filename )
            txt = f.read()
        finally:
            f.close()
        try:
            model = dolo.dynare_import(filename)
            model.check_consistency(verbose=True)
            n = len(model.equations)
            q = len(self.widgets)
            if n > q:
                for i in range(n-q):
                    self.add_widget()
            elif n < q:
                for i in range(q-n):
                    self.delete_widget(0)
            for n,eq in enumerate(model.equations):
                tt = str(eq)
                tt = tt.replace('**','^')
                tt = tt.replace('==','=')
                self.widgets[n].set_text(tt)
            self.ui.lineEdit_var.setText( str.join(' ',[ str(v) for v in model.variables ]) )
            self.ui.lineEdit_parameters.setText( str.join(' ',[ str(v) for v in model.parameters ]) )
            self.ui.lineEdit_shocks.setText(  str.join(' ',[ str(v) for v in model.shocks ]) )

            # parameters values
            parms_text = ''
            for p in model.parameters:
                pv = model.parameters_values[p]
                parms_text += '{0} = {1};\n'.format(p,pv)
            self.ui.plainTextEdit.setPlainText(parms_text)
            initval_text = ''
            for v in model.init_values:
                vv = model.init_values[v]
                initval_text += '{0} = {1};\n'.format(v,vv)
            self.ui.plainTextEdit_2.setPlainText(initval_text)
            
            if model.covariances:
                cov_text = ''
                for i,si in enumerate(model.shocks):
                    for j,sj in enumerate(model.shocks):
                        v = model.covariances[i,j]
                        vt = str(v).replace('**','^')
                        if v==0:
                            pass
                        elif i>j:
                            pass
                        elif i<j:
                            cov_text += 'var {0},{1} = {2};\n'.format(si,sj,vt)
                        else:
                            cov_text += 'var {0} = {1};\n'.format(si,vt)
                self.ui.plainTextEdit_3.setPlainText(cov_text)
                

            

        except Exception as e:
            print 'Import failed.'
            print e