error G0152 variable initialization problem

I'm trying to run the code below from a published paper. I get the error:

G0152 variable not initialized. line 1010. 

I suspect the problem variable is either p_boot_stat or p_boot[.,1].

I've tried to initialize it the best I could but with no success. Could someone advise on how to initialize/proceed?

new; /* @z clear out any previously assigned variables from the workspace */
library cml,pgraph; /* @z cmlmt is the newer version of cml. active pgraph library means graphics procedures can be used */
/* @z CML MT NOT BACKWARD COMPATIBLE. cml.ext an extra file in Ehrmann Fratzscher Rigobon that 'declares globals used in CML' */
#include cml.ext;
graphset;
cmlset;
outwidth 255; /* @z controls auxiliary output width */

cls; /* @z short for 'clear screen' */
/* INITIALIZATION */
boot = 0;
dist = 40;
leer = 1;
nulo = 999999; /* @z Code for missing data */
penalty = 1000;
param_o = 0;
param_b = 0;
p_x = 0;
A = 0;
gmm = 0;
gmo = 0;
gmp = 0;
gmmvcx = 0;
gmmvar = 0;
gmmpen = 0;

cls;
/* initialization of control variables */
metodoA = 0; /* different restrictions on A
1 = basic set up: only domestic constraints and zerosin the monetary policy reaction
2 = the previous one but spillovers are restricted to be between -1 and 1 or -1 and 0
3 = the same as before but now us has to have a bigger effect.

11 = basic set up: only domestic constraints and monetary policy reaction is allowed to REACT to german inflation
12 = the previous one but spillovers are restricted to be between -1 and 1 or -1 and 0
13 = the same as before but now us has to have a bigger effect.
*/

metodoret = 2; /* number of days to compute the returns */

metodovar = 1; /* decides if we run a VAR */
lags = 6; /* lags for the VAR */

metodonor = 1;
/* method of normalization
0 = normalizes using the standard deviation
1 = basis points
2 = normalizes with a given vector
*/

win = 20; /* number of consecutive observations to compute
the rolling window */
limit = 1.0;
minobs = 4*4;
metodoint = 1; /* @z short-term & bond yields in first differences to make them stationary in my paper */

/* computing the interest rates as
1 = levels
2 = first differences
3 = levels but long rates as yield
4 = first differences and long rates as yields
*/

metodotim = 0;
/* what is the sample in which this is run
0 = runs on the full data set
1 = runs the data between winini and winfin
the format is year- month-day (19990101) in which the data starts
2 = it eliminates the NBER days after running the VAR.
3 = dates and it eliminates the NBER days after running the VAR. */

winini = 19990101;
winfin = 20081231; /* last day 20081231 */
metodocom = 1; /* common shocks
0 = no common shocks
1 = there is a common shock and the number is especified in k */
k = 1;

metodored = 1; /* one means that we run with constraints on the reduced form */
metodoreg = 0; /* 0 = means that we run using only the single variable regimes
1 = includes all the possiible variance regimes */

datatype = 2; /* which data file to load */
/* robustness tests */
/* common factors
metodoret = 2;
lags = 3;
win = 20;
metodotim = 0;
datatype = 3;
*/
/* shorter sample
metodoret = 2;
lags = 5;
win = 20;
metodotim = 1;
datatype = 2;
*/
/* excluding recessions
metodoret = 2;
lags = 10;
win = 20;
metodotim = 2;
datatype = 2;
*/
/* 5-day returns
metodoret = 5;
lags = 11;
win = 20;
metodotim = 0;
datatype = 2;
*/
/* 10-day roling window
metodoret = 2;
lags = 10;
win = 10;
metodotim = 0;
datatype = 2;
*/
/* 30-day rolling window
metodoret = 2;
lags = 10;
win = 30;
metodotim = 0;
datatype = 2;
*/
/* excluding financial crises
metodoret = 2;
lags = 9;
win = 20;
metodotim = 2;
datatype = 4;
*/
/* use all variance regimes
metodoret = 2;
lags = 12;
win = 20;
metodotim = 0;
datatype = 2;
metodoreg = 1;
*/

/* @zac ‘ftocv’ converts a numeric vector (or matrix) to a character vector */
/* @zac strput lays a substring over a string */

