| | 76 | <hr/><a name="_details"></a><h2>Detailed Description</h2> |
| | 77 | <p>Linear Autoregressive model with Gaussian noise. </p> |
| | 78 | <p>Regression of the following kind: </p> |
| | 79 | <p class="formulaDsp"> |
| | 80 | <img class="formulaDsp" alt="\[ y_t = \theta_1 \psi_1 + \theta_2 + \psi_2 +\ldots + \theta_n \psi_n + r e_t \]" src="form_28.png"/> |
| | 81 | </p> |
| | 82 | <p> where unknown parameters <code>rv</code> are <img class="formulaInl" alt="$[\theta r]$" src="form_29.png"/>, regression vector <img class="formulaInl" alt="$\psi=\psi(y_{1:t},u_{1:t})$" src="form_30.png"/> is a known function of past outputs and exogeneous variables <img class="formulaInl" alt="$u_t$" src="form_31.png"/>. Distrubances <img class="formulaInl" alt="$e_t$" src="form_32.png"/> are supposed to be normally distributed: </p> |
| | 83 | <p class="formulaDsp"> |
| | 84 | <img class="formulaDsp" alt="\[ e_t \sim \mathcal{N}(0,1). \]" src="form_33.png"/> |
| | 85 | </p> |
| | 86 | <p>See <a class="el" href="tut_arx.html">Theory of ARX model estimation</a> for mathematical treatment.</p> |
| | 87 | <p>The easiest way how to use the class is: </p> |
| | 88 | <div class="fragment"><pre class="fragment"><span class="preprocessor">#include "<a class="code" href="arx_8h.html" title="Bayesian Filtering for generalized autoregressive (ARX) model.">estim/arx.h</a>"</span> |
| | 89 | <span class="keyword">using namespace </span>bdm; |
| | 90 | |
| | 91 | <span class="comment">// estimation of AR(0) model</span> |
| | 92 | <span class="keywordtype">int</span> main() { |
| | 93 | <span class="comment">//prior</span> |
| | 94 | mat V0 = 0.00001 * eye ( 2 ); |
| | 95 | V0 ( 0, 0 ) = 0.1; <span class="comment">//</span> |
| | 96 | ARX Ar; |
| | 97 | Ar.set_statistics ( 1, V0 ); <span class="comment">//nu is default (set to have finite moments)</span> |
| | 98 | <span class="comment">// forgetting is default: 1.0</span> |
| | 99 | mat Data = concat_vertical ( randn ( 1, 100 ), ones ( 1, 100 ) ); |
| | 100 | Ar.bayesB ( Data ); |
| | 101 | |
| | 102 | cout << <span class="stringliteral">"Expected value of Theta is: "</span> << Ar.posterior().mean() << endl; |
| | 103 | } |
| | 104 | </pre></div><dl class="todo"><dt><b><a class="el" href="todo.html#_todo000001">Todo:</a></b></dt><dd>sort out constant terms - bayes should accept vec without additional 1s </dd></dl> |
| 229 | | <hr/><a name="_details"></a><h2>Detailed Description</h2> |
| 230 | | <p>Linear Autoregressive model with Gaussian noise. </p> |
| 231 | | <p>Regression of the following kind: </p> |
| 232 | | <p class="formulaDsp"> |
| 233 | | <img class="formulaDsp" alt="\[ y_t = \theta_1 \psi_1 + \theta_2 + \psi_2 +\ldots + \theta_n \psi_n + r e_t \]" src="form_28.png"/> |
| 234 | | </p> |
| 235 | | <p> where unknown parameters <code>rv</code> are <img class="formulaInl" alt="$[\theta r]$" src="form_29.png"/>, regression vector <img class="formulaInl" alt="$\psi=\psi(y_{1:t},u_{1:t})$" src="form_30.png"/> is a known function of past outputs and exogeneous variables <img class="formulaInl" alt="$u_t$" src="form_31.png"/>. Distrubances <img class="formulaInl" alt="$e_t$" src="form_32.png"/> are supposed to be normally distributed: </p> |
| 236 | | <p class="formulaDsp"> |
| 237 | | <img class="formulaDsp" alt="\[ e_t \sim \mathcal{N}(0,1). \]" src="form_33.png"/> |
| 238 | | </p> |
| 239 | | <p>See <a class="el" href="tut_arx.html">Theory of ARX model estimation</a> for mathematical treatment.</p> |
| 240 | | <p>The easiest way how to use the class is: </p> |
| 241 | | <div class="fragment"><pre class="fragment"><span class="preprocessor">#include "<a class="code" href="arx_8h.html" title="Bayesian Filtering for generalized autoregressive (ARX) model.">estim/arx.h</a>"</span> |
| 242 | | <span class="keyword">using namespace </span>bdm; |
| 243 | | |
| 244 | | <span class="comment">// estimation of AR(0) model</span> |
| 245 | | <span class="keywordtype">int</span> main() { |
| 246 | | <span class="comment">//prior</span> |
| 247 | | mat V0 = 0.00001 * eye ( 2 ); |
| 248 | | V0 ( 0, 0 ) = 0.1; <span class="comment">//</span> |
| 249 | | ARX Ar; |
| 250 | | Ar.set_statistics ( 1, V0 ); <span class="comment">//nu is default (set to have finite moments)</span> |
| 251 | | <span class="comment">// forgetting is default: 1.0</span> |
| 252 | | mat Data = concat_vertical ( randn ( 1, 100 ), ones ( 1, 100 ) ); |
| 253 | | Ar.bayesB ( Data ); |
| 254 | | |
| 255 | | cout << <span class="stringliteral">"Expected value of Theta is: "</span> << Ar.posterior().mean() << endl; |
| 256 | | } |
| 257 | | </pre></div><dl class="todo"><dt><b><a class="el" href="todo.html#_todo000001">Todo:</a></b></dt><dd>sort out constant terms - bayes should accept vec without additional 1s </dd></dl> |