Estimation : DsgeLikelihood 

This document outlines 1st draft design of C++ implementation of DsgeLikelihood based closely on Matalb Dynare implementation with some addiitional featrures such as parameter description structure aimed at future handling  sub-samples in Kalman filter for regime changes.

Function parameters are still in a flux 
DsgeLikelihood 

Figure 1 : DsgeLikelihood

DsgeLikelihood 
Type:		public Package 
Status:		Proposed.  Version 1.0.  Phase 1.0. 
Package:	Logical Model
Details: 		Created on 27/08/2009 21:10:15. Modified on 27/08/2009 21:10:15. 

DsgeLikelihood 
Type:		public Class 
Status:		Proposed.  Version 1.0.  Phase 1.0. 
Package:	DsgeLikelihood
Details: 		Created on 27/08/2009 21:39:19. Modified on 21/09/2009 14:22:31. 

calculates likelihood using kalman

Connections 
•	Aggregation link from class Estimation <Estimation>
•	Aggregation link to class MexStructParam
•	Aggregation link to class MexStruct
•	Aggregation link to class KordpDynare<k_order_pert>
•	Aggregation link to class KalmanTask<Kalman>

DsgeLikelihood Attributes 
Attribute	Type	Notes	
 likelihood 	private :
double 	 	
 vll 	private :
vector<double>*  	 	
 kordModel 	private :
KordpDynare  	 	
 bkt 	private :
BasicKalmanTask  	 	
 ukt 	private :
KalmanUniTask 	Univariate 	
 Q 	private :
GeneralMatrix& 	 	
 T 	private :
GeneralMatrix& 	 	
 R 	private :
GeneralMatrix& 	 	
 Pstar 	private :
GeneralMatrix& 	 	
 Pinf 	private :
GeneralMatrix& 	 	
 Z 	private :
GeneralMatrix& 	 	
 H 	private :
GeneralMatrix& 	 	
 data 	private :
GeneralMatrix& 	 	
 parameterDescription; 	private :
GeneralParams 	 	
 xparam1 	private :
Vector& 	 	
 SteadyState 	private :
Vector& 	 	
 presampleStart 	private :
int 	 	
 constant 	private :
Vector& 	 	

DsgeLikelihood Methods 
Method	Type	Notes	
 dynare_resolve(MexStructParam&params) ()  	private: int  	 	
 CalcLikelihood(MexStructParam&params) ()  	private: double  	 	
 SolveDRkOrderPert(MexStructParam&params) ()  	private: void  	 	
 SetDRModel(MexStructParam&params) ()  	private: MexStructParam&  	Former dr1 driver 	
 InitiateKalmanMatrices(MexStructParam&params) ()  	private: void  	 	
 updateQHMparams(MexStructParam&params) ()  	private: void  	Updates Q and H Kalman matrices 	
 DataPreparation(MexStructParam&params) ()  	private: void  	data detrending and filtering 	
 priordens(MexStructParam&params) ()  	private: double  	 	
 disclyap_fast(const GeneralMatrix &G, const GeneralMatrix & V, GeneralMatrix &X, double tol) ()  	private: void  	 	
 getLikVector() ()  	public: vector<double>&  	vector of log likelihoods for each Kalman step 	
 getLik() ()  	public: double  	log likelihood as summ of Vll for each Kalman step 	

MexStruct 
Type:		public Class
		Extends: GeneralParams.  
Status:		Proposed.  Version 1.0.  Phase 1.0. 
Package:	DsgeLikelihood
Details: 		Created on 20/09/2009 20:50:47. Modified on 20/09/2009 21:26:05. 

contains all the parameters from M_, options_ and bayestopt_ (the latter needs to be rethought), needed by the C++ estimation functions. 

This class should be initialized at the instanciation of the top class (here 
dynare_estimation++) from M_ and options_ pointers passed as arguments

Connections 
•	Aggregation link from class DsgeLikelihood
•	Aggregation link to class StructBaseNameMap
•	Aggregation link to class MexStructParam
•	Generalization link to class GeneralParams<Estimation>

MexStruct Attributes 
Attribute	Type	Notes	
 parStructBase 	private :
vector <int>  	 	
 parStruct 	private :
vector <const mxArray*>  	 	
 parNamStructMap 	private :
map <string, int>  	 	
 numParStruct 	private const :
int 	 	
  structName 	private const :
string 	 	

MexStruct Methods 
Method	Type	Notes	
 getStructField ()  	public: MexStructParam&  	 	
 getMxField ()  	private: mxArray*   	 	
 getMxFieldStruct ()  	private: StructBaseNameMap*   	 	
 UpdateMexField ()  	public: void  	 	

MexStructParam 
Type:		public Class
		Extends: GeneralParams.  
Status:		Proposed.  Version 1.0.  Phase 1.0. 
Package:	DsgeLikelihood
Details: 		Created on 20/09/2009 20:50:31. Modified on 20/09/2009 21:30:58. 

Conatains Matalb structure references mxArray and can be nested so to have several recursive references to Matlab sub-structure as its content.

Connections 
•	Aggregation link from class DsgeLikelihood
•	Aggregation link from class MexStructParam
•	Aggregation link from class MexStruct
•	Generalization link to class GeneralParams<Estimation>

MexStructParam Attributes 
Attribute	Type	Notes	
 parStruct 	private const :
mxArray*  	 	
 parStructParent 	private const :
GeneralParams*  	 	
 structName 	private const :
string 	 	

MexStructParam Methods 
Method	Type	Notes	
 getStructField ()  	public: MexStructParam&  	 	
 getMxField ()  	private: mxArray*   	 	

StructBaseNameMap 
Type:		public Class 
Status:		Proposed.  Version 1.0.  Phase 1.0. 
Package:	DsgeLikelihood
Details: 		Created on 20/09/2009 23:21:44. Modified on 20/09/2009 23:26:33. 

Connections 
•	Aggregation link from class MexStruct

StructBaseNameMap Attributes 
Attribute	Type	Notes	
 structName 	public :
char* 	 	
 baseName 	private :
char* 	Matlab base:caller, global, base