t=8;
Archivo = "ECBred__________________________________.res"; /* @zac are the ____ due to there different versions of data? */
Archivo = strput(ftocv(metodoret,1,0),Archivo,t); t=t+1;
t=t+1;
Archivo = strput(ftocv(metodovar,1,0),Archivo,t); t=t+1;
t=t+1;
Archivo = strput(ftocv(win ,2,0),Archivo,t); t=t+2;
Archivo = strput(ftocv(limit*10 ,2,0),Archivo,t); t=t+2;
t=t+1;
Archivo = strput(ftocv(minobs ,2,0),Archivo,t); t=t+2;
Archivo = strput(ftocv(metodotim,1,0),Archivo,t); t=t+1;
Archivo = strput(ftocv(metodocom,1,0),Archivo,t); t=t+1;
Archivo = strput(ftocv(k ,1,0),Archivo,t); t=t+1;
t=t+1;
Archivo = strput(ftocv(metodonor,1,0),Archivo,t); t=t+1;
t=t+1;
Archivo = strput(ftocv(metodoint,1,0),Archivo,t); t=t+1;
t=t+1;
Archivo = strput(ftocv(metodoA ,2,0),Archivo,t); t=t+2;
t=t+1;
Archivo = strput(ftocv(metodoreg,1,0),Archivo,t); t=t+1;
t=t+1;
Archivo = strput(ftocv(boot ,3,0),Archivo,t); t=t+3;
t=t+1;
Archivo = strput(ftocv(lags ,1,0),Archivo,t); t=t+1;
t=t+3;
Archivo = strput(ftocv(datatype ,1,0),Archivo,t); t=t+1;
t=8;
ArchXLS = "ECBred.res";
ArchXLS = strput(ftocv(metodoret,1,0),ArchXLS,t); t=t+1;
ArchXLS = strput(ftocv(metodovar,1,0),ArchXLS,t); t=t+1;
ArchXLS = strput(ftocv(win ,2,0),ArchXLS,t); t=t+2;
ArchXLS = strput(ftocv(limit*10 ,2,0),ArchXLS,t); t=t+2;
ArchXLS = strput(ftocv(minobs ,2,0),ArchXLS,t); t=t+2;
ArchXLS = strput(ftocv(metodotim,1,0),ArchXLS,t); t=t+1;
ArchXLS = strput(ftocv(metodocom,1,0),ArchXLS,t); t=t+1;
ArchXLS = strput(ftocv(k ,1,0),ArchXLS,t); t=t+1;
ArchXLS = strput(ftocv(metodonor,1,0),ArchXLS,t); t=t+1;
ArchXLS = strput(ftocv(metodoint,1,0),ArchXLS,t); t=t+1;
ArchXLS = strput(ftocv(metodoA ,2,0),ArchXLS,t); t=t+2;
ArchXLS = strput(ftocv(metodoreg,1,0),ArchXLS,t); t=t+1;
ArchXLS = strput(ftocv(boot ,3,0),ArchXLS,t); t=t+3;
ArchXLS = strput(ftocv(lags ,1,0),ArchXLS,t); t=t+1;
t=t+1;
ArchXLS = strput(ftocv(datatype ,1,0),ArchXLS,t-1); t=t+1; /* @zac 't-1' after ArchXLS changed by zac from t */

? $Archivo; ? $ArchXLS; /* @zac Why use ? $ */
output file=^Archivo reset; /* @zac ^ means Interpret following name as a variable, not a literal. If the filename is */
/* in a string variable, then the ^ (caret) operator must precede the name of the string */
? $Archivo; /* @zac a character matrix must have a $ prefixed to it in a print statement */
? "metodoA" metodoA;
? "metodoret" metodoret;
? "metodovar" metodovar;
? "lags" lags;
? "metodonor" metodonor;
? "win" win;
? "limit" limit;
? "minobs" minobs;
? "metodoint" metodoint;
? "metodotim" metodotim;
output off;
? "reading";
/* Reading the data */

/* @zac if leer eq 1;
elseif datatype eq 2; */
load d[] = "ECBData.csv";
/* @zac elseif datatype eq 3;
load d[] = "ECBData_commonfactor.csv";
elseif datatype eq 4;
load d[] = "ECBData_crises.csv";
else;
stop;
endif;
*/

ECBData = reshape(d,rows(d)/42,42); /* @zac matrix d is reshaped into a (rows(d)/42)x42 matrix and assigned to ECBData */

v = { boolean, year, month, day,
ir3mea, ir10yea, ir3mus, ir10yus, eusea, pus, pea3,
agdpuu, consconfuu, cpiuu, fgdpuu, housestuu, indproduu, napmuu, nonfpayruu,
pgdpuu, ppiuu, retsaleuu, tbguu, unempruu, workweekuu,
s3cpimgu, gdpwqgu, gdppgqgu, ifobcgu, ipmgu, ipwmgu, mordmgu, ppimgu, ppiwmgu,
retmgu, tradebgu, unwcgu, sp1m3ygu, sp1uncgu, sp2m3ygu, oilprice, nber
};

ECBData = miss(ECBData,nulo); /* @zac 'miss' converts elements of ECBData that are equal to nulo to GAUSS's missing value code */
? rows(ECBData);
? ECBData[rows(ECBData),.];

saved(ECBData,"ECBData",v);
/********************/
/* Estimation */
/********************/

/* Data
BOOLEAN 1
YEAR 2
MONTH 3
DAY 4
IR3MEA 5 short EA rate
IR10YEA 6 long EA rate
IR3MUS 7 short US rate
IR10YUS 8 long US rate
EUSEA 9 Exchange rates
PUS 10 stock market: US
PEA3 11 stock market: EA

NEWS:
AGDPUU 12 news from US
CONSCONF 13
CPIUU 14
FGDPUU 15
HOUSESTU 16
INDPRODU 17
NAPMUU 18
NONFPAYR 19
PGDPUU 20
PPIUU 21
RETSALEU 22
TBGUU 23
UNEMPRUU 24
WORKWEEK 25
S3CPIMGU 26 news fromm Germany/EA
GDPWQGU 27
GDPPGQGU 28
IFOBCGU 29
IPMGU 30
IPWMGU 31
MORDMGU 32
PPIMGU 33
PPIWMGU 34
RETMGU 35
TRADEBGU 36
UNWCGU 37
SP1M3YGU 38
SP1UNCGU 39
SP2M3YGU 40

OTHER:
OILPRICE 41 oil prices
NBER 42 NBER recession dummy
*/
/* cleaning the data */
? "cleaning the data"; /* @zac MAYBE '?' initialises the string "cleaning the data" */

i_isus = 7; /* @zac US short rate */
i_ilus = 8;
i_smus = 10;
i_isge = 5;
i_ilge = 6;
i_smge = 11; /* @zac stock market EA */
i_usge = 9; /* @zac exchange rate */
i_cont = 41|seqa(12,1,14)|seqa(26,1,15); /*@zac seqa creates an additive sequence. seqa(12,1,14) starts at 12 incrementing by 1 for 14 times? these are US news variables */
i_nber = 42; /*@zac |seqa(26,1,15) vertical concatenation of EA news terms after US news terms. */
if metodotim eq 1; /* @zac metodotim = 1 = sample between winini & winfin, use 41, ortherwise ..... */
i_cont = 41;
elseif metodotim eq 2;
i_cont = i_cont|i_nber;
elseif metodotim eq 3;
i_cont = 41|i_nber;
endif;
DataCol = 4;
if (metodotim eq 1) or (metodotim eq 3);
/* cleaning the time periods */
prov = ECBData[.,2]*10000+ECBData[.,3]*100+ECBData[.,4]; /* @zac year, month, day? note boolean excluded. why multiply dates by 10000? */
prov = (prov.>=winini).*(prov.<=winfin);
prov = miss(prov,0); /* @zac replace missing values with 0? */

