140 | | <p>Second, if the parameters of a ARX model are not specified, they are automatically named <code>theta</code> and <code>r</code>. Howver, in this case, <code>A1</code> and <code>A2</code> differ in size, hence their random variables differ and can not use the same name. Therefore, we have explicitly used another names (RVs) of the parameters.</p> |
| 140 | <p>Second, if the parameters of a ARX model are not specified, they are automatically named <code>theta</code> and <code>r</code>. However, in this case, <code>A1</code> and <code>A2</code> differ in size, hence their random variables differ and can not use the same name. Therefore, we have explicitly used another names (RVs) of the parameters.</p> |
154 | | <p> Note that for known trajectory of <img class="formulaInl" alt="$ \phi_t $" src="form_186.png"/> the standard ARX estimator can be used if we find a way how to feed the changing <img class="formulaInl" alt="$ \phi_t $" src="form_186.png"/> into it. This is achieved by a trivial extension using inheritance method <a class="el" href="classbdm_1_1BM.html#a6799f4b16a6a59ed58b1d0d6e17116f4" title="Substitute val for rvc.">bdm::BM::condition()</a>. </p> |
| 154 | <p> Note that for known trajectory of <img class="formulaInl" alt="$ \phi_t $" src="form_186.png"/> the standard ARX estimator can be used if we find a way how to feed the changing <img class="formulaInl" alt="$ \phi_t $" src="form_186.png"/> into it. This is achieved by a trivial extension using inheritance method <a class="el" href="classbdm_1_1BM.html#a6799f4b16a6a59ed58b1d0d6e17116f4" title="Substitute val for rvc.">bdm::BM::condition()</a>.</p> |
| 155 | <p>Extension of standard ARX estimator to conditional estimator is implemented as class <a class="el" href="classbdm_1_1ARXfrg.html">bdm::ARXfrg</a>. The only difference from standard ARX is that this object will change its forgetting factor via method ARXfrg::condition(). Existence of this function is assumed by the MPF estimator. Informally, the name 'ARXfrg' means: "if anybody calls your condition(0.9), it tells you new value of forgetting factor".</p> |
| 156 | <p>The MPF estimator is implemented by class <a class="el" href="classbdm_1_1MPF.html" title="Marginalized Particle filter.">bdm::MPF</a>. In the toolbox, it can be constructed as follows: </p> |
| 157 | <div class="fragment"><pre class="fragment">%%%%%% ARX estimator conditioned on frg |
| 158 | |
| 159 | A1.class = <span class="stringliteral">'ARXfrg'</span>; |
| 160 | A1.rv = y; |
| 161 | A1.rgr = RVtimes([y,u],[-3,-1]) ; |
| 162 | A1.options =<span class="stringliteral">'logbounds,logll'</span>; |
| 163 | A1.frg = 0.9; |
| 164 | A1.name = <span class="stringliteral">'A1'</span>; |
| 165 | |
| 166 | %%%%%% Random walk on frg - Dirichlet |
| 167 | phi_pdf.class = <span class="stringliteral">'mDirich'</span>; % random walk on coefficient phi |
| 168 | phi_pdf.rv = RV(<span class="stringliteral">'phi'</span>,2); % 2D random walk - frg is the first element |
| 169 | phi_pdf.k = 0.01; % width of the random walk |
| 170 | phi_pdf.betac = [0.01 0.01]; % stabilizing elememnt of random walk |
| 171 | |
| 172 | %%%%%% Combining estimators in Marginalized particle filter |
| 173 | E.class = <span class="stringliteral">'MPF'</span>; |
| 174 | E.BM = A1; % ARX is the analytical part |
| 175 | E.parameter_pdf = phi_pdf; % Random walk is the parameter evolution model |
| 176 | E.n = 20; % number of particles |
| 177 | E.prior.class = <span class="stringliteral">'eDirich'</span>; % prior on non-linear part |
| 178 | E.prior.beta = [1 1]; % |
| 179 | E.options =<span class="stringliteral">'logbounds,logll'</span>; |
| 180 | E.name = <span class="stringliteral">'MPF'</span>; |
| 181 | |
| 182 | M=estimator(DS,{E}); |
| 183 | </pre></div><p>Here, the configuration structure <code>A1</code> is a description of an ARX model, as used in previous examples, the only difference is in its name 'ARXfrg'.</p> |
| 184 | <p>The configuration structure <code>phi_pdf</code> defines random walk on the forgetting factor. It was chosen as Dirichlet, hence it will produce 2-dimensional vector of <img class="formulaInl" alt="$[\phi, 1-\phi]$" src="form_192.png"/>. The class <code>ARXfrg</code> was designed to read only the first element of its condition. The random walk of type mDirich is: </p> |
| 185 | <p class="formulaDsp"> |
| 186 | <img class="formulaDsp" alt="\[ f(\phi_t|\phi_{t-1}) = Di (\phi_{t-1}/k + \beta_c) \]" src="form_193.png"/> |
| 187 | </p> |
| 188 | <p> where <img class="formulaInl" alt="$ k $" src="form_89.png"/> influences the spread of the walk and <img class="formulaInl" alt="$ \beta_c $" src="form_189.png"/> has the role of stabilizing, to avoid traps of corner cases such as [0,1] and [1,0]. Its influence on the results is quite important.</p> |
| 189 | <p>This example is implemented as bdmtoolbox/tutorial/userguide/frg_example.m Its typical run should look like the following: </p> |
| 190 | <div align="center"> |
| 191 | <img src="frg_example_small.png" alt="frg_example_small.png"/> |