Changeset 204 for mpdm/merg_pred.cpp

Show
Ignore:
Timestamp:
11/10/08 15:40:29 (16 years ago)
Author:
smidl
Message:

merger is now in logarithms + new merge_test

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • mpdm/merg_pred.cpp

    r198 r204  
    3434        mat V0g = 0.001*eye ( thrg.count() ); V0g ( 0,0 ) *= 10; // 
    3535        double nu0 = ord+6.0; 
    36         double frg = 1.0;//0.99; 
     36        double frg = 0.95; 
    3737 
    3838        ARX P1 ( thri, V0, nu0, frg ); 
     
    4040        ARX PG ( thrg, V0g, nu0, frg ); 
    4141        //Test estimation 
    42         int ndat = 500; 
     42        int ndat = 200; 
    4343        int t; 
    4444 
     
    5151        int Li_Data = L.add ( RV ( "{Y U1 U2 }" ), "" ); 
    5252        int Li_LL   = L.add ( RV ( "{1 2 G }" ), "LL" ); 
    53         int Li_Pred = L.add ( RV ( "{1 2 G ar ge ln}" ), "Pred" ); 
     53        int Li_Pred = L.add ( RV ( "{1 2 G ar ge }" ), "Pred" ); 
    5454 
    5555        L.init(); 
     
    6666        vec PostLLs(3); 
    6767        vec PredLLs_m=zeros(5); 
    68         vec PostLLs_m=zeros(3); 
    6968        ivec ind_r1 = "0 1 3"; 
    7069        ivec ind_r2 = "0 2 3"; 
     
    8483                        // Test predictors 
    8584                        if (t>2){ 
    86                                 mlnorm<ldmat>* P1p = P1.predictor_student(y,concat(ym,u1)); 
    87                                 mlnorm<ldmat>* P2p = P2.predictor_student(y,concat(ym,u2)); 
    88                                 mlnorm<ldmat>* Pgp = PG.predictor_student(y,concat(ym,uu)); 
     85                                mlnorm<ldmat>* P1p = P1.predictor(y,concat(ym,u1)); 
     86                                mlnorm<ldmat>* P2p = P2.predictor(y,concat(ym,u2)); 
     87                                mlnorm<ldmat>* Pgp = PG.predictor(y,concat(ym,uu)); 
    8988                                 
    9089                                Array<mpdf*> A(2); A(0)=P1p;A(1)=P2p; 
    9190                                merger M(A); 
    9291                                enorm<ldmat> g0(concat(yy,uu)); g0.set_parameters("0 0 0 0 ",3*eye(4)); 
    93                                 M.set_parameters(1.2, 100,1); 
     92                                M.set_parameters(10000000.0, 100,1); 
    9493                                M.merge(&g0); 
    9594                                 
     
    9897                                double P2pl = P2p->evalcond(yt,rgr2);    
    9998                                double PGpl = Pgp->evalcond(yt,rgrg);    
    100                                 PredLLs(0) = log(P1pl); PredLLs(1) = log(P2pl); PredLLs(2) = log(PGpl); 
     99                                { 
     100                                        cout << "yt: " << yt << endl; 
     101                                        cout << "yt_1: " << P1p->_epdf().mean() << endl; 
     102                                        cout << "yt_2: " << P2p->_epdf().mean() << endl; 
     103                                        cout << "yt_G: " << P2p->_epdf().mean() << endl; 
     104                                } 
     105                                double cP1pl; 
     106                                double cP2pl; 
    101107                                { 
    102108                                        ARX* Apred = (ARX*)M._Mix()._Coms(0); 
     
    107113                                        mlnorm<ldmat>* cP2p = (mlnorm<ldmat>*)mP2p->condition(y); 
    108114 
    109                                         double cP1pl = cP1p->evalcond(yt,rgr1);  
    110                                         double cP2pl = cP2p->evalcond(yt,rgr2);  
    111                                         PredLLs(3) = log(cP1pl); 
    112                                         PredLLs(4) = log(cP2pl); 
     115                                        cP1pl = cP1p->evalcond(yt,rgr1);         
     116                                        cP2pl = cP2p->evalcond(yt,rgr2);         
     117                                 
     118                                        cout << "ytm1: " << cP1p->_epdf().mean() << endl; 
     119                                        cout << "ytm2: " << cP2p->_epdf().mean() << endl; 
    113120                                } 
    114121 
    115                                 L.logit(Li_Pred, PredLLs_m*frg+ PredLLs); //log-normal 
    116                                 PredLLs_m *=frg; 
    117                                 PredLLs_m += PredLLs; 
     122                                PredLLs *=frg; 
     123                                PredLLs += log(concat(vec_3(P1pl, P2pl, PGpl), vec_2(cP1pl,cP2pl))); 
     124                                L.logit(Li_Pred, PredLLs); //log-normal 
    118125                                 
    119126                                delete P1p;