arx.cpp arx.h double double egiw_bestbelow (egiw Eg, egiw Eg0, double Egll, ivec &indeces) egiw_bestbelow egiw Eg egiw Eg0 double Egll ivec & indeces Return the best structure. Eg a copy of GiW density that is being examined Eg0 a copy of prior GiW density before estimation Egll likelihood of the current Eg indeces current indeces best likelihood in the structure below the given one #include"arx.h" usingnamespaceitpp; voidARX::bayes(constvec&dt){ doublelnc; if(frg<1.0){ V*=frg; nu*=frg; if(evalll){ last_lognc=est.lognc(); } } V.opupdt(dt,1.0); nu+=1.0; if(evalll){ lnc=est.lognc(); ll=lnc-last_lognc; last_lognc=lnc; tll+=ll; } } doubleegiw_bestbelow(egiwEg,egiwEg0,doubleEgll,ivec&indeces){//parameterEgisacopy! ldmatVo=Eg._V();//copy ldmatVo0=Eg._V();//copy ldmat&Vp=Eg._V();//pointerintoEg ldmat&Vp0=Eg._V();//pointerintoEg intend=Vp.rows()-1; inti; matLi; matLi0; doublemaxll=Egll; doubletmpll=Egll; doublebelll=Egll; ivectmpindeces; ivecmaxindeces=indeces; cout<<"bb:("<<indeces<<")ll="<<Egll<<endl; //trytoremoveonlyonerv for(i=0;i<end;i++){ //copyoriginal Li=Vo._L(); Li0=Vo0._L(); //removestuff Li.del_col(i+1); Li0.del_col(i+1); Vp.ldform(Li,Vo._D()); Vp0.ldform(Li0,Vo0._D()); tmpll=Eg.lognc()-Eg0.lognc();//likelihoodisdifferenceofnorm.coefs. cout<<"i=("<<i<<")ll="<<tmpll<<endl; // if(tmpll>Egll){//increaseofthelikelihood tmpindeces=indeces; tmpindeces.del(i); //searchforabettermatchinthissubstructure belll=egiw_bestbelow(Eg,Eg0,tmpll,tmpindeces); if(belll>maxll){//bettermatchfound maxll=belll; maxindeces=tmpindeces; } } } indeces=maxindeces; returnmaxll; } ivecARX::structure_est(egiwest0){ ivecind=linspace(1,rv.count()-1); egiw_bestbelow(est,est0,est.lognc()-est0.lognc(),ind); returnind; }