ECBData[.,DataCol:cols(ECBData)] = ECBData[.,DataCol:cols(ECBData)].*prov;
endif;

Data = ECBData[.,1:DataCol];
Data = Data~(Data[.,2]*10000+Data[.,3]*100+Data[.,4]);

DataCol = DataCol+1;
Data = Data~ECBData[.,i_isus i_ilus i_smus i_isge i_ilge i_smge i_usge];
Data = Data~ECBData[.,i_cont];
Data = packr(Data); /*@zac packr deletes rows with missing data */
tot=6 ; /* @zac what is tot = 6 ? no ; ??? */
DataOri = Data;

/* computing the two day returns to eliminate the problems with the non-syncronous trading */

/* we only change our variables of interest */
/* interest rates in levels */
if metodoint eq 1;
if metodoret eq 1;
i=rows(Data); do while i ge 2;
t=DataCol+1;
Data[i,t] = Data[i,t]/100; t=t+1;
Data[i,t] = Data[i,t]/100; t=t+1;
Data[i,t] = (Data[i,t]/Data[i-1,t])^(1/(Data[i,1]-Data[i-1,1])) - 1; t=t+1;
Data[i,t] = Data[i,t]/100; t=t+1;
Data[i,t] = Data[i,t]/100; t=t+1;
Data[i,t] = (Data[i,t]/Data[i-1,t])^(1/(Data[i,1]-Data[i-1,1])) - 1; t=t+1;
Data[i,t] = (Data[i,t]/Data[i-1,t])^(1/(Data[i,1]-Data[i-1,1])) - 1; t=t+1;

Data[i,t] = (Data[i,t]/Data[i-1,t])^(1/(Data[i,1]-Data[i-1,1])) - 1; t=t+1; /* @zac is this oil price? */
i=i-1; endo;
Data = trimr(Data,1,0); /*@zac trim top row because it's used in calculation? */
else;
i=rows(Data); do while i ge metodoret+1;
t=DataCol+1;
Data[i,t] = sumc(Data[i:i-metodoret+1,t])/(metodoret*100); t=t+1; /*@zac sumc computes sum of each column of a matrix */
Data[i,t] = sumc(Data[i:i-metodoret+1,t])/(metodoret*100); t=t+1;
Data[i,t] = ((Data[i,t]/Data[i-metodoret,t])^(1/(Data[i,1]-Data[i-metodoret,1])))-1; t=t+1;
Data[i,t] = sumc(Data[i:i-metodoret+1,t])/(metodoret*100); t=t+1;
Data[i,t] = sumc(Data[i:i-metodoret+1,t])/(metodoret*100); t=t+1;
Data[i,t] = ((Data[i,t]/Data[i-metodoret,t])^(1/(Data[i,1]-Data[i-metodoret,1])))-1; t=t+1;
Data[i,t] = ((Data[i,t]/Data[i-metodoret,t])^(1/(Data[i,1]-Data[i-metodoret,1])))-1; t=t+1;

Data[i,t] = ((Data[i,t]/Data[i-metodoret,t])^(1/(Data[i,1]-Data[i-metodoret,1])))-1; t=t+1;

if t le cols(Data); /* @zac le = less than or equal to */
Data[i,t:cols(Data)] = sumc(Data[i:i-metodoret+1,t:cols(Data)])';
endif;
i=i-1; endo;


Data_e = seqa(1,1,rows(Data))/metodoret;
Data_e = 1-((Data_e-trunc(Data_e)).>0); /* @zac trunc(x) converts number in x to integers by truncating the fractional part */
Data_e = miss(Data_e,0);
Data_e = packr(Data.*Data_e);
Data = trimr(Data_e,2,0);
endif;
/* interest rates in first differences */ /*@zac this is the specification i need. BUT shouldn't metodoret eq 2? */
elseif metodoint eq 2;
if metodoret eq 1;
i=rows(Data); do while i ge 2;
t=DataCol+1;
Data[i,t] = (Data[i,t]-Data[i-1,t])/100; t=t+1; /* @zac short and long rates differenced and in basis points */
Data[i,t] = (Data[i,t]-Data[i-1,t])/100; t=t+1;
Data[i,t] = (Data[i,t]/Data[i-1,t])^(1/(Data[i,1]-Data[i-1,1])) - 1; t=t+1;
Data[i,t] = (Data[i,t]-Data[i-1,t])/100; t=t+1;
Data[i,t] = (Data[i,t]-Data[i-1,t])/100; t=t+1;
Data[i,t] = (Data[i,t]/Data[i-1,t])^(1/(Data[i,1]-Data[i-1,1])) - 1; t=t+1;
Data[i,t] = (Data[i,t]/Data[i-1,t])^(1/(Data[i,1]-Data[i-1,1])) - 1; t=t+1;

