Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

PREESTMODEL Class Reference

Pre-est. model. More...

#include <models.h>

Inheritance diagram for PREESTMODEL:

MODEL MARKOVMODEL SVMODEL SVCIR SVEOU SVEOU1 List of all members.

Public Member Functions

void setdata (matrix Y)
 sets the data and calculates f_j(data).

matrix estfunc (matrix par)
 the estimating function MS(2.1)

double twonorm_estfunc (matrix par)
 Returns two-norm of estimating function with parameters given by par.

matrix sumH (matrix par)
 MS(3.11) disregarding A(theta).

double twonorm_sumH (matrix par)
 Returns two-norm of _approximated_ estimating function with parameters given by par.

void set_Mbar_terms (double lambda)
 calculates and sets Mbar_terms.

void set_iter_Mbar (bool val)
 Determines wether Mbar (time-consuming calculation) should be calculated.

void set_sumH_est (double x)
 Sets pre-estimate of sumH to x.

void calculate_X ()
 Calculates matrix $\mathbf{X}$ with $j$th row containing observations $(x_{s},\ldots,x_{s+1-q}).$.

matrix get_X ()
unsigned get_N ()
 Returns the number of inner-functions in pbef.

virtual double Zval (unsigned j, long i, long k, matrix const &Y)
 Z_{jk}^{(i)}, j=0,...,N-1, k=1,...,q, i.

double prediction (unsigned j, long i, matrix const &Y)
 Returns $\breve{\pi}_{j+1}^{(i-1)}(\theta) = \breve{\alpha}_{(j+1)0}(\theta) + \breve{\alpha}_{j+1}(\theta)^TZ_{j+1}^{(i-1)}$. Here $Z_j^{(i-1)}$ is our actual data.


Public Attributes

bool printdebug
 boolean to determine wether to print debug-info or not


Protected Member Functions

virtual void calculate_Z ()
void calculate_a ()
 Calculates the terms $a_{j,0},\ldots,a_{j,q}$ used in calculation of projections $\pi_j$.

void calculate_b ()
 Calculates $b_j(\theta) = \left(COV_\theta(Z_{j1}^{(s)},f_j(X_{s+1})),\ldots, COV_\theta(Z_{jq}^{(s)},f_j(X_{s+1})))\right)^T $.

void calculate_C ()
 Calculates covariance matrix of Z.

void calculate_EHH ()
 The first term in the expression of $\overline{M}$.

void calculate_Mbar ()
 Calculation of $\overline{M}$.

matrix calculate_Dalpha ()
 Partial derivatives of $\breve{\alpha}$.

matrix calculate_Cbar ()
 $\overline{C} = diag(\tilde{C}_1,\ldots,\tilde{C}_N)$ where

void calculate_Astar ()
 Calculates $A_n^*(\theta)$ derived from Mbar,Dalpha and Cbar.


Protected Attributes

safevector< matrix > fdata
 matrix holding f_j(data), j=1,...,N.

unsigned N
 The number of inner-functions, $f_1,...,f_N$, in the estimating function.

functionvector ifuncs
 inner-functions in estimating-function G.

long q
 The lag-length in the prediction.

long s
 Summation start-index, $s$, of estimating function.

long MbarNOS
 The number of simulations used in calculating Mbar.

long l
 summation-start in the expresion of Mbar.

unsigned numsimul
 Number of simulated variables used in determination of $\breve{a}_j(\theta), C_j(\theta)$, etc.

matrix X
 For fixed $s$ the $numsimul\times q$ matrix with $j$th row given by observations $x_{s},\ldots, x_{s+1-q})$.

matrix Xnext
matrix X1
bool iter_Mbar
 Boolean that determines wether to calculate the time-consuming Mbar in current iteration.

matrix simY
 simulated Y for calculations.

matrix Astar
 $A_n^*(\theta)$

safevector< matrix > Z
 On index j: holds simulations of $Z_{j1},\ldots,Z_{jq}$, i.e. $f_j$ mapped onto matrix X.

