Commit 341e6a29 authored by Houtan Bastani's avatar Houtan Bastani
Browse files

remove trailing whitespace and replace tabs with spaces

parent bd626b07
......@@ -92,7 +92,7 @@
//-- must equal to one, the actual number of free dimensions is one less. --//
//-----------------------------------------------------------------------------//
//== Free Dirichet dimensions for state_variable[2] ==//
2 2
2 2
//-----------------------------------------------------------------------------//
//-- The jth restriction matrix is n_states x free[j]. Each row of the --//
......
This diff is collapsed.
......@@ -24,8 +24,8 @@ typedef struct TMarkovStateVariable_tag
int nobs;
int nstates;
//=== State vector ===
int* S;
//=== State vector ===
int* S;
//=== Transition matrix
TMatrix Q;
......@@ -37,29 +37,29 @@ typedef struct TMarkovStateVariable_tag
//=== Prior information ===
TMatrix Prior; // Dirichlet prior on the columns of Q. Must be nstates x nstates with positive elements.
TVector *Prior_b; // Dirichlet prior on the quasi-free parameters b
TVector Prior_B; // Prior_b stacked into single vector
TVector Prior_B; // Prior_b stacked into single vector
//=== Lag information encoding ===
int nlags_encoded; // Number of lags encoded in the restrictions
int nlags_encoded; // Number of lags encoded in the restrictions
int nbasestates; // Number of base states nbasestates^(nlags_encoded) = nstates
int** lag_index; // nstates x (nlags_encoded + 1) lag_index[i][j] is the value of the jth lag when the overall state is k
//=== Restrictions ===
int* FreeDim; //
int* FreeDim; //
int** NonZeroIndex; // nstates x nstates
TMatrix MQ; // nstates x nstates
//=== Parent Markov state variable ===
struct TMarkovStateVariable_tag *parent; // either parent state variable or pointer to itself
//=== Multiple state variables ===
int n_state_variables;
struct TMarkovStateVariable_tag **state_variable;
TMatrix *QA;
TVector *ba;
TVector *Prior_ba;
int** SA;
int** Index;
struct TMarkovStateVariable_tag **state_variable;
TMatrix *QA;
TVector *ba;
TVector *Prior_ba;
int** SA;
int** Index;
//=== Control variables ===
int UseErgodic;
......@@ -91,7 +91,7 @@ int** CreateLagIndex(int nbasestates, int nlags, int nstates);
TMatrix ConvertBaseTransitionMatrix(TMatrix T, TMatrix bT, int nlags);
//=== Data extractions routines ===
TMatrix GetTransitionMatrix_SV(TMatrix Q, TMarkovStateVariable *sv);
TMatrix GetTransitionMatrix_SV(TMatrix Q, TMarkovStateVariable *sv);
TMatrix GetBaseTransitionMatrix_SV(TMatrix Q, TMarkovStateVariable *sv);
#define GetTransitionProbability_SV(sv,j,i) (ElementM((sv)->Q,N_E2I[i],N_E2I[j]))
#define DecomposeIndexInd_SV(sv,i,j) ((sv)->state_variable[j]->N_I2E[(sv)->Index[N_E2I[i]][j]])
......@@ -131,7 +131,7 @@ int** CreateTranslationMatrix_Flat(int **states, TMarkovStateVariable *sv);
/*******************************************************************************/
/******************************** ThetaRoutines ********************************/
/*******************************************************************************/
typedef struct
typedef struct
{
//=== Computes ln(P(y[t] | Y[t-1], Z[t], theta, s[t] = s)) ===
PRECISION (*pLogConditionalLikelihood)(int s, int t, struct TStateModel_tag *model);
......@@ -152,7 +152,7 @@ typedef struct
int (*pNumberFreeParametersTheta)(struct TStateModel_tag*);
void (*pConvertFreeParametersToTheta)(struct TStateModel_tag*, PRECISION*);
void (*pConvertThetaToFreeParameters)(struct TStateModel_tag*, PRECISION*);
//=== Notification routines ===
void (*pStatesChanged)(struct TStateModel_tag*);
void (*pThetaChanged)(struct TStateModel_tag*);
......@@ -162,10 +162,10 @@ typedef struct
//=== Allows for initialization of data structures before forward recursion ===
void (*pInitializeForwardRecursion)(struct TStateModel_tag*);
//=== Permutes the elements of Theta.
//=== Permutes the elements of Theta.
int (*pGetNormalization)(int*, struct TStateModel_tag*);
int (*pPermuteTheta)(int*, struct TStateModel_tag*);
} ThetaRoutines;
//=== Constructors ===
......@@ -179,7 +179,7 @@ typedef struct TStateModel_tag
TMarkovStateVariable *sv;
ThetaRoutines *routines;
void *theta;
//=== Control variables ===
int ValidForwardRecursion;
int UseLogFreeParametersQ;
......@@ -190,7 +190,7 @@ typedef struct TStateModel_tag
TVector* Z; // Z[t][i] = P(s[t] = i | Y[t-1], Z[t-1], theta, Q) 0 < t <= T and 0 <= i < nstates
PRECISION L; // L = Sum(ln(Sum(P(y[t] | Y[t-1], Z[t], theta, s[t]) * P(s[t] | Y[t-1], Z[t-1], theta, Q),0 <= s[t] < nstates)),0 < t <= T)
//=== Simulation status fields
//=== Simulation status fields
int n_degenerate_draws; // counter for number of degenerate draws
int *states_count; // integer array of length nstates to count the number of each of the states
......@@ -282,7 +282,7 @@ void ConvertQToFreeParameters(TStateModel *model, PRECISION *f);
void ConvertFreeParametersToQ(TStateModel *model, PRECISION *f); // needs to be modified
void ConvertQToLogFreeParameters(TStateModel *model, PRECISION *f); // needs to be modified
void ConvertLogFreeParametersToQ(TStateModel *model, PRECISION *f); // needs to be modified
#define NumberFreeParametersTheta(model) ((model)->routines->pNumberFreeParametersTheta(model))
#define NumberFreeParametersTheta(model) ((model)->routines->pNumberFreeParametersTheta(model))
void ConvertFreeParametersToTheta(TStateModel *model, PRECISION *f);
#define ConvertThetaToFreeParameters(model,f) ((model)->routines->pConvertThetaToFreeParameters(model,f))
......@@ -302,7 +302,7 @@ TVector* ErgodicAll_SVD(TMatrix P);
TVector DrawDirichletVector(TVector Q, TVector Alpha);
TVector* DrawIndependentDirichletVector(TVector *Q, TVector *A);
PRECISION LogDirichlet_pdf(TVector Q, TVector Alpha);
PRECISION LogIndependentDirichlet_pdf(TVector *Q, TVector *Alpha);
PRECISION LogIndependentDirichlet_pdf(TVector *Q, TVector *Alpha);
int DrawDiscrete(TVector p);
PRECISION AddLogs(PRECISION a, PRECISION b);
PRECISION AddScaledLogs(PRECISION x, PRECISION a, PRECISION y, PRECISION b);
......@@ -332,7 +332,7 @@ typedef struct TParameters_tag
int (*pNumberFreeParametersTheta)(struct TStateModel_tag*);
void (*pConvertFreeParametersToTheta)(struct TStateModel_tag*, PRECISION*);
void (*pConvertThetaToFreeParameters)(struct TStateModel_tag*, PRECISION*);
// Obsolete fields retained for backward compatibility
void *p;
......@@ -343,10 +343,10 @@ void FreeParameters(TParameters *p);
TParameters* CreateParameters(PRECISION (*)(int,int,struct TStateModel_tag*), // pLogConditionalLikelihood
void (*)(void*), // Destructor for parameters
PRECISION (*)(struct TStateModel_tag*), // pLogPrior
int (*)(struct TStateModel_tag*), // pNumberFreeModelSpecificParameters
void (*)(struct TStateModel_tag*, PRECISION*), // pConvertFreeParametersToModelSpecificParameters
void (*)(struct TStateModel_tag*, PRECISION*), // pConvertModelSpecificParametersToFreeParameters
PRECISION (*)(struct TStateModel_tag*), // pLogPrior
int (*)(struct TStateModel_tag*), // pNumberFreeModelSpecificParameters
void (*)(struct TStateModel_tag*, PRECISION*), // pConvertFreeParametersToModelSpecificParameters
void (*)(struct TStateModel_tag*, PRECISION*), // pConvertModelSpecificParametersToFreeParameters
void (*)(struct TStateModel_tag*), // pDrawParameters
void *); // pointer to user defined parameters
......@@ -384,7 +384,7 @@ TStateModel* CreateStateModel(TMarkovStateVariable *sv, TParameters *p);
The following set of fields are set for both types.
===============================================================================
int UseErgodic
Uses the ergodic distribution if non-zero and use the uniform distribution
Uses the ergodic distribution if non-zero and use the uniform distribution
otherwise.
int nstates
......@@ -393,8 +393,8 @@ TStateModel* CreateStateModel(TMarkovStateVariable *sv, TParameters *p);
int nobs
Number of observations. Always positive.
int* S
S[t] is the state at time t, for 0 <= t <= nobs. S is created via a call
int* S
S[t] is the state at time t, for 0 <= t <= nobs. S is created via a call
to dw_CreateArray_int(). It is guaranteed that 0 <= S[t] < nstates.
TMatrix Q
......@@ -402,7 +402,7 @@ TStateModel* CreateStateModel(TMarkovStateVariable *sv, TParameters *p);
struct TMarkovStateVariable_tag *parent
Parent of the Markov state variable. If the Markov state variable has no
parent, then parent is a pointer to the structure itself.
parent, then parent is a pointer to the structure itself.
int n_state_variables
Number of state variables. Will be equal to one for single Markov state
......@@ -414,18 +414,18 @@ TStateModel* CreateStateModel(TMarkovStateVariable *sv, TParameters *p);
n_state_variables is equal to one, then state_variable[0] is a pointer to
the structure itself. Care must be taken to ensure that infinite loops do
not result when transversing through state variables. When creating a
mulitple Markov state variable via a call to the routine
mulitple Markov state variable via a call to the routine
CreateMarkovStateVariable_Multiple(), the last argument which is a pointer
to a pointer to a TMarkovStateVariable must have been created with
to a pointer to a TMarkovStateVariable must have been created with
dw_CreateArray_pointer(n_state_variables,(void (*)(void*))FreeMarkovStateVariable);
dw_CreateArray_pointer(n_state_variables,(void (*)(void*))FreeMarkovStateVariable);
Furthermore, the structure receives ownership of this argument and is
Furthermore, the structure receives ownership of this argument and is
responsible for its freeing.
int** Index
This is a nstates x n_state_variables rectangular array of integers. State
s corresponds to state_variable[i] being equal to Index[s][i].
This is a nstates x n_state_variables rectangular array of integers. State
s corresponds to state_variable[i] being equal to Index[s][i].
int** SA
An array of integer pointers of length n_state_variables. The pointers SA[i]
......@@ -442,7 +442,7 @@ TStateModel* CreateStateModel(TMarkovStateVariable *sv, TParameters *p);
i = j + dw_DimA(state_variable[0]->ba) + ... + dw_DimA(state_variable[k-1]->ba)
TVector* Prior_ba
For single Markov state variables, Prior_ba[i] = Prior_b[i]. For multiple
For single Markov state variables, Prior_ba[i] = Prior_b[i]. For multiple
state variables Prior_ba[i] = state_variable[k]->Prior_ba[j] where
i = j + dw_DimA(state_variable[0]->Prior_ba) + ... + dw_DimA(state_variable[k-1]->Prior_ba)
......@@ -460,15 +460,15 @@ TStateModel* CreateStateModel(TMarkovStateVariable *sv, TParameters *p);
&(b[k][i])=&B[FreeDim[0] + ... + FreeDim[k-1] + i])
The elements of b[k] are non-negative and their sum equals one up to
The elements of b[k] are non-negative and their sum equals one up to
DimV(b[k])*MACHINE_EPSILON.
TMatrix Prior
Prior Dirichlet parameters for Q.
TVector *Prior_b
The Dirichlet prior parametrs for b. Array of vectors of length
DimA(FreeDim). The element Prior_b[k] is of length FreeDim[k].
The Dirichlet prior parametrs for b. Array of vectors of length
DimA(FreeDim). The element Prior_b[k] is of length FreeDim[k].
Non-standard memory management is used so that
&(Prior_b[k][i])=&B[FreeDim[0] + ... + FreeDim[k-1] + i])
......@@ -493,7 +493,7 @@ TStateModel* CreateStateModel(TMarkovStateVariable *sv, TParameters *p);
Coefficients for the elements of Q in terms of the free parameters B.
int nlags_encoded; // Number of lags encoded in the restrictions
int nlags_encoded; // Number of lags encoded in the restrictions
int nbasestates; // Number of base states nbasestates^(nlags_encoded) = nstates
int** lag_index; // nstates x (nlags_encoded + 1) lag_index[i][j] is the value of the jth lag when the overall state is k
......@@ -503,15 +503,15 @@ TStateModel* CreateStateModel(TMarkovStateVariable *sv, TParameters *p);
===============================================================================
Normalization:
In general, a permutation of the states, together with the corresponding
In general, a permutation of the states, together with the corresponding
permutation of the rows and columns of the transition matrix and the model
dependent parameters theta, does not change the value of the likelihood
dependent parameters theta, does not change the value of the likelihood
function and so presents a normalization problem. However, some permutations
of the states are not permissible in that they may violate the restrictions
placed on the transition matrix or restrictions on the model dependent
parameters. Furthermore, even if a permutation did not cause a violation of
any restrictions, a non-symmetric prior on the model dependent parameters
could cause the value of the likelihood to change.
placed on the transition matrix or restrictions on the model dependent
parameters. Furthermore, even if a permutation did not cause a violation of
any restrictions, a non-symmetric prior on the model dependent parameters
could cause the value of the likelihood to change.
********************************************************************************/
......
......@@ -6,9 +6,9 @@
matrices in native ascii format.
*/
TMarkovStateVariable* ReadMarkovSpecification_SV(FILE *f_in, char *idstring, int nobs);
int WriteMarkovSpecification_SV(FILE *f_out, TMarkovStateVariable *sv, char *idstring);
int ReadTransitionMatrices_SV(FILE *f_in, TMarkovStateVariable* sv, char *header, char *idstring);
int WriteTransitionMatrices_SV(FILE *f_out, TMarkovStateVariable* sv, char *header, char *idstring);
int WriteMarkovSpecification_SV(FILE *f_out, TMarkovStateVariable *sv, char *idstring);
int ReadTransitionMatrices_SV(FILE *f_in, TMarkovStateVariable* sv, char *header, char *idstring);
int WriteTransitionMatrices_SV(FILE *f_out, TMarkovStateVariable* sv, char *header, char *idstring);
int ReadBaseTransitionMatrices_SV(FILE *f_out, TMarkovStateVariable *sv, char *header, char *idstring);
int WriteBaseTransitionMatrices_SV(FILE *f_out, TMarkovStateVariable *sv, char *header, char *idstring);
......@@ -16,7 +16,7 @@ int WriteBaseTransitionMatricesFlat_SV(FILE *f_out, TMarkovStateVariable *sv, ch
void WriteBaseTransitionMatricesFlat_Headers_SV(FILE *f_out, TMarkovStateVariable* sv, char *idstring);
/*
Routines for reading/writing Markov state variables and transition matrices
Routines for reading/writing Markov state variables and transition matrices
from TStateModel. Calls base routines.
*/
TMarkovStateVariable* ReadMarkovSpecification(FILE *f, char *filename);
......
......@@ -96,7 +96,7 @@ int main(int nargs, char **args)
printf("Elapsed Time: %d seconds\n",end_time - begin_time);
// Reset parametrers
if (!ReadTransitionMatrices((FILE*)NULL,cmd->parameters_filename_actual,cmd->parameters_header_actual,model)
if (!ReadTransitionMatrices((FILE*)NULL,cmd->parameters_filename_actual,cmd->parameters_header_actual,model)
|| !Read_VAR_Parameters((FILE*)NULL,cmd->parameters_filename_actual,cmd->parameters_header_actual,model))
printf("Unable to reset parameters after tuning\n");
......@@ -107,15 +107,15 @@ int main(int nargs, char **args)
DrawAll(model);
if (count == check)
{
check+=period;
printf("%d iterations completed out of %d\n",count,burn_in);
}
{
check+=period;
printf("%d iterations completed out of %d\n",count,burn_in);
}
}
end_time=(int)time((time_t*)NULL);
printf("Elapsed Time: %d seconds\n",end_time - begin_time);
ResetMetropolisInformation(p);
// Simulation
printf("Simulating - %d draws\n",iterations);
for (check=period, output=thinning, count=1; count <= iterations; count++)
......@@ -134,10 +134,10 @@ int main(int nargs, char **args)
}
if (count == check)
{
check+=period;
printf("%d(%d) iterations completed out of %d(%d)\n",count,thinning,iterations,thinning);
}
{
check+=period;
printf("%d(%d) iterations completed out of %d(%d)\n",count,thinning,iterations,thinning);
}
}
end_time=(int)time((time_t*)NULL);
printf("Elapsed Time: %d seconds\n",end_time - begin_time);
......
This diff is collapsed.
......@@ -51,7 +51,7 @@ typedef struct
TVector** bplus;
//====== Priors ======
TVector zeta_a_prior; //
TVector zeta_a_prior; //
TVector zeta_b_prior; //
TMatrix* A0_prior; // A0_prior[j] = constant parameter variance of the normal prior on the jth column of A0
TMatrix* Aplus_prior; // Aplus_prior[j] = constant parameter variance of the normal prior on the jth column of Aplus
......@@ -63,7 +63,7 @@ typedef struct
//====== Sims-Zha specification parameters and workspace ======
TVector** lambda; // nvars x n_coef_states[j] array of nvars-dimensional vectors
TVector* constant; // nvars x n_coef_states[j] -- constant[j][k] == psi[j][npre - 1 + k]
TVector* constant; // nvars x n_coef_states[j] -- constant[j][k] == psi[j][npre - 1 + k]
TVector* psi; // nvars x (npre - 1 + n_coef_states[j])
PRECISION lambda_prior; // prior variance of each element of lambda
PRECISION inverse_lambda_prior;
......@@ -83,7 +83,7 @@ typedef struct
TMatrix* inverse_b0_prior; // inverse_b0_prior = U'[j]*Inverse(A0_prior[j])*U[j]
TMatrix* inverse_bplus_prior; // inverse_bplus_prior = V'[j]*Inverse(Aplus_prior[j])*V[j]
TVector log_abs_det_A0; // log(abs(det(A0[k])))
TVector log_abs_det_A0; // log(abs(det(A0[k])))
PRECISION*** A0_dot_products; // A0_dot_products[t][j][k] = Y'[t] * A0[j][k]
PRECISION*** Aplus_dot_products; // Aplus_dot_products[t][j][k] = X'[t] * Aplus[j][k]
......@@ -107,10 +107,10 @@ typedef struct
int valid_log_abs_det_A0; // Invalid after A0 changes
int valid_dot_products; // Invalid after A0 or Aplus changes
int valid_state_dependent_fields; // Invalid after states change
int valid_state_dependent_fields_previous; // Initially invalid.
int valid_parameters; // Initially invalid. Valid after successful read or draw of parameters.
// Parametes are invalid if Zeta is negative or if they do not satisfy
// the normalization.
int valid_state_dependent_fields_previous; // Initially invalid.
int valid_parameters; // Initially invalid. Valid after successful read or draw of parameters.
// Parametes are invalid if Zeta is negative or if they do not satisfy
// the normalization.
//=== Data ===
TVector* Y; // Y[t] nvar vector of time t data for 1 <= t <= T
......@@ -122,14 +122,14 @@ typedef struct
void FreeTheta_VAR(T_VAR_Parameters *p);
ThetaRoutines* CreateRoutines_VAR(void);
T_VAR_Parameters* CreateTheta_VAR(int flag, int nvars, int nlags, int nexg, int nstates, int nobs, // Specification and Sizes
int **coef_states, int **var_states, // Translation Tables
TMatrix *U, TMatrix *V, TMatrix *W, // Restrictions
TMatrix Y, TMatrix X); // Data
int **coef_states, int **var_states, // Translation Tables
TMatrix *U, TMatrix *V, TMatrix *W, // Restrictions
TMatrix Y, TMatrix X); // Data
int** CreateTranslationMatrix_Flat(int **states, TMarkovStateVariable *sv);
void SetPriors_VAR(T_VAR_Parameters *theta, TMatrix* A0_prior, TMatrix* Aplus_prior, TVector zeta_a_prior, TVector zeta_b_prior);
void SetPriors_VAR_SimsZha(T_VAR_Parameters *theta, TMatrix* A0_prior, TMatrix* Aplus_prior, TVector zeta_a_prior,
TVector zeta_b_prior, PRECISION lambda_prior);
void SetPriors_VAR_SimsZha(T_VAR_Parameters *theta, TMatrix* A0_prior, TMatrix* Aplus_prior, TVector zeta_a_prior,
TVector zeta_b_prior, PRECISION lambda_prior);
TStateModel* CreateConstantModel(TStateModel *model);
......@@ -244,7 +244,7 @@ The model:
y(t)' * A0(s(t)) = x(t)' * Aplus(s(t)) + epsilon(t)' * Inverse(Xi(s(t)))
where
where
y(t) is nvars x 1
x(t) is npre x 1
x(t)=[y(t-1),...,y(t-p),z(t)], where z(t) is exogenous
......@@ -253,18 +253,18 @@ The model:
Aplus(k) is npre x nvars
Xi(k) is an nvars x nvars diagonal matrix
s(t) is an integer with 0 <= s(t) < nstates
Furthermore
Furthermore
A0(j,k) = U(j) * b0(j,k)
Aplus(j,k) = V(j) * bplus(j,k) - W(j) * A0(j,k)
and
and
Zeta(j,k) = Xi(j,k)*Xi(j,k)
where
A0(j,k) is the jth column of A0(k)
Aplus(j,k) is the jth column of A0(k)
Xi(j,k) is the jth diagonal element of Xi(k)
......@@ -277,7 +277,7 @@ The model:
Sims-Zha Specification:
This specification imposes that r(j) == npre, V(j) is the identity matrix, and
W(j) is equal to a npre x nvars diagonal matrix with minus ones along the
W(j) is equal to a npre x nvars diagonal matrix with minus ones along the
diagonal. Further restrictions are imposed of the form.
bplus(j,k) = f(psi(j),lambda(j,k))
......@@ -292,8 +292,8 @@ Sims-Zha Specification:
f(a,b) = diag(vec(a))
Random Walk Specification:
This specification imposes that W(j) is equal to a npre x nvars diagonal
matrix with minus ones along the diagonal. Though it is not imposed, we
This specification imposes that W(j) is equal to a npre x nvars diagonal
matrix with minus ones along the diagonal. Though it is not imposed, we
usually want Aplus(j,k) to satisfy linear restrictions implicit in the
matrix V(j). This means that W(j) must be in the span of V(j) and hence
(I - V(j)*V'(j))*W(j) = 0.
......@@ -318,46 +318,46 @@ Prior:
---------------------------------------------------------------------------------
TVector** A0
The length of A0 is nvars. The vector A0[j][k] is the jth column of A0 when
the jth coefficient state variable is equal to k. Note that when the Markov
state variable is equal to s, the jth coefficient state variable is equal to
The length of A0 is nvars. The vector A0[j][k] is the jth column of A0 when
the jth coefficient state variable is equal to k. Note that when the Markov
state variable is equal to s, the jth coefficient state variable is equal to
coef_states[j][s]. The number of distinct values for the jth coefficient state
variable is equal to the dimension of A0[j]. This field is created with
dw_CreateArray_array() and freed with dw_FreeArray().
TVector** b0
TVector** b0
The length of b0 is nvars. The vector b0[j][k] consists of the free parameters
in the jth column of A0 when the jth coefficient state variable is equal to k.
The dimension of b0[j][k] does not vary across k. Note that when the Markov
state variable is equal to s, the jth coefficient state variable is equal to
coef_states[j][s]. The dimension of b0[j] is equal to the dimension of A0[j].
This field is created with dw_CreateArray_array() and freed with
in the jth column of A0 when the jth coefficient state variable is equal to k.
The dimension of b0[j][k] does not vary across k. Note that when the Markov
state variable is equal to s, the jth coefficient state variable is equal to
coef_states[j][s]. The dimension of b0[j] is equal to the dimension of A0[j].
This field is created with dw_CreateArray_array() and freed with
dw_FreeArray().
TVector** Aplus
The length of Aplus is nvars. The vector Aplus[j][k] is the jth column of
Aplus when the jth coefficient state variable is equal to k. Note that when
the Markov state variable is equal to s, the jth coefficient state variable is
equal to coef_states[j][s]. The dimension of Aplus[j] is equal to the
dimension of A0[j]. This field is created with dw_CreateArray_array() and
The length of Aplus is nvars. The vector Aplus[j][k] is the jth column of
Aplus when the jth coefficient state variable is equal to k. Note that when
the Markov state variable is equal to s, the jth coefficient state variable is
equal to coef_states[j][s]. The dimension of Aplus[j] is equal to the
dimension of A0[j]. This field is created with dw_CreateArray_array() and
freed with dw_FreeArray().
TVector** bplus
The length of bplus is nvars. The vector bplus[j][k] consists of the free
The length of bplus is nvars. The vector bplus[j][k] consists of the free
parameters in the jth column of Aplus when the jth coefficient state variable
is equal to k. The dimension of bplus[j][k] does not vary across k. Note that
when the Markov state variable is equal to s, the jth coefficient state
variable is equal to coef_states[j][s]. The dimension of bplus[j] is equal to
the dimension of A0[j]. This field is created with dw_CreateArray_array() and
is equal to k. The dimension of bplus[j][k] does not vary across k. Note that
when the Markov state variable is equal to s, the jth coefficient state
variable is equal to coef_states[j][s]. The dimension of bplus[j] is equal to
the dimension of A0[j]. This field is created with dw_CreateArray_array() and
freed with dw_FreeArray().
PRECISION** Zeta
The length of Zeta is nvars. The value of Zeta[j][k] is the square of the
value of the jth diagonal element of Xi when the jth variance state variable is
equal to k. Note that the the Markov state variable is equal to s, the jth
variance state variable is equal to var_states[j][s]. The number of distinct
values for the jth variance state variable is equal to the dimension of
Zeta[j]. This field is created with dw_CreateArray_array() and freed with
The length of Zeta is nvars. The value of Zeta[j][k] is the square of the
value of the jth diagonal element of Xi when the jth variance state variable is
equal to k. Note that the the Markov state variable is equal to s, the jth
variance state variable is equal to var_states[j][s]. The number of distinct
values for the jth variance state variable is equal to the dimension of
Zeta[j]. This field is created with dw_CreateArray_array() and freed with
dw_FreeArray().
TVector** delta
......@@ -373,27 +373,27 @@ TVector* psi
=============================== State Translation ===============================
int* n_var_states
An integer array of dimension nvars. The value of n_var_states[j] is the
int* n_var_states
An integer array of dimension nvars. The value of n_var_states[j] is the
number of variance states for column j.
int** var_states
An integer array of dimension nvars by nstates. The value of var_states[j][k]
is the value of the variance state for column j when the overall Markov state
variable is equal to k. It is used as an index into Xi[j]. It must be the
case that
An integer array of dimension nvars by nstates. The value of var_states[j][k]
is the value of the variance state for column j when the overall Markov state
variable is equal to k. It is used as an index into Xi[j]. It must be the
case that
0 <= var_states[j][k] < n_var_states[j].
int* n_coef_states
An integer arrary of dimension nvars. The value of n_coef_states[j] is the
int* n_coef_states
An integer arrary of dimension nvars. The value of n_coef_states[j] is the
number of coefficient states for column j.
int** coef_states
An integer array of dimension nvar by nstates. The value of coef_states[j][k]
is the value of the coefficient state for column j when the overall Markov
state variable is equal to k. It is used as an index into A0[j], b0[j],
Aplus[j] or bplus[j]. It must be the case that
An integer array of dimension nvar by nstates. The value of coef_states[j][k]
is the value of the coefficient state for column j when the overall Markov
state variable is equal to k. It is used as an index into A0[j], b0[j],
Aplus[j] or bplus[j]. It must be the case that
0 <= coef_states[j][k] < n_coef_states[j].
......@@ -401,29 +401,29 @@ int n_A0_states
The number of distinct values for the matrix A0.
int* A0_states
An integer array of dimension nstates. The value of A0_states[k] is the value
An integer array of dimension nstates. The value of A0_states[k] is the value
of the state variable controlling A0 when the value of the overall Markov state
variable is k. It is used as an index into the vector log_abs_det_A0. It must
be the case that
variable is k. It is used as an index into the vector log_abs_det_A0. It must
be the case that
0 <= A0_states[k] < n_A0_states.
0 <= A0_states[k] < n_A0_states.
int** A0_column_states
An integer array of dimension nvars by n_A0_states. The value of
A0_column_states[j][k] is the value of the coefficient state for column j when
value of the state variable controlling the matrix A0 is k. It is used as an
index into A0[j]. It must be the case that
An integer array of dimension nvars by n_A0_states. The value of
A0_column_states[j][k] is the value of the coefficient state for column j when
value of the state variable controlling the matrix A0 is k. It is used as an
index into A0[j]. It must be the case that
0 <= A0_column_states[j][k] < n_coef_states[j].
================================= Normalization =================================
For 0 <= k < n_A0_states, the contemporaneous coefficient matrix A[k] is formed.
For 0 <= j < nvars and 0 <= k < n_A0_states, the number
For 0 <= k < n_A0_states, the contemporaneous coefficient matrix A[k] is formed.
For 0 <= j < nvars and 0 <= k < n_A0_states, the number
e[j]*Inverse(A[k])*Target[j][A0_column_states[j][k]]
is computed. If this number is negative, then the sign of
is computed. If this number is negative, then the sign of
A0[j][A0_column_states[j][k]]
......
......@@ -77,16 +77,16 @@ static FILE* OpenFile_VARio(FILE *f, char *filename)
Returns:
A pointer to a valid TStateModel upon success and null pointer upon failure.
Upon failure, the routine prints an error message if USER_ERR is a verbose
error and terminates if USER_ERR is a terminal error. The terminal errors
and verbose errors can be set with dw_SetTerminalErrors() and
dw_SetVerboseErrors().
Upon failure, the routine prints an error message if USER_ERR is a verbose
error and terminates if USER_ERR is a terminal error. The terminal errors
and verbose errors can be set with dw_SetTerminalErrors() and
dw_SetVerboseErrors().