Revision 100, 0.9 kB
(checked in by smidl, 16 years ago)
|
test arx
|
-
Property svn:eol-style set to
native
|
Rev | Line | |
---|
[100] | 1 | #include <estim/arx.h> |
---|
| 2 | #include <stat/libEF.h> |
---|
| 3 | using namespace itpp; |
---|
| 4 | |
---|
| 5 | //These lines are needed for use of cout and endl |
---|
| 6 | using std::cout; |
---|
| 7 | using std::endl; |
---|
| 8 | |
---|
| 9 | int main() { |
---|
| 10 | // Setup model |
---|
| 11 | vec th("0.8 -0.3 0.4 0.01"); |
---|
| 12 | int ord=th.length(); |
---|
| 13 | double sqr=1; |
---|
| 14 | |
---|
| 15 | //Test constructor |
---|
| 16 | mat V0 = 0.001*eye(ord+1); V0(0.0)*= 10; // |
---|
| 17 | double nu0 = ord+1; |
---|
| 18 | |
---|
| 19 | RV thr("1","{theta_and_r }",vec_1(th.length()+1),"0"); |
---|
| 20 | ARX Ar(thr, V0, nu0); |
---|
| 21 | epdf& Ar_ep = Ar._epdf(); |
---|
| 22 | |
---|
| 23 | //Test estimation |
---|
| 24 | int ndat = 1000; |
---|
| 25 | int t,j; |
---|
| 26 | vec Yt(ndat); |
---|
| 27 | vec LL(ndat); |
---|
| 28 | Yt.set_subvector(0,randn(ord)); //initial values |
---|
| 29 | vec rgr(ord); |
---|
| 30 | |
---|
| 31 | cout << Ar_ep.mean()<<endl; |
---|
| 32 | for (t=ord; t<ndat; t++) { |
---|
| 33 | for(j=0;j<(ord);j++){rgr(j)=Yt(t-j-1);} |
---|
| 34 | Yt(t) = th*rgr + sqr * NorRNG(); |
---|
| 35 | |
---|
| 36 | vec Psi = concat(Yt(t), rgr); |
---|
| 37 | Ar.bayes(Psi); |
---|
| 38 | LL(t) = Ar._ll(); |
---|
| 39 | } |
---|
| 40 | cout << Ar_ep.mean()<<endl; |
---|
| 41 | |
---|
| 42 | // Test brute-froce structure estimation |
---|
| 43 | cout << Ar.structure_est(egiw(thr,V0,nu0)) <<endl; |
---|
| 44 | } |
---|