31 | | double frg = 0.94; |
32 | | |
33 | | ARX P1(thri, V0, nu0, frg); |
34 | | ARX P2(thri, V0, nu0, frg); |
35 | | ARX PG(thrg, V0g, nu0, frg); |
| 32 | double frg = 0.99; |
| 33 | |
| 34 | ARX P1 ( thri, V0, nu0, frg ); |
| 35 | ARX P2 ( thri, V0, nu0, frg ); |
| 36 | ARX PG ( thrg, V0g, nu0, frg ); |
43 | | int Eth1_log = L.add(thri,"P1"); |
44 | | int Eth2_log = L.add(thri,"P2"); |
45 | | int Data_log = L.add(RV("10","{Y U1 U2 }","3","0"), ""); |
46 | | int LL_log = L.add(RV("11","{1 2 G }","3","0"), "LL"); |
47 | | |
48 | | vec Yt(ndat); |
49 | | |
50 | | Yt.set_subvector(0,randn(ord)); //initial values |
51 | | vec rgrg(thg.length()); |
52 | | vec rgri(thri.count()); |
53 | | |
54 | | for (t=2; t<ndat; t++) { |
| 44 | int Eth1_log = L.add ( thri,"P1" ); |
| 45 | int Eth2_log = L.add ( thri,"P2" ); |
| 46 | int Ethg_log = L.add ( thrg,"PG" ); |
| 47 | int Data_log = L.add ( RV ( "{Y U1 U2 }" ), "" ); |
| 48 | int LL_log = L.add ( RV ( "{1 2 G }" ), "LL" ); |
| 49 | |
| 50 | L.init(); |
| 51 | |
| 52 | vec Yt ( ndat ); |
| 53 | |
| 54 | Yt.set_subvector ( 0,randn ( ord ) ); //initial values |
| 55 | vec rgrg ( thg.length() ); |
| 56 | vec rgri ( thri.count() ); |
| 57 | |
| 58 | for ( t=0; t<ndat; t++ ) { |
56 | | rgrg(0)=Yt(t-1); |
57 | | rgrg(1)= sin(t/(40)*pi); |
58 | | rgrg(2)= cos(t/(40)*pi); |
59 | | |
60 | | Yt(t) = thg*rgrg + sqr * NorRNG(); |
61 | | |
62 | | // 1st |
63 | | rgri(0)=Yt(t); |
64 | | rgri(1)=rgrg(1); |
65 | | P1.bayes(rgri); |
66 | | // 2nd |
67 | | rgri(1)=rgrg(2); |
68 | | P2.bayes(rgri); |
69 | | |
70 | | //Global |
71 | | PG.bayes(concat(Yt(t),rgrg)); |
72 | | L.logit(Eth1_log, P1._epdf().mean()); |
73 | | L.logit(Eth2_log, P2._epdf().mean()); |
74 | | L.logit(Data_log, vec_3(Yt(t), rgrg(1), rgrg(2))); |
75 | | L.logit(LL_log, vec_3(P1._ll(), P2._ll(), PG._ll())); |
76 | | L.step(false); |
| 60 | if ( t>0 ) { |
| 61 | rgrg ( 0 ) =Yt ( t-1 ); |
| 62 | rgrg ( 1 ) = pow(sin ( ( t/40.0 ) *pi ),3); |
| 63 | rgrg ( 2 ) = pow(cos ( ( t/40.0 ) *pi ),3); |
| 64 | |
| 65 | Yt ( t ) = thg*rgrg + sqr * NorRNG(); |
| 66 | |
| 67 | // 1st |
| 68 | rgri ( 0 ) =Yt ( t ); |
| 69 | rgri ( 1 ) =Yt ( t-1 ); |
| 70 | rgri ( 2 ) =rgrg ( 1 ); |
| 71 | P1.bayes ( rgri ); |
| 72 | // 2nd |
| 73 | rgri ( 2 ) =rgrg ( 2 ); |
| 74 | P2.bayes ( rgri ); |
| 75 | |
| 76 | //Global |
| 77 | PG.bayes ( concat ( Yt ( t ),rgrg ) ); |
| 78 | |
| 79 | //Merger |
| 80 | } |
| 81 | L.logit ( Eth1_log, P1._epdf().mean() ); |
| 82 | L.logit ( Eth2_log, P2._epdf().mean() ); |
| 83 | L.logit ( Ethg_log, PG._epdf().mean() ); |
| 84 | L.logit ( Data_log, vec_3 ( Yt ( t ), rgrg ( 1 ), rgrg ( 2 ) ) ); |
| 85 | L.logit ( LL_log, vec_3 ( P1._ll(), P2._ll(), PG._ll() ) ); |
| 86 | L.step ( ); |