SWZ: remove extra whitespace
parent
248cc388af
commit
a5ed818758
|
@ -742,11 +742,11 @@ int ReadBaseTransitionMatricesFlat_SV(FILE *f_in, TMarkovStateVariable *sv)
|
|||
FreeMatrix(Q);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// Scale the columns of Q - loose requirement on sumation to one
|
||||
for (j=sv->nbasestates-1; j >= 0; j--)
|
||||
{
|
||||
for (sum=0.0, i=sv->nbasestates-1; i >= 0; i--)
|
||||
for (sum=0.0, i=sv->nbasestates-1; i >= 0; i--)
|
||||
if (ElementM(Q,i,j) < 0.0)
|
||||
{
|
||||
FreeMatrix(Q);
|
||||
|
@ -761,7 +761,7 @@ int ReadBaseTransitionMatricesFlat_SV(FILE *f_in, TMarkovStateVariable *sv)
|
|||
dw_UserError("Transition matrix columns must sum to one.");
|
||||
return 0;
|
||||
}
|
||||
for (sum=1.0/sum, i=sv->nbasestates-1; i >= 0; i--)
|
||||
for (sum=1.0/sum, i=sv->nbasestates-1; i >= 0; i--)
|
||||
ElementM(Q,i,j)*=sum;
|
||||
}
|
||||
|
||||
|
|
|
@ -2398,8 +2398,8 @@ void Update_lambda_psi_from_bplus(T_VAR_Parameters *p)
|
|||
forecast : horizon x nvars matrix or null pointer
|
||||
horizon : positive integer - forecast horizon
|
||||
initial : initial value of predetermined variables.
|
||||
shocks : array of length horizon of shocks or null pointer. If null
|
||||
pointer, then the shocks are all zero. Each vector is of length
|
||||
shocks : array of length horizon of shocks or null pointer. If null
|
||||
pointer, then the shocks are all zero. Each vector is of length
|
||||
nvar.
|
||||
S : array of length horizon. S[t] is the state at time T+1+t.
|
||||
model : pointer to valid TStateModel structure.
|
||||
|
@ -2408,7 +2408,7 @@ void Update_lambda_psi_from_bplus(T_VAR_Parameters *p)
|
|||
Computes forecast
|
||||
|
||||
Returns:
|
||||
The matrix forecast upon success and null upon failure. If forecast is
|
||||
The matrix forecast upon success and null upon failure. If forecast is
|
||||
null, then it created.
|
||||
*/
|
||||
TMatrix forecast_base(TMatrix forecast, int horizon, TVector initial, TVector *shocks, int *S, TStateModel *model)
|
||||
|
@ -2455,7 +2455,7 @@ TMatrix forecast_base(TMatrix forecast, int horizon, TVector initial, TVector *s
|
|||
}
|
||||
|
||||
/*
|
||||
For 1 <= k < h, y[k][i] is null if the ith coordinate of y(t0+1+k) is
|
||||
For 1 <= k < h, y[k][i] is null if the ith coordinate of y(t0+1+k) is
|
||||
unrestricted and is its value otherwise. In general, t0 is the last index for
|
||||
which we have full information. It must be the case that t0 <= nobs.
|
||||
*/
|
||||
|
@ -2570,7 +2570,7 @@ TMatrix forecast_base(TMatrix forecast, int horizon, TVector initial, TVector *s
|
|||
/* } */
|
||||
|
||||
/*
|
||||
|
||||
|
||||
*/
|
||||
/* TVector* dw_state_space_mean_unconditional_forecast(TVector *F, int h, int t0, TStateModel *model) */
|
||||
/* { */
|
||||
|
@ -3580,7 +3580,7 @@ TMatrix MakeA0(TMatrix A0, int s, T_VAR_Parameters *p)
|
|||
|
||||
/*
|
||||
Assumes:
|
||||
A0 : Matrix array of length n_states or null pointer. A0[s] is either
|
||||
A0 : Matrix array of length n_states or null pointer. A0[s] is either
|
||||
p->nvars x p->nvars matrix or null pointer
|
||||
*/
|
||||
TMatrix* MakeA0_All(TMatrix *A0, T_VAR_Parameters *p)
|
||||
|
@ -3634,7 +3634,7 @@ TMatrix MakeAplus(TMatrix Aplus, int k, T_VAR_Parameters *p)
|
|||
|
||||
/*
|
||||
Assumes:
|
||||
Aplus : Matrix array of length n_states or null pointer. Aplus[s] is either
|
||||
Aplus : Matrix array of length n_states or null pointer. Aplus[s] is either
|
||||
p->npre x p->nvars matrix or null pointer
|
||||
*/
|
||||
TMatrix* MakeAplus_All(TMatrix *Aplus, T_VAR_Parameters *p)
|
||||
|
@ -3684,7 +3684,7 @@ TMatrix MakeZeta(TMatrix Zeta, int k, T_VAR_Parameters *p)
|
|||
|
||||
/*
|
||||
Assumes:
|
||||
Zeta : Matrix array of length n_states or null pointer. Zeta[s] is either
|
||||
Zeta : Matrix array of length n_states or null pointer. Zeta[s] is either
|
||||
p->vars x p->nvars matrix or null pointer
|
||||
*/
|
||||
TMatrix* MakeZeta_All(TMatrix *Zeta, T_VAR_Parameters *p)
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
model : point to valid TStateModel structure
|
||||
|
||||
Results:
|
||||
Computes and prints to the file f_out the requested percentiles for forecasts
|
||||
Computes and prints to the file f_out the requested percentiles for forecasts
|
||||
of the observables.
|
||||
|
||||
Returns:
|
||||
|
@ -84,7 +84,7 @@ int forecast_percentile(FILE *f_out, TVector percentiles, int draws, FILE *poste
|
|||
{
|
||||
// Draw time T regime
|
||||
m=DrawDiscrete(init_prob);
|
||||
|
||||
|
||||
// Draw regimes from time T+1 through T+h inclusive
|
||||
for (j=0; j < h; j++)
|
||||
{
|
||||
|
@ -138,7 +138,7 @@ ERROR_EXIT:
|
|||
model : point to valid TStateModel/T_MSStateSpace structure
|
||||
|
||||
Results:
|
||||
Computes and prints to the file f_out the requested percentiles for forecasts
|
||||
Computes and prints to the file f_out the requested percentiles for forecasts
|
||||
of the observables.
|
||||
|
||||
Returns:
|
||||
|
@ -146,10 +146,10 @@ ERROR_EXIT:
|
|||
|
||||
Notes:
|
||||
The regime at time T is drawn from the filtered probabilities at time t, and
|
||||
is set to s there after.
|
||||
is set to s there after.
|
||||
|
||||
*/
|
||||
int forecast_percentile_regime(FILE *f_out, TVector percentiles, int draws,
|
||||
int forecast_percentile_regime(FILE *f_out, TVector percentiles, int draws,
|
||||
FILE *posterior_file, int s, int T, int h, TStateModel *model)
|
||||
{
|
||||
T_VAR_Parameters *p;
|
||||
|
@ -238,54 +238,54 @@ ERROR_EXIT:
|
|||
|
||||
|
||||
/*
|
||||
Attempt to set up model from command line. Command line options are the
|
||||
Attempt to set up model from command line. Command line options are the
|
||||
following
|
||||
|
||||
-ft <filename tag>
|
||||
If this argument exists, then the following is attempted:
|
||||
specification file name = est_final_<tag>.dat
|
||||
output file name = ir_<tag>_regime_<k>.dat
|
||||
parameters file name = est_final_<tag>.dat
|
||||
parameters file name = est_final_<tag>.dat
|
||||
header = "Posterior mode: "
|
||||
|
||||
|
||||
-fs <filename>
|
||||
If this argument exists, then the specification file name is <filename>.
|
||||
If this argument exists, then the specification file name is <filename>.
|
||||
The argument -fs takes precedence over -ft.
|
||||
|
||||
-fp <filename>
|
||||
If this argument exists, then the parameters file name is <filename>. The
|
||||
argument -fp takes precedence over -ft. The default value is the filename
|
||||
If this argument exists, then the parameters file name is <filename>. The
|
||||
argument -fp takes precedence over -ft. The default value is the filename
|
||||
associated with the argument -fs.
|
||||
|
||||
-ph <header>
|
||||
If this argument exists, then the header for the parameters file is
|
||||
If this argument exists, then the header for the parameters file is
|
||||
<header>. The default value is "Posterior mode: ".
|
||||
|
||||
-horizon <integer>
|
||||
If this argument exists, then the horizon of the impulse responses is given
|
||||
by the passed integer. The default value is 12.
|
||||
|
||||
-error_bands
|
||||
-error_bands
|
||||
Output error bands. (default = off - only median is computed)
|
||||
|
||||
-percentiles n p_1 p_2 ... p_n
|
||||
Percentiles to compute. The first parameter after percentiles must be the
|
||||
number of percentiles and the following values are the actual percentiles.
|
||||
Percentiles to compute. The first parameter after percentiles must be the
|
||||
number of percentiles and the following values are the actual percentiles.
|
||||
default = 3 0.16 0.50 0.84 if error_bands flag is set
|
||||
= 1 0.50 otherwise
|
||||
|
||||
-parameter_uncertainty
|
||||
-parameter_uncertainty
|
||||
Apply parameter uncertainty when computing error bands.
|
||||
|
||||
-shocks_per_parameter <integer>
|
||||
Number of shocks and regime paths to draw for each parameter draw. The
|
||||
-shocks_per_parameter <integer>
|
||||
Number of shocks and regime paths to draw for each parameter draw. The
|
||||
default value is 1 if parameter_uncertainty is set and 10,000 otherwise.
|
||||
|
||||
-thin
|
||||
Thinning factor. Only 1/thin of the draws in posterior draws file are
|
||||
|
||||
-thin
|
||||
Thinning factor. Only 1/thin of the draws in posterior draws file are
|
||||
used. The default value is 1.
|
||||
|
||||
-regimes
|
||||
-regimes
|
||||
Produces forecasts as if each regime were permanent. (default = off)
|
||||
|
||||
-regime <integer>
|
||||
|
@ -328,7 +328,7 @@ int main(int nargs, char **args)
|
|||
// parameter filename
|
||||
if (!parm)
|
||||
sprintf(parm=(char*)malloc(strlen(fmt) + strlen(tag) - 1),fmt,tag);
|
||||
}
|
||||
}
|
||||
|
||||
// horizon
|
||||
horizon=dw_ParseInteger_String(nargs,args,"horizon",12);
|
||||
|
@ -344,7 +344,7 @@ int main(int nargs, char **args)
|
|||
" -horizon : horizon for the forecast (12)\n"
|
||||
);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!parm)
|
||||
strcpy(parm=(char*)malloc(strlen(spec)+1),spec);
|
||||
|
@ -364,7 +364,7 @@ int main(int nargs, char **args)
|
|||
free(head);
|
||||
free(parm);
|
||||
|
||||
//============================= Compute forecasts =============================
|
||||
//============================= Compute forecasts =============================
|
||||
|
||||
// Mean forecast
|
||||
/* if (dw_FindArgument_String(nargs,args,"mean") != -1) */
|
||||
|
|
|
@ -12,7 +12,7 @@ static void AddObservationFixed(PRECISION x, int *low, int *h, int *high, PRECIS
|
|||
|
||||
static PRECISION Cumulative(PRECISION level, int low, int *h, PRECISION min, PRECISION max, int intervals, int sample_size);
|
||||
static PRECISION Percentile(PRECISION percentile, int low, int *h, PRECISION min, PRECISION max, int intervals, int sample_size);
|
||||
static TMatrix MakeHistogram(int low, int *h, PRECISION min, PRECISION max,int intervals, int sample_size,
|
||||
static TMatrix MakeHistogram(int low, int *h, PRECISION min, PRECISION max,int intervals, int sample_size,
|
||||
PRECISION min_out, PRECISION max_out, int bins);
|
||||
static TMatrix MakeHistogramAuto(int low, int *h, int high, PRECISION min, PRECISION max, int intervals, int sample_size, int bins);
|
||||
|
||||
|
@ -53,7 +53,7 @@ TMatrixHistogram *CreateMatrixHistogram(int rows, int cols, int intervals, int t
|
|||
|
||||
if (!(h->high=(int**)malloc(rows*sizeof(int*)))) dw_Error(MEM_ERR);
|
||||
for (i=rows-1; i >= 0; i--)
|
||||
if (!(h->high[i]=(int*)malloc(cols*sizeof(int)))) dw_Error(MEM_ERR);
|
||||
if (!(h->high[i]=(int*)malloc(cols*sizeof(int)))) dw_Error(MEM_ERR);
|
||||
|
||||
h->Min=CreateMatrix(rows,cols);
|
||||
h->Max=CreateMatrix(rows,cols);
|
||||
|
@ -476,8 +476,8 @@ static void Resize(PRECISION x, int *h, PRECISION *min, PRECISION *max, int inte
|
|||
}
|
||||
|
||||
/*
|
||||
Adds a observation to the histogram. The type of the histogram must
|
||||
be HISTOGRAM_VARIABLE.
|
||||
Adds a observation to the histogram. The type of the histogram must
|
||||
be HISTOGRAM_VARIABLE.
|
||||
*/
|
||||
static void AddObservationVariable(PRECISION x, int *h, PRECISION *min, PRECISION *max, int intervals)
|
||||
{
|
||||
|
@ -485,7 +485,7 @@ static void AddObservationVariable(PRECISION x, int *h, PRECISION *min, PRECISIO
|
|||
|
||||
if ((x < *min) || (x > *max)) Resize(x,h,min,max,intervals);
|
||||
|
||||
if (*max > *min)
|
||||
if (*max > *min)
|
||||
{
|
||||
i=(int)(intervals*(x - *min)/(*max - *min));
|
||||
h[(i < intervals) ? i : intervals-1]++;
|
||||
|
@ -516,13 +516,13 @@ static void AddObservationFixed(PRECISION x, int *low, int *h, int *high, PRECIS
|
|||
|
||||
/*
|
||||
Returns the level such that the probability of observing an observation
|
||||
less than or equal to level is percentile. If there is a point mass at
|
||||
less than or equal to level is percentile. If there is a point mass at
|
||||
x, and P(y < x) <= percentile <= P(y <= x), then x is returned.
|
||||
|
||||
Assumes
|
||||
Both intervals and sample_size are poitive and low and h[i] are
|
||||
non-negative. Also if
|
||||
|
||||
non-negative. Also if
|
||||
|
||||
high = sample_size - (low + h[0] + ... + h[intervals - 1]),
|
||||
|
||||
then high is non-negative.
|
||||
|
@ -560,8 +560,8 @@ static PRECISION Percentile(PRECISION percentile, int low, int *h, PRECISION min
|
|||
|
||||
Assumes
|
||||
Both intervals and sample_size are poitive and low and h[i] are
|
||||
non-negative. Also, if
|
||||
|
||||
non-negative. Also, if
|
||||
|
||||
high = sample_size - (low + h[0] + ... + h[intervals - 1]),
|
||||
|
||||
then high is non-negative.
|
||||
|
@ -591,18 +591,18 @@ static PRECISION Cumulative(PRECISION level, int low, int *h, PRECISION min, PRE
|
|||
if (level >= max) return 1.0;
|
||||
|
||||
for (count=low, i=0; i < intervals; count+=h[i++])
|
||||
if ((min+=inc) >= level)
|
||||
if ((min+=inc) >= level)
|
||||
return ((PRECISION)count + (PRECISION)h[i]*(level - min + inc)/inc)/(PRECISION)sample_size;
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
/*
|
||||
Returns a histogram over the interval I=[min_out,max_out]. The matrix returned
|
||||
has bins rows and 2 columns. If inc=(max_out - min_out)/bins, then the first
|
||||
element of the ith row is
|
||||
has bins rows and 2 columns. If inc=(max_out - min_out)/bins, then the first
|
||||
element of the ith row is
|
||||
|
||||
min + (i + 0.5)*inc,
|
||||
|
||||
min + (i + 0.5)*inc,
|
||||
|
||||
which is the mid-point of the ith interval. The second element is
|
||||
|
||||
P(min + i*inc < x <= min + (i + 1)*inc)/inc,
|
||||
|
@ -611,11 +611,11 @@ static PRECISION Cumulative(PRECISION level, int low, int *h, PRECISION min, PRE
|
|||
|
||||
Assumes
|
||||
Both intervals and sample_size are poitive and low and h[i] are
|
||||
non-negative. Also if
|
||||
|
||||
non-negative. Also if
|
||||
|
||||
high = sample_size - (low + h[0] + ... + h[intervals - 1]),
|
||||
|
||||
then high is non-negative.
|
||||
then high is non-negative.
|
||||
|
||||
If min < max, let inc=(max - min)/intervals and define
|
||||
|
||||
|
@ -742,7 +742,7 @@ static TMatrix MakeHistogramAuto(int low, int *h, int high, PRECISION min, PRECI
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return MakeHistogram(low,h,min,max,intervals,sample_size,min_out,max_out,bins);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue