Changeset 1166 for library/bdm

Show
Ignore:
Timestamp:
08/27/10 17:05:39 (14 years ago)
Author:
smidl
Message:

samplepred for ARX

Location:
library/bdm/estim
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • library/bdm/estim/arx.cpp

    r1064 r1166  
    77 
    88    BMEF::bayes_weighted(yt,cond,w); //potential discount scheduling 
    9  
    109    double lnc; 
    1110    //cache 
     
    7271} 
    7372 
     73vec ARX::samplepred(const vec &cond) const{ 
     74        mat M; 
     75        chmat R; 
     76        est.sample_mat(M,R); 
     77         
     78        vec tmp; 
     79        if (dimc>0){ 
     80                if (have_constant){ 
     81                        tmp = M*concat(cond,1.0); 
     82                } else { 
     83                        tmp = M*cond; 
     84                } 
     85        } else { 
     86                tmp = zeros(dimy); 
     87        } 
     88        tmp += R._Ch().T()*randn(dimy); 
     89        return tmp; 
     90} 
     91 
    7492void ARX::flatten ( const BMEF* B , double weight =1.0) { 
    7593    const ARX* A = dynamic_cast<const ARX*> ( B ); 
     
    114132    est.mean_mat ( mu, R ); //mu = 
    115133    //correction for student-t  -- TODO check if correct!! 
    116     //R*=nu/(nu-2); 
     134    R*=posterior()._nu()/(posterior()._nu()-2); 
    117135    if (mu.cols()>0) {// nonempty egiw 
    118136        mat p_mu = mu.T() * ext_rgr;    //the result is one column 
  • library/bdm/estim/arx.h

    r1131 r1166  
    8888        bayes_weighted ( yt, cond, 1.0 ); 
    8989    }; 
    90     double logpred ( const vec &yt, const vec &cond ) const; 
    91     void flatten ( const BMEF* B , double weight ); 
     90        double logpred ( const vec &yt, const vec &cond ) const; 
     91        vec samplepred (  const vec &cond ) const; 
     92        void flatten ( const BMEF* B , double weight ); 
    9293    //! Conditioned version of the predictor 
    9394    enorm<ldmat>* epredictor ( const vec &rgr ) const;