modelflowib 2.73__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- modelBLfunk.py +180 -0
- model_Excel.py +332 -0
- model_cvx.py +139 -0
- model_dynare.py +173 -0
- model_financial_stability.py +88 -0
- model_latex.py +497 -0
- model_latex_class.py +808 -0
- model_parquet_mixin.py +424 -0
- modelclass.py +9828 -0
- modelconstruct.py +1496 -0
- modelconstruct_estimation.py +2872 -0
- modeldash.py +265 -0
- modeldashboot.py +202 -0
- modeldashsidebar.py +456 -0
- modeldekom.py +651 -0
- modeldiff.py +561 -0
- modeldisplay.py +550 -0
- modelestimation.py +1776 -0
- modelestimator_new.py +2613 -0
- modelflowib-2.73.dist-info/METADATA +156 -0
- modelflowib-2.73.dist-info/RECORD +44 -0
- modelflowib-2.73.dist-info/WHEEL +5 -0
- modelflowib-2.73.dist-info/licenses/license.md +10 -0
- modelflowib-2.73.dist-info/top_level.txt +39 -0
- modelgrab.py +318 -0
- modelgrabgdx.py +584 -0
- modelgrabwf2.py +1107 -0
- modelhelp.py +543 -0
- modelhtml.py +606 -0
- modelinvert.py +250 -0
- modeljupyter.py +824 -0
- modeljupytermagic.py +813 -0
- modelmacrograb.py +98 -0
- modelmanipulation.py +1461 -0
- modelmf.py +349 -0
- modelnet.py +114 -0
- modelnewton.py +2178 -0
- modelnormalize.py +430 -0
- modelpattern.py +428 -0
- modelreport.py +2187 -0
- modeluserfunk.py +97 -0
- modelvis.py +1038 -0
- modelwidget.py +718 -0
- modelwidget_input.py +1933 -0
modelmacrograb.py
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
Created on Sun Jun 19 14:43:37 2022
|
|
4
|
+
|
|
5
|
+
grab a world bank macromodel using modelnormalize and not modelmanipulation
|
|
6
|
+
|
|
7
|
+
@author: ibhan
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import pandas as pd
|
|
11
|
+
from dataclasses import dataclass, field
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
from modelclass import model
|
|
15
|
+
import modelnormalize as nz
|
|
16
|
+
import modelmanipulation as mp
|
|
17
|
+
|
|
18
|
+
@dataclass
|
|
19
|
+
class GrabMacroModel():
|
|
20
|
+
'''This class takes a world bank model specification, variable data and variable description
|
|
21
|
+
and transform it to ModelFlow business language'''
|
|
22
|
+
|
|
23
|
+
inputfrml : any = '' #wf1 name
|
|
24
|
+
modelname : str ='macromodel'
|
|
25
|
+
make_fitted : bool = True
|
|
26
|
+
add_add_factor : bool = True
|
|
27
|
+
debug : bool = True
|
|
28
|
+
def __post_init__(self):
|
|
29
|
+
eq = [l.upper() for l in self.inputfrml.split('\n') if len(l.strip())]
|
|
30
|
+
eeq = [('<>' if len(tup := e.split('>')) == 1 else f'{tup[0]}>' ,tup[-1])
|
|
31
|
+
for e in eq ]
|
|
32
|
+
|
|
33
|
+
self.all_frml = [(frmlname,
|
|
34
|
+
nz.normal(
|
|
35
|
+
eq,
|
|
36
|
+
make_fixable = (fixit :='EXO' in frmlname or 'FIXABLE' in frmlname),
|
|
37
|
+
add_add_factor = fixit and self.add_add_factor,
|
|
38
|
+
make_fitted = self.make_fitted and fixit
|
|
39
|
+
)
|
|
40
|
+
)
|
|
41
|
+
for frmlname,eq in eeq]
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
if self.debug:
|
|
45
|
+
for frmlname,frml in self.all_frml:
|
|
46
|
+
print(f'\nFrml name:{frmlname}\n{frml}')
|
|
47
|
+
|
|
48
|
+
# create the main model:
|
|
49
|
+
fmainmodel_tomodel = '\n'.join( [f'FRML {frmlname} {frml.normalized}$' for frmlname,frml in self.all_frml])
|
|
50
|
+
# now create the fitted model
|
|
51
|
+
if self.make_fitted:
|
|
52
|
+
ffitmodel_tomodel ='\n'.join( [f'FRML <FIT> {frml.fitted}$'
|
|
53
|
+
for frmlname,frml in self.all_frml if len(frml.fitted)])
|
|
54
|
+
self.mfitmodel = model(ffitmodel_tomodel,modelname = self.modelname + ' calc fittet values')
|
|
55
|
+
else:
|
|
56
|
+
self.mfitmodel = None
|
|
57
|
+
ffitmodel_tomodel = ''
|
|
58
|
+
|
|
59
|
+
# now create the add factor model
|
|
60
|
+
# one for inclusion in the main model, and one for solo use in to create data
|
|
61
|
+
if self.add_add_factor:
|
|
62
|
+
fcalc_add_factor_tomodel_solo = '\n'.join([f'{frml.calc_add_factor}' for frmlname,frml in self.all_frml if frml.calc_add_factor])
|
|
63
|
+
self.mcalc_add_factor = model(fcalc_add_factor_tomodel_solo,modelname = f'Calculation of add factors for {self.modelname}')
|
|
64
|
+
|
|
65
|
+
fcalc_add_factor_tomodel ='\n'.join([f'FRML <CALC_ADD_FACTOR> {frml.calc_add_factor}$' for frmlname,frml in self.all_frml if frml.calc_add_factor])
|
|
66
|
+
else:
|
|
67
|
+
fcalc_add_factor_tomodel =''
|
|
68
|
+
self.mcalc_add_factor = None
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
self.fmodel = f'{fmainmodel_tomodel}\n{ffitmodel_tomodel}\n{fcalc_add_factor_tomodel}'
|
|
73
|
+
self.mmodel = model(self.fmodel,modelname =self.modelname)
|
|
74
|
+
# self.mmodel.set_var_description(self.model_all_about['var_description'])
|
|
75
|
+
# self.mmodel.set_var_description(self.var_description)
|
|
76
|
+
# breakpoint()
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
if __name__ == '__main__':
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
smallmodel = '''
|
|
85
|
+
<fixable z> dlog(cpv)= -c2_cpv*(log(cpv(-1))-log(y(-1)) - c1_cpv)+c3_cpv*dlog(y)
|
|
86
|
+
|
|
87
|
+
<fixable z> dlog(g) = -c2_g* (log(g(-1))- log(y(-1)) - c1_g) +c3_g*dlog(y)
|
|
88
|
+
|
|
89
|
+
<fixable z> dlog(i) = -c2_i* (log(i(-1))- log(y(-1)-g(-1)) - c1_i) +c3_i*dlog(y)
|
|
90
|
+
|
|
91
|
+
<fixable z> dlog(m) = -c2_m* (log(m(-1))- log(gde(-1)) - c1_m) +c3_m*dlog(gde)
|
|
92
|
+
|
|
93
|
+
<ident> y=cpv+i+g+x-m+ydisc
|
|
94
|
+
|
|
95
|
+
<ident> gde=cpv+i+g
|
|
96
|
+
|
|
97
|
+
'''
|
|
98
|
+
cmodel = GrabMacroModel(smallmodel)
|