Revision 198, 1.1 kB
(checked in by smidl, 16 years ago)
|
opravy + zavedeni studenta + zakomentovani debug v mergeru
|
-
Property svn:eol-style set to
native
|
Line | |
---|
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=0.1; |
---|
14 | |
---|
15 | //Test constructor |
---|
16 | mat V0 = 0.00001*eye(ord+1); V0(0.0)*= 100; // |
---|
17 | double nu0 = ord+4; |
---|
18 | |
---|
19 | RV thr("{theta_and_r }",vec_1(ord+1)); |
---|
20 | ARX Ar(thr, V0, nu0); |
---|
21 | const epdf& Ar_ep = Ar._epdf(); |
---|
22 | |
---|
23 | //Test estimation |
---|
24 | int ndat = 100; |
---|
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 | |
---|
32 | cout << Ar_ep.mean()<<endl; |
---|
33 | for (t=ord; t<ndat; t++) { |
---|
34 | for(j=0;j<(ord);j++){rgr(j)=Yt(t-j-1);} |
---|
35 | Yt(t) = th*rgr + sqr * NorRNG(); |
---|
36 | |
---|
37 | vec Psi = concat(Yt(t), rgr); |
---|
38 | Ar.bayes(Psi); |
---|
39 | LL(t) = Ar._ll(); |
---|
40 | |
---|
41 | cout << "y: " << Yt(t) << endl; |
---|
42 | mlstudent* Pr = Ar.predictor_student(RV("{y }"),RV("{y1 y2 y3 y4 }")); |
---|
43 | cout << Ar._ll() <<" , " << log(Pr->evalcond(vec_1(Yt(t)),rgr)) <<endl; |
---|
44 | delete Pr; |
---|
45 | } |
---|
46 | cout << Ar_ep.mean()<<endl; |
---|
47 | |
---|
48 | // Test brute-froce structure estimation |
---|
49 | cout << Ar.structure_est(egiw(thr,V0,nu0)) <<endl; |
---|
50 | } |
---|