Data[i,t] = (Data[i,t]/Data[i-1,t])^(1/(Data[i,1]-Data[i-1,1])) - 1; t=t+1;
i=i-1; endo;
Data = trimr(Data,1,0);
else;
i=rows(Data); do while i ge metodoret+1;
t=DataCol+1;
Data[i,t] = (sumc(Data[i:i-metodoret+1,t])-sumc(Data[i-1:i-metodoret,t]))/(100); t=t+1;
Data[i,t] = (sumc(Data[i:i-metodoret+1,t])-sumc(Data[i-1:i-metodoret,t]))/(100); t=t+1;
Data[i,t] = ((Data[i,t]/Data[i-metodoret,t])^(1/(Data[i,1]-Data[i-metodoret,1])))-1; t=t+1;
Data[i,t] = (sumc(Data[i:i-metodoret+1,t])-sumc(Data[i-1:i-metodoret,t]))/(100); t=t+1;
Data[i,t] = (sumc(Data[i:i-metodoret+1,t])-sumc(Data[i-1:i-metodoret,t]))/(100); t=t+1;
Data[i,t] = ((Data[i,t]/Data[i-metodoret,t])^(1/(Data[i,1]-Data[i-metodoret,1])))-1; t=t+1;
Data[i,t] = ((Data[i,t]/Data[i-metodoret,t])^(1/(Data[i,1]-Data[i-metodoret,1])))-1; t=t+1;

Data[i,t] = ((Data[i,t]/Data[i-metodoret,t])^(1/(Data[i,1]-Data[i-metodoret,1])))-1; t=t+1;

if t le cols(Data);
Data[i,t:cols(Data)] = sumc(Data[i:i-metodoret+1,t:cols(Data)])';
endif;
i=i-1; endo;


Data_e = seqa(1,1,rows(Data))/metodoret;
Data_e = 1-((Data_e-trunc(Data_e)).>0);
Data_e = miss(Data_e,0);
Data_e = packr(Data.*Data_e);
Data = trimr(Data_e,2,0);
endif;
tot=7 ;

/* long run interest rates in yields */

elseif metodoint eq 3;
if metodoret eq 1;
i=rows(Data); do while i ge 2;
t=DataCol+1;
Data[i,t] = Data[i,t]/100; t=t+1;
Data[i,t] = Data[i,t]/100 - Data[i,t-1]; t=t+1;
Data[i,t] = (Data[i,t]/Data[i-1,t])^(1/(Data[i,1]-Data[i-1,1])) - 1; t=t+1;
Data[i,t] = Data[i,t]/100; t=t+1;
Data[i,t] = Data[i,t]/100 - Data[i,t-1]; t=t+1;
Data[i,t] = (Data[i,t]/Data[i-1,t])^(1/(Data[i,1]-Data[i-1,1])) - 1; t=t+1;
Data[i,t] = (Data[i,t]/Data[i-1,t])^(1/(Data[i,1]-Data[i-1,1])) - 1; t=t+1;

Data[i,t] = (Data[i,t]/Data[i-1,t])^(1/(Data[i,1]-Data[i-1,1])) - 1; t=t+1;
i=i-1; endo;
Data = trimr(Data,1,0);
else;
i=rows(Data); do while i ge metodoret+1;
t=DataCol+1;
Data[i,t] = sumc(Data[i:i-metodoret+1,t])/(metodoret*100); t=t+1;
Data[i,t] = sumc(Data[i:i-metodoret+1,t])/(metodoret*100) - Data[i,t-1]; t=t+1;
Data[i,t] = ((Data[i,t]/Data[i-metodoret,t])^(1/(Data[i,1]-Data[i-metodoret,1])))-1; t=t+1;
Data[i,t] = sumc(Data[i:i-metodoret+1,t])/(metodoret*100); t=t+1;
Data[i,t] = sumc(Data[i:i-metodoret+1,t])/(metodoret*100) - Data[i,t-1]; t=t+1;
Data[i,t] = ((Data[i,t]/Data[i-metodoret,t])^(1/(Data[i,1]-Data[i-metodoret,1])))-1; t=t+1;
Data[i,t] = ((Data[i,t]/Data[i-metodoret,t])^(1/(Data[i,1]-Data[i-metodoret,1])))-1; t=t+1;

Data[i,t] = ((Data[i,t]/Data[i-metodoret,t])^(1/(Data[i,1]-Data[i-metodoret,1])))-1; t=t+1;

if t le cols(Data);
Data[i,t:cols(Data)] = sumc(Data[i:i-metodoret+1,t:cols(Data)])';
endif;
i=i-1; endo;


Data_e = seqa(1,1,rows(Data))/metodoret;
Data_e = 1-((Data_e-trunc(Data_e)).>0);
Data_e = miss(Data_e,0);
Data_e = packr(Data.*Data_e);
Data = trimr(Data_e,2,0);
endif;


/* interest rates in first differences and long rates in yields */
elseif metodoint eq 4;
if metodoret eq 1;
i=rows(Data); do while i ge 2;
t=DataCol+1;
Data[i,t] = (Data[i,t]-Data[i-1,t])/100; t=t+1;
Data[i,t] = (Data[i,t]-Data[i-1,t])/100 - Data[i,t-1]; t=t+1;
Data[i,t] = (Data[i,t]/Data[i-1,t])^(1/(Data[i,1]-Data[i-1,1])) - 1; t=t+1;
Data[i,t] = (Data[i,t]-Data[i-1,t])/100; t=t+1;
Data[i,t] = (Data[i,t]-Data[i-1,t])/100 - Data[i,t-1]; t=t+1;
Data[i,t] = (Data[i,t]/Data[i-1,t])^(1/(Data[i,1]-Data[i-1,1])) - 1; t=t+1;
Data[i,t] = (Data[i,t]/Data[i-1,t])^(1/(Data[i,1]-Data[i-1,1])) - 1; t=t+1;

