/*--------------------------------------------------------------------------
 * simula.h - definitions/declarations for Simulation class
 *
 *       (C) Jurgen Doornik 1994
 *
 *--------------------------------------------------------------------------*/

#ifndef SIMULA_INCLUDED
#define SIMULA_INCLUDED

class Simulation
{
    decl m_mT;                              // sample size matrix
    decl m_mxT;                            // maximum sample size
    decl m_cRep;                        // number of replications
    decl m_cRejected;          // number of replications rejected
    decl m_mPvalue;         // row vector with p-values for tests
    decl m_asPvalue;              // array with names of p-values
    decl m_asPvalue1;				  // two-sided p-values names
    decl m_asTest;                   // array with names of tests
    decl m_asCoef;            // array with names of coefficients
    decl m_mTrueParam;      // actual parameter values for coeffs
    decl m_fCommon;      // TRUE if same seed for each experiment
    decl m_dSeed;              // reset to dSeed if fCommon==TRUE
    decl m_mCoefMean;                     // mean of coefficients
    decl m_mCoefMeanSq;        // mean of squares of coefficients
    decl m_mReject;                      // rejection frequencies
    decl m_mTestVal;   // sorted test values for last sample size
    decl m_mCritVal;  // critical values corresponding to mPvalue
    decl m_mCritVal1;  // critical values corresponding left tail
    decl m_mCoefVal;    // coefficient values of each replication
	decl m_bRecursive;// TRUE: do recursively, report only last T
	decl m_mPvalueExp;           // expanded version of m_mPvalue
	decl m_mIdxOneSided, m_mIdxTwoSided;// type of critical value
	decl m_bStore;// TRUE: accumulate results for saving/graphing
	decl m_mCoefMeanRec;    // recursive MC: mean of coefficients
	decl m_mCoefMeanSqRec;    // recursive MC: coeff. mean square
	decl m_mRejectRec;	   // recursive MC: rejection frequencies
	decl m_mCritValRec;	         // recursive MC: critical values
	decl m_mTestMomRec;			    // recursive MC: test moments
	decl m_iPlotRep; // plot every # reps; 0: only last, -1: none

    Simulation(const mT, const mxT,                // constructor
        const cRep, const fCommon, const dSeed,
        const mPvalue,const mTrueParam); 
	
    virtual Generate(const iRep,          // generate replication
        const cT, const mxT);
    virtual GetCoefficients();       // return coefficient values
    virtual GetPvalues();             // return p-values of tests
    virtual GetTestStatistics();        // return test statistics
	virtual Plot(const iRep, const iT); // optional plot function
    virtual IsTwoSided();//<> or 0-1 vector with 1 when two-sided
	SaveIn7(const sFilename);	   // save the simulation results
	SaveRecIn7(const sFilename);	// save the recursive results
    SetCoefNames(const asNames); // install names of coefficients
	SetPlotRep(const iPlotRep);	// set plot replication step size
    SetTestNames(const asNames);        // install names of tests
	SetRecursive(const bRecursive);	   // switch recursive on/off
	SetStore(const bStore);   // switch storage of results on/off
    Simulate();                  // do the simulation experiments
	
	setPvalues(const mPvalue);	 // sets p-values to be tested at
	doFirstRep(const abTests, const abPvalues, const abCoefs);
	report(const t, const bTests, const bPvalues, const bCoefs);
	stoRec(const i, const bTests, const bPvalues, const bCoefs);
};

#endif /* SIMULA_INCLUDED */