safevector< matrix > EtildeZ
safevector< matrix > fXnext
 On index j: Holds simulations of $f_j(X_{s+1})$.

safevector< matrix > fX1
 On index j: Holds simulations of $f_j(X_{1})$.

safevector< matrix > a
 Terms used in projection. $\breve{\alpha}_j$. MS(2.4).

safevector< double > a0
 $\breve{\alpha}_{j0}(\theta)=E_\theta(f_j(X_1)) - \breve{\alpha}_j(\theta)^TE_\theta(Z_j^{(s)})$. MS(2.5)

safevector< matrix > b
 defined (as b_j) in MS on the top of page 9.

safevector< matrix > C
 Covariance matrix of Z_j (as C_j). See MS on the top of page 9.

matrix EHH
 EHH in Mbar (MS(3.14)).

matrix varH
 columnvector containing the simulated value of var(H_i) in the i'th row.

double sumH_est
 estimate of theta, based on sumH.

int Mbar_terms
 The number of terms in the expression of Mbar.

matrix Mbar
 MS(3.14).


Detailed Description

Pre-est. model.

inherits from MODEL

Definition at line 111 of file models.h.


Member Function Documentation

void PREESTMODEL::calculate_EHH  )  [protected]
 

The first term in the expression of $\overline{M}$.

Iteration no. i

OBS: {} has already been calculated, so we can use prediction directly without calling calculate_a();

Definition at line 239 of file models.cpp.

References EHH, ifuncs, l, MbarNOS, N, prediction(), q, s, MODEL::simulate(), simY, varH, and Zval().

Referenced by calculate_Mbar().

00239                                 {
00240 
00241   long m=l;
00242   if(q>l) m=q;
00243   
00244   matrix H(N*(q+1)); // Simulation of H
00245   matrix M(N*(q+1), N*(q+1)); 
00246 
00247   simY=simulate(MbarNOS+1);
00248 
00249   for(long i=m; i<MbarNOS; i++) {
00250     //!   Iteration no. i
00251 
00252     for (unsigned j=0; j<N; j++) {
00253       double (*fj)(double) = ifuncs[j];
00254       for (long k=0; k<=q; k++) {
00255         //! OBS: \breve{\alpha} has already been calculated, so we can use prediction directly without calling calculate_a();
00256         double res = fj(simY.get(i))-prediction(j,i-1,simY);
00257         if (k>0) // Pr. defintion: Z_{j0}^{(i-1)} = 1
00258           res *= Zval(j,i-1,k,simY); 
00259         // index (j,k) is placed in H at location (j-1)*(q+1)+k (We index from 0).
00260         unsigned Hindex = j*(q+1)+k;
00261         H.set(res,Hindex);
00262       }
00263     } // Now we have calculated H^(i)(theta)
00264 
00265 
00266     // Next we calculate the mean*normalization.
00267     for (unsigned r=0; r<N*(q+1); r++) {
00268       for (unsigned s=0; s<N*(q+1); s++) {     
00269         M.add(H.get(r)*H.get(s),r,s); // Here we add (H*H^t)_(rs) = (H)_r*(H)_s to the matrix M.
00270       }
00271     }
00272   }
00273 
00274   double w = (double)1/(double)(MbarNOS - m +1);  
00275   EHH = M*w; 
00276 
00277   qmove(1,25);
00278   varH.newsize(N*(q+1));
00279   
00280   for (unsigned k=0; k<N*(q+1); k++)                                
00281     varH.set(EHH.get(k,k),k);                        // the diagonal of E((H^r)(H^r)^T) is the
00282                                                      // variances of the coordinates of H^r.
00283                                                      // This is the reason why we break the
00284                                                      // calculation of Mbar up into two pieces.
00285 }


The documentation for this class was generated from the following files:
Generated on Tue Feb 14 16:05:52 2006 for estfunc by doxygen 1.3.6