Data[i,t] = (Data[i,t]/Data[i-1,t])^(1/(Data[i,1]-Data[i-1,1])) - 1; t=t+1;
i=i-1; endo;
Data = trimr(Data,1,0);
else;
i=rows(Data); do while i ge metodoret+1;
t=DataCol+1;
Data[i,t] = (sumc(Data[i:i-metodoret+1,t])-sumc(Data[i-1:i-metodoret,t]))/(100); t=t+1;
Data[i,t] = (sumc(Data[i:i-metodoret+1,t])-sumc(Data[i-1:i-metodoret,t]))/(100) - Data[i,t-1]; t=t+1;
Data[i,t] = ((Data[i,t]/Data[i-metodoret,t])^(1/(Data[i,1]-Data[i-metodoret,1])))-1; t=t+1;
Data[i,t] = (sumc(Data[i:i-metodoret+1,t])-sumc(Data[i-1:i-metodoret,t]))/(100); t=t+1;
Data[i,t] = (sumc(Data[i:i-metodoret+1,t])-sumc(Data[i-1:i-metodoret,t]))/(100) - Data[i,t-1]; t=t+1;
Data[i,t] = ((Data[i,t]/Data[i-metodoret,t])^(1/(Data[i,1]-Data[i-metodoret,1])))-1; t=t+1;
Data[i,t] = ((Data[i,t]/Data[i-metodoret,t])^(1/(Data[i,1]-Data[i-metodoret,1])))-1; t=t+1;

Data[i,t] = ((Data[i,t]/Data[i-metodoret,t])^(1/(Data[i,1]-Data[i-metodoret,1])))-1; t=t+1;

if t le cols(Data);
Data[i,t:cols(Data)] = sumc(Data[i:i-metodoret+1,t:cols(Data)])';
endif;
i=i-1; endo;


Data_e = seqa(1,1,rows(Data))/metodoret;
Data_e = 1-((Data_e-trunc(Data_e)).>0);
Data_e = miss(Data_e,0);
Data_e = packr(Data.*Data_e);
Data = trimr(Data_e,2,0);
endif;



else;
stop;
endif;

/************************/
/************************/
/* */
/* */
/* ESTIMATION */
/* */
/* */
/************************/
/************************/
/* running the VAR and cleaning the means */
? "VAR"; /* @zac Again, ? MAYBE initialises the string "VAR" */
/* we have to eliminate the nber date)s from the estimation. we put missing values */
if (metodotim eq 2) or (metodotim eq 3);
NBERDum = miss(1-(trimr(Data[.,cols(Data)],lags,0).>0),0);
else;
NBERDum = 1;
endif;
if metodovar eq 1;
x = Data[.,DataCol+1:cols(Data)]; /*@zac is DataCol = 4? since the 1st 4 columns boolean + date? */

xx = ones(rows(x),1)~seqa(1,1,rows(x))/rows(x);
i=1; do while i le lags;
xx = xx~lagn(x,-(lags-i));
i=i+1; endo;
yy = lagn(x[.,1:7],-lags);
xx = xx~lagn(x[.,8:cols(x)],-lags);

yy = trimr(yy,0,lags);
xx = trimr(xx,0,lags);
dd = trimr(Data[.,1:DataCol],lags,0);

beta_rf = inv(xx'xx)*(xx'yy);
resi_rf = yy-xx*beta_rf;

Data = dd~resi_rf;
endif;

