Commit b16a1f91 by Houtan Bastani

### next small change, still testing the CI

parent 0fcd79b0
 ... ... @@ -603,8 +603,9 @@ the return value, ``terms``. Each cell in the return value is comprised of a pair of elements: the root node of the sub-tree representing the additive node and the sign preceding this node (``1`` or ``-1``). Given the equation we want to estimate (shown here from ``Smets_Wouters_2007.mod`` as a reminder), ``Smets_Wouters_2007.mod`` as a reminder): .. include:: sw2007/Smets_Wouters_2007.mod :code: ... ... @@ -625,13 +626,78 @@ Hence, in this case, 4 nodes of ``terms`` contain ``BinaryOpNode``'s (corresponding to the binary operation ``*``) and one term contains a ``VariableNode``. To understand how the terms are stored, one need only look at the following output for the first term, ``crpiMcrpiXcrr*pinf``: .. code-block:: text >> terms terms = 1x5 cell array {1x2 cell} {1x2 cell} {1x2 cell} {1x2 cell} {1x2 cell} >> terms{1} ans = 1x2 cell array {1x1 struct} {[1]} >> terms{1}{1} ans = struct with fields: node_type: 'BinaryOpNode' op: '*' arg1: [1x1 struct] arg2: [1x1 struct] >> terms{1}{1}.arg1 ans = struct with fields: node_type: 'VariableNode' name: 'pinf' type: 'endogenous' lag: 0 >> terms{1}{1}.arg2 ans = struct with fields: node_type: 'VariableNode' name: 'crpiMcrpiXcrr' type: 'parameter' lag: 0 Here, the second element of ``terms{1}`` is ``1`` as it is not preceded by a minus sign. The node itself is a ``BinaryOpNode`` as it represents the multiplication of an endogenous variable (the first argument of the node) and a parameter (the second argument of the node). .. note:: The elements of ``terms`` are not necessarily in the same order as written in the equation in the ``.mod`` file. This is because, for efficiency reasons (e.g. node sharing), the AST created by the preprocessor does not guarantee this ordering. preprocessor does not guarantee this ordering. By the same token, the elements of a node are not guaranteed to be in the same order as they appear in the ``.mod`` file, as you can see above where the first argument of the ``BinaryOpNode`` in ``terms{1}{1}`` is the endogenous variable ``pinf`` whereas ``pinf`` appears second in the multiplication as written in the ``.mod`` file: ``crpiMcrpiXcrr*pinf``. Now that we have ``terms`` set, we can enter the loop in the main function of ``parse_ols_style_equation.m`` that constructs the regressor matrix ``X``: Now that we have ``terms`` set, we can construct the regressor matrix ``X`` by entering the loop on line 75 of ``parse_ols_style_equation.m``: .. code-block:: MATLAB :linenos: inline ... ... @@ -715,10 +781,11 @@ Now that we have ``terms`` set, we can enter the loop in the main function of X = [X Xtmp]; end When the loop starts, certain variables are set. ``Xtmp`` is where we will construct the regressor column to be appended to ``X`` at the end of each loop. ``node_to_parse`` and ``node_sign`` are simply the corresponding parts of the pair stored in each ``terms`` cell, as described above. Entering the loop, we set 3 variables: ``Xtmp``, ``node_to_parse``, and ``node_sign``. ``Xtmp`` is where we will construct the regressor column to be appended to ``X`` at the end of each loop. ``node_to_parse`` and ``node_sign`` are simply the corresponding parts of the pair stored in each ``terms`` cell, as described above. With these variables set, we take different actions, depending on the type of node encountered in ``node_to_parse``. The following subsections explain those ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!