104 | | Second, if the parameters of a ARX model are not specified, they are automatically named \c theta and \c r. Howver, in this case, \c A1 and \c A2 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. |
| 104 | Second, if the parameters of a ARX model are not specified, they are automatically named \c theta and \c r. However, in this case, \c A1 and \c A2 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. |
| 124 | The MPF estimator is implemented by class bdm::MPF. In the toolbox, it can be constructed as follows: |
| 125 | \code |
| 126 | %%%%%% ARX estimator conditioned on frg |
| 127 | |
| 128 | A1.class = 'ARXfrg'; |
| 129 | A1.rv = y; |
| 130 | A1.rgr = RVtimes([y,u],[-3,-1]) ; |
| 131 | A1.options ='logbounds,logll'; |
| 132 | A1.frg = 0.9; |
| 133 | A1.name = 'A1'; |
| 134 | |
| 135 | %%%%%% Random walk on frg - Dirichlet |
| 136 | phi_pdf.class = 'mDirich'; % random walk on coefficient phi |
| 137 | phi_pdf.rv = RV('phi',2); % 2D random walk - frg is the first element |
| 138 | phi_pdf.k = 0.01; % width of the random walk |
| 139 | phi_pdf.betac = [0.01 0.01]; % stabilizing elememnt of random walk |
| 140 | |
| 141 | %%%%%% Combining estimators in Marginalized particle filter |
| 142 | E.class = 'MPF'; |
| 143 | E.BM = A1; % ARX is the analytical part |
| 144 | E.parameter_pdf = phi_pdf; % Random walk is the parameter evolution model |
| 145 | E.n = 20; % number of particles |
| 146 | E.prior.class = 'eDirich'; % prior on non-linear part |
| 147 | E.prior.beta = [1 1]; % |
| 148 | E.options ='logbounds,logll'; |
| 149 | E.name = 'MPF'; |
| 150 | |
| 151 | M=estimator(DS,{E}); |
| 152 | |
| 153 | \endcode |
| 154 | |
| 155 | Here, the configuration structure \c A1 is a description of an ARX model, as used in previous examples, the only difference is in its name 'ARXfrg'. |
| 156 | |
| 157 | The configuration structure \c phi_pdf defines random walk on the forgetting factor. It was chosen as Dirichlet, hence it will produce 2-dimensional vector of \f$[\phi, 1-\phi]\f$. The class \c ARXfrg was designed to read only the first element of its condition. |
| 158 | The random walk of type mDirich is: |
| 159 | \f[ f(\phi_t|\phi_{t-1}) = Di (\phi_{t-1}/k + \beta_c) \f] |
| 160 | where \f$ k \f$ influences the spread of the walk and \f$ \beta_c \f$ has the role of stabilizing, to avoid traps of corner cases such as [0,1] and [1,0]. |
| 161 | Its influence on the results is quite important. |
| 162 | |
| 163 | This example is implemented as bdmtoolbox/tutorial/userguide/frg_example.m |
| 164 | Its typical run should look like the following: |
| 165 | \image html frg_example_small.png |
| 166 | \image latex frg_example.png "Typical run of tutorial/userguide/frg_example.m" width=\linewidth |
| 167 | |
| 168 | Note: error bars in this case are not directly comparable with those of previous examples. The MPF class implements the qbounds function as minimum and maximum of bounds in the condidered set (even if its weight is extreemly small). Hence, the bounds of the MPF are probably larger than it should be. Nevertheless, they provide great help when designing and tuning algorithms. |