/* normalizing */
? "normalization";
if metodonor eq 0;
DataNorm = ones(1,DataCol)~(sqrt(diag(varCovXS(resi_rf)))'/100);
Data = Data./DataNorm;
elseif metodonor eq 1;
DataNorm = ones(1,DataCol)~0.0001*ones(1,cols(resi_rf));
Data = Data./DataNorm;
elseif metodonor eq 2;
DataNorm = ones(1,DataCol)~0.01*ones(1,cols(resi_rf));
Data = Data./DataNorm;
else;
stop;
endif;
/* GUY ARRET!!!! */

/* rolling window of second moments */
? "creating the regimes";
Data = Data.*NBERDum;
DataRoll = ones(win,1)*sqrt(diag(varCovXS(packr(Data[.,DataCol+1:Cols(Data)]))))'; /* @zac varCovXS = vcx calculates the variance-covariance matrix */
i=win+1; do while i le rows(Data);
DataRoll = DataRoll | sqrt(diag(varCovXS(Data[i:i-win,DataCol+1:Cols(Data)])))';
i=i+1; endo;

Data = Data.*miss(1-(missrv(DataRoll[.,1],nulo).==nulo),0); /* missrv(x,v) converts missing values in x into the values in v */

Data = packr(Data); /* @zac packr(x) Deletes rows with missing values. */
DataRoll = packr(DataRoll);

DataWind = DataRoll[1,.]+limit*sqrt(diag(vcx(DataRoll)))';
DataWind = (DataRoll.>DataWind);
? rows(data)~rows(dataroll); /* @zac ? help or displays a list of available commands */

/* finding the observations that are always in low variance */
DataProv = 1;
i=1; do while i le cols(DataWind);
DataProv = DataProv.*(1-DataWind[.,i]);
i=i+1; endo;
DataReg = DataProv;

if metodoreg eq 0;
/* finding feasible unique regimes of high volatility for each variable */
i=1; do while i le cols(DataWind); /* @zac DataWind = Data Window? */
DataProv = 1;
j=1; do while j le cols(DataWind);
if j eq i;
DataProv = DataProv.*DataWind[.,j];
else;
DataProv = DataProv.*(1-DataWind[.,j]);
endif;
j=j+1; endo;

if sumc(DataProv) gt minobs;
DataReg = DataReg~DataProv;
else;
DataReg = DataReg~DataWind[.,i];
endif;
i=i+1; endo;

else;
/* finding all the other permutations of high volatility */
n = 7;
DataMask = seqa(0,1,2^n);
DataProv = DataMask;
i=1; do while i le n;
DataMask = DataMask~( int(DataProv./(2^(n-i))) );
DataProv = DataProv-(2^(n-i))*( int(DataProv[.,1]./(2^(n-i))) );
i=i+1; endo;
DataMask = DataMask[.,2:n+1];
i=2; do while i le rows(DataMask);
DataProv = 1;
j=1; do while j le cols(DataMask);
if DataMask[i,j] eq 1;
DataProv = DataProv.*DataWind[.,j];
else;
DataProv = DataProv.*(1-DataWind[.,j]);
endif;
j=j+1; endo;

if sumc(DataProv) gt minobs; /* @zac gt = greater than */
DataReg = DataReg~DataProv; /* @zac DataReg = Data regime? */
endif;
i=i+1; endo;
endif;

/**************************************************/
/**************************************************/
/* */
/* */
/* INITIALIZATION FOR ESTIMATION */
/* */
/* */
/**************************************************/
/**************************************************/
/* preparing the data for the GMM */
? "estimation";
DataGMM = Data[.,DataCol+1:cols(Data)]; /* @zac cols(Data) = number of columns in matrix Data. DataCol = 4? */
DataReg = DataReg;

gmmvar = rows(DataGMM)|diag(vcx(DataGMM)); /* @zac vcx(DataGMM) creates a KxK variance-covariance matrix from the NxK matrix DataGMM */
i=1; do while i le cols(DataReg);
gmmprov = packr(DataGMM.*miss(DataReg[.,i],0));
gmmvar = gmmvar~(rows(gmmprov)|diag(vcx(gmmprov)));
i=i+1; endo;
gmmvar[2:rows(gmmvar),.] = gmmvar[2:rows(gmmvar),.]./gmmvar[2:rows(gmmvar),2];
gmmvar = gmmvar[.,2:cols(gmmvar)];

output file=^Archivo on; /* @zac ^ is used to get the dataset name from a string variable, among other uses */
? "Covariance matrix of the regimes";
? gmmvar;
output off;
if metodoA eq 0;
A_rest = 99 ~ -1 ~ 0 ~ -11 ~ 90 ~ 90 ~ 0 |
0 ~ 99 ~ 0 ~ 90 ~ -11 ~ 90 ~ 0 |
1 ~ 1 ~ 99 ~ 90 ~ 90 ~ 10 ~ 0 |
-11~ 90 ~ 90 ~ 99 ~ -1 ~ 0 ~ 0 |
90 ~ -11 ~ 90 ~ 0 ~ 99 ~ 0 ~ 0 |
90 ~ 90 ~ 10 ~ 1 ~ 1 ~ 99 ~ 0 |
0 ~ 1 ~ 0 ~ 0 ~ -1 ~ 0 ~ 99 ;
A_para = 0 ~ 0 ~ 0 ~ 0 ~ 0 ~ 0 ~ 0 |
0 ~ 0 ~ 0 ~ 0 ~ 0 ~ 0 ~ 0 |
0 ~ 0 ~ 0 ~ 0 ~ 0 ~ 0 ~ 0 |
0 ~ 0 ~ 0 ~ 0 ~ 0 ~ 0 ~ 0 |
0 ~ 0 ~ 0 ~ 0 ~ 0 ~ 0 ~ 0 |
0 ~ 0 ~ 0 ~ 0 ~ 0 ~ 0 ~ 0 |
0 ~ 0 ~ 0 ~ 0 ~ 0 ~ 0 ~ 0 ;
A_redd = 1 ~ 1 ~ 0 ~ 1 ~ 0 ~ 0 ~ 0 |
0 ~ 1 ~ 0 ~ 0 ~ 1 ~ 0 ~ 0 |
-1 ~ -1 ~ 1 ~ 0 ~ 0 ~ 0 ~ 0 |
81 ~ 0 ~ 0 ~ 1 ~ 1 ~ 0 ~ 0 |
0 ~ 81 ~ 0 ~ 0 ~ 1 ~ 0 ~ 0 |
0 ~ 0 ~ 81 ~ -1 ~ -1 ~ 1 ~ 0 |
0 ~ 0 ~ 0 ~ 0 ~ 0 ~ 0 ~ 1 ;
A_redp = 0 ~ 0 ~ 0 ~ 0 ~ 0 ~ 0 ~ 0 |
0 ~ 0 ~ 0 ~ 0 ~ 0 ~ 0 ~ 0 |
0 ~ 0 ~ 0 ~ 0 ~ 0 ~ 0 ~ 0 |
104~ 0 ~ 0 ~ 0 ~ 0 ~ 0 ~ 0 |
0 ~ 205 ~ 0 ~ 0 ~ 0 ~ 0 ~ 0 |
0 ~ 0 ~ 306 ~ 0 ~ 0 ~ 0 ~ 0 |
0 ~ 0 ~ 0 ~ 0 ~ 0 ~ 0 ~ 0 ;
else;
? "PROBLEM (in german)";
stop;
endif;

DataVCX = 0;
i=1; do while i le cols(DataReg);
gmmprov = packr(DataGMM.*miss(DataReg[.,i],0));
gmmprov = vech(vcx(gmmprov));

if DataVCX eq 0;
DataVCX = gmmprov;
else;
DataVCX = DataVCX~gmmprov;
endif;
i=i+1; endo;
/********************************/
/* */
/* ESTIMATION */
/* */
/********************************/

/* initializing the parameters */
n = cols(DataGMM); /* @zac n is dim(A) */
A = ones(n,n);
{A,gama,sigzreg,param_o,param_b} = parametros(A,A_rest,param_o,n,0);

_cml_Algorithm = 1;
_cml_Bounds = param_b;
_cml_LineSearch = 2;
_cml_Covpar = 1;
_cml_MaxIters = 300;

if metodored eq 0; /*@zac 'metodored = 1' means run with constraints on the reduced-form */
if metodocom eq 0; /*@zac 'metodocom = 0' means no common shocks */
{p_x,p_f,p_g,p_c,p_r} = cmlprt(cml(DataGMM,0,&FindARegimes,param_o)); /*@zac 'cmlpart' formats and prints the output from a call to CML. */
stop;

else;
metodocom = 0;
{A,gama,sigzreg,param_o,param_b} = parametros(A,A_rest,param_o,n,0);

_cml_Bounds = param_b;
{p_x,p_f,p_g,p_c,p_r} = cmlprt(cml(DataGMM,0,&FindARegimes,param_o)); /*@zac 'cmlpart' formats and prints the output from a call to CML. */

metodocom = 2;
{A,gama,sigzreg,param_o,param_b} = parametros(A,A_rest,param_o,n,0);
param_o[1:rows(p_x)] = p_x;

_cml_Bounds = param_b;
_cml_MaxIters = 100;
{p_x,p_f,p_g,p_c,p_r} = cmlprt(cml(DataGMM,0,&FindARegimes,param_o));

metodocom = 1;
{A,gama,sigzreg,param_o,param_b} = parametros(A,A_rest,param_o,n,0);
param_o = p_x;

_cml_Bounds = param_b;
_cml_MaxIters = 300;
{p_x,p_f,p_g,p_c,p_r} = cmlprt(cml(DataGMM,0,&FindARegimes,param_o));

endif;

elseif metodored eq 1;
? "running only the A";
metodored = 0;
metodocom = 0;
{A,gama,sigzreg,param_o,param_b} = parametros(A,A_rest,param_o,n,0);

_cml_Bounds = param_b;
_cml_DirTol = 0.00001;
{p_x,p_f,p_g,p_c,p_r} = cmlprt(cml(DataGMM,0,&FindARegimes,param_o));

metodocom = 2;
{A,gama,sigzreg,param_o,param_b} = parametros(A,A_rest,param_o,n,0);
param_o[1:rows(p_x)] = p_x;

_cml_Bounds = param_b;
_cml_MaxIters = 100;
_cml_DirTol = 0.0001;
{p_x,p_f,p_g,p_c,p_r} = cmlprt(cml(DataGMM,0,&FindARegimes,param_o));

/* ? "hola"; wait; */
metodored = 1;
metodocom = 1;
{A,gama,sigzreg,param_o,param_b} = parametros(A,A_rest,param_o,n,0);
param_o = p_x;

_cml_Bounds = param_b;
_cml_MaxIters = 300;
_cml_DirTol = 0.001;
_cml_LineSearch = 3;
{p_x,p_f,p_g,p_c,p_r} = cmlprt(cml(DataGMM,0,&FindARegimes,param_o));
/* estimating the variance decomposition */
DataVCX_orig = DataVCX;
GMMvar_orig = GMMvar;
p_x_orig = p_x;
A_orig = A;
{A,gama,sigZreg,p_x,param_b} = parametros(A,A_rest,p_x_orig,n,1);

vardecomp = zeros(n,n);
sigEunc = zeros(n,n);
sigZunc = 0;
i=1; do while i le cols(DataVCX);
prov = xpnd(DataVCX[.,i]);
prov = A * prov * A';
prov = prov - (gama*gama' * sigZreg[i]);
sigEreg = diagrv(eye(n),diag(prov));

vardecomp = vardecomp + xpnd(DataVCX[.,i])*GMMvar[1,i]/sumc(GMMvar[1,.]');
sigEunc = sigEunc + sigEreg *GMMvar[1,i]/sumc(GMMvar[1,.]');
sigZunc = sigZunc + sigZreg[i] *GMMvar[1,i]/sumc(GMMvar[1,.]');
i=i+1; endo;

vardecomp = diag(vardecomp);
invA = inv(A);
i=1; do while i le n;
sigE = zeros(n,n);
sigE[i,i] = 1;
sigE = sigE.*sigEunc;
sigE = invA*sigE*invA';
vardecomp = vardecomp~diag(sigE);
i=i+1; endo;
sigz = gama*sigZunc*gama';
sigz = invA*sigz*invA';
vardecomp = vardecomp~diag(sigz);
vardecomp = vardecomp~sumc(vardecomp[.,2:2+n]');
xxt = vardecomp'./vardecomp[.,cols(vardecomp)]';
vdec=xxt[2:9,1:7];

vdec_orig = vdec;
cls;
if boot eq 0;
else;
? "Now we estimate the bootstrap";
p_boot = p_x;
a_boot = vec(inv(A));
vdec_boot = vec(vdec);
bb_boot=1; do while bb_boot le boot;
/* creating new covariance matrices for each regime*/
i=1; do while i le cols(DataVCX_orig);
prov = chol(xpnd(DataVCX_orig[.,i]))';
prov = prov*rndn(n,GMMvar[1,i]);
DataVCX[.,i] = vech(vcx(prov'));
i=i+1; endo;

{p_x,p_f,p_g,p_c,p_r} = cmlprt(cml(DataGMM,0,&FindARegimes,p_x_orig));
p_boot = p_boot~p_x;
a_boot = a_boot~vec(inv(A));

vardecomp = zeros(n,n);
sigEunc = zeros(n,n);
sigZunc = 0;
i=1; do while i le cols(DataVCX);
prov = xpnd(DataVCX[.,i]);
prov = A * prov * A';
prov = prov - (gama*gama' * sigZreg[i]);
sigEreg = diagrv(eye(n),diag(prov));

vardecomp = vardecomp + xpnd(DataVCX[.,i])*GMMvar[1,i]/sumc(GMMvar[1,.]');
sigEunc = sigEunc + sigEreg *GMMvar[1,i]/sumc(GMMvar[1,.]');
sigZunc = sigZunc + sigZreg[i] *GMMvar[1,i]/sumc(GMMvar[1,.]');
i=i+1; endo;

vardecomp = diag(vardecomp);
invA = inv(A);
i=1; do while i le n;
sigE = zeros(n,n);
sigE[i,i] = 1;
sigE = sigE.*sigEunc;
sigE = invA*sigE*invA';
vardecomp = vardecomp~diag(sigE);
i=i+1; endo;
sigz = gama*sigZunc*gama';
sigz = invA*sigz*invA';
vardecomp = vardecomp~diag(sigz);
vardecomp = vardecomp~sumc(vardecomp[.,2:2+n]');
xxt = vardecomp'./vardecomp[.,cols(vardecomp)]';
vdec=xxt[2:9,1:7];
vdec_boot = vdec_boot~vec(vdec);

cls;
bb_boot=bb_boot+1; endo;
endif;
else;
? "problems with metodored"; stop;
endif;
/* PRINTING */
output file=^Archivo on;
? "Our beatiful matrix A";

? A_orig;
? ;
? "and the inverse";
? inv(A_orig);

?; ?; ?; ?;

? "Variance dcomposition";
/* ? vardecomp'; */

? vdec_orig;
?; ?; ?; ?;

output off;
p_boot_stat = p_boot[.,1]';
p_boot_stat = p_boot_stat|sumc(p_boot')'/(boot+1);
p_boot_stat = p_boot_stat|sqrt(diag(vcx(p_boot')))';
p_boot_stat = p_boot_stat|maxc(p_boot')';
p_boot_stat = p_boot_stat|minc(p_boot')';
p_boot_stat = p_boot_stat|sumc(p_boot'.>0)'/(boot+1);
p_boot_stat = p_boot_stat|sumc(abs(p_boot)'.<0.00001)'/(boot+1);
p_boot_stat = p_boot_stat|sumc(abs(p_boot+1)'.<0.00001)'/(boot+1);

p_boot_min = int(minc(p_boot')*100)'/100;
p_boot_max = int(maxc(p_boot')*100+1)'/100;
p_boot_ste = (p_boot_max-p_boot_min)/(dist-1);
p_boot_dis = p_boot_min*0;
p_boot_mas = p_boot_min*0;
i=1; do while i le dist+1;
p_boot_tre = p_boot_min + (i-1)*p_boot_ste;
p_boot_mas = p_boot_mas | sumc(p_boot'.0)'/(boot+1);
a_boot_stat = a_boot_stat|sumc(abs(a_boot)'.<0.00001)'/(boot+1);
a_boot_stat = a_boot_stat|sumc(abs(a_boot+1)'.<0.00001)'/(boot+1);

a_boot_min = int(minc(a_boot')*100)'/100;
a_boot_max = int(maxc(a_boot')*100+1)'/100;
a_boot_ste = (a_boot_max-a_boot_min)/(dist-1);
a_boot_dis = a_boot_min*0;
a_boot_mas = a_boot_min*0;
i=1; do while i le dist+1;
a_boot_tre = a_boot_min + (i-1)*a_boot_ste;
a_boot_mas = a_boot_mas | sumc(a_boot'.0)*abs(invA[i,j]);
elseif A_redd[i,j] eq 81;
xi = trunc(A_redp[i,j]/100);
xj = A_redp[i,j]-100*xi;
gmmred = gmmred | ( (invA[i,j])<(invA[xi,xj]) )*abs(invA[i,j]-invA[xi,xj]);
elseif A_redd[i,j] eq -81;
xi = trunc(A_redp[i,j]/100);
xj = A_redp[i,j]-100*xi;
gmmred = gmmred | ( (invA[i,j])>(invA[xi,xj]) )*abs(invA[i,j]-invA[xi,xj]);
else;
stop;
endif;
j=j+1; endo;
i=i+1; endo;
if rows(gmmred) gt 1;
gmmred = trimr(gmmred,1,0);
gmmred = gmmred*maxc(abs(gmm))*penalty/10;
else;
gmmred = 0;
endif;

gmm = gmm|gmmred;
gmp = gmm;
gmm = -(sumc(abs(gmm)^2))/rows(gmm);
endif;
else;
? "no metodo red";
stop;
endif;
retp(gmm);
endp;

1 Answer



0



I am assuming that the line of code that is reported as causing the error is:

p_boot_stat = p_boot[.,1]';

The error "Variable not initialized" will only come up for a variable that you have not yet given a value, but are trying to reference in some way. For example, if we clear our GAUSS workspace with the new command and then make two variable assignments, like this:

new;
z = 0;
a = 1;
b = a;

we will have no problem, because each variable is assigned to (or initialized) before it's value is referenced. However, if we changed the program to this:

new;
z = 0;
if z == 1;
   a = 1;
endif;
b = a;

we will encounter the error G0152: Variable not initialized, since the code tries to assign to b the value of a, but it never assigns a a value.

This is what is happening in the code you posted. The code that is causing your error is:

p_boot_stat = p_boot[.,1]';

From the explanation above, we know that this is because p_boot has not yet been given a value. Looking through the code we can see that p_boot is assigned a value with this code:

if boot eq 0;
    //NOTE, we do not assign 'p_boot' in this case
    else;
        ? "Now we estimate the bootstrap";
        p_boot = p_x;
endif;

Since this is the only case in which p_boot is assigned a value, we can see that if the variable boot is equal to zero, p_boot will be uninitialized. And if we look up towards the top of the file, we see:

boot = 0;

aptech

1,338

Your Answer


You must login to post answers.

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.

Try GAUSS for 30 days for FREE

See what GAUSS can do for your data

© Aptech Systems, Inc. All rights reserved.

Privacy Policy