modelnormalize module

Created on Sat Nov 28 13:32:47 2020

This Module is used transforming model specifications to modelflow business language.

  • preprocessing expressions to resolve functions like

    dlog, log, pct, movavg

  • replace function names

  • normalize formulas

@author: bruger

class modelnormalize.Normalized_frml(endo_var: str = '', original: str = '', preprocessed: str = '', normalized: str = '', calc_add_factor: str = '', un_normalized: str = '', fitted: str = '', eviews: str = '')[source]

Bases: object

class defining result from normalization of expression

endo_var: str = ''
original: str = ''
preprocessed: str = ''
normalized: str = ''
calc_add_factor: str = ''
un_normalized: str = ''
fitted: str = ''
eviews: str = ''
property fprint
property fdict
modelnormalize.endovar(f)[source]

Finds the first variable in a expression

modelnormalize.funk_in(funk, a_string)[source]

Find the first location of a function in a string

if found returns a match object where the group 2 is the interesting stuff used in funk_find_arg

modelnormalize.funk_replace(funk1, funk2, a_string)[source]

replace funk1( with funk2(

takes care that funk1 embedded in variable name is not replaced

modelnormalize.funk_replace_list(replacelist, a_string)[source]

Replaces a list of funk1( , funk2(

modelnormalize.funk_find_arg(funk_match, streng)[source]

chops a string in 3 parts

  1. before ‘funk(’

  2. in the matching parantesis

  3. after the last matching parenthesis

modelnormalize.preprocess(udtryk, funks=[])[source]

test processing expanding dlog,diff,movavg,pct,logit functions

Parameters:
  • udtryk (str) – model we want to do template expansion on

  • funks (list, optional) – list of user defined functions . Defaults to [].

Returns:

None.

has to be changed to (= for when the transition to 3.8 is finished.

modelnormalize.fixleads(eq, check=False)[source]
modelnormalize.normal(ind_o, the_endo='', add_add_factor=True, do_preprocess=True, add_suffix='_A', endo_lhs=True, make_fixable=False, make_fitted=False, eviews='')[source]

normalize an expression g(y,x) = f(y,x) ==> y = F(x,z)

Default find the expression for the first variable on the left hand side (lhs)

The variable - without lags- should not be on rhs.

Parameters:
  • ind_o (str) – input expression, no $ and no frml name just lhs=rhs

  • the_endo (str, optional) – the endogeneous to isolate on the left hans side. if the first variable in the lhs. It shoud be on the left hand side.

  • add_add_factor (bool, optional) – force introduction aof adjustment term, and an expression to calculate it

  • do_preprocess (bool, optional) – DESCRIPTION. preprocess the expression

  • endo_lhs (bool, optional) – If false, accept to normalize for a rhs endogeneous variable

  • make_fixable (bool, optional) – also make this equation exogenizable

  • fitted (bool,optional) – create a fitted equations, without exo and adjustment

preprocessing handels

Returns:

Normalized_frml which will contain the different relevant expressions

Return type:

An instance of the class

modelnormalize.elem_trans(udtryk, df=None)[source]

Handeles expression with @elem