error message : G1001 : found keyword 'ELSE' : Expected nothing

output error: found keyword 'else': expected nothing. (line 259)

Below is the code around the line of the error. It is as downloaded from the publisher's website 'Journal of Applied Economics', I have not changed the code.

Dataset is a 6230 x 42 matrix .csv excel file. I don't know how to include it here.

Please help.

if leer eq 1;
elseif datatype eq 2;
   load d[] = "ECBData.csv";
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);

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);
? rows(ECBData);
? ECBData[rows(ECBData),.];

   saved(ECBData,"ECBData",v);
else; //Error on this line
   ECBData = loadd("ECBData");
   v = getname("ECBData");
endif;

13 Answers



0



The Problem
The error is coming from this block of code.

 
  saved(ECBData,"ECBData",v);
else; //Error on this line
   ECBData = loadd("ECBData");
   v = getname("ECBData");
endif;

In the above code, we see a conditional statement with a else and an endif, but it does not start with an if. All conditional blocks must start with an if statement. For example:

a = 1;
if a == 1;
   print "a is equal to 1";
else;
   print "a does NOT equal 1";
endif;

the statement above is clear. However, if we removed the first if, we would have no reference to understand what the else case refers to.

There is a bug in your code. Since you received the code from someone else, you need to figure out what the code block should do.
Solutions
The conditional statement that is causing the error is deciding whether to save the data that was loaded from one of the .csv files into a GAUSS dataset (that is the saved line), or whether to load data from a GAUSS dataset with the command loadd. Since you mentioned that you already have data in .csv format, you should (for now at least) need to load or save data from a GAUSS dataset. Therefore, you could change the code to this:

save_to_dataset = 0;
load_from_dataset = 0;
if save_to_dataset != 0;
  saved(ECBData,"ECBData",v);
elseif load_from_dataset; != 0;//Error on this line
   ECBData = loadd("ECBData");
   v = getname("ECBData");
endif;

This is legal GAUSS code that will skip the loading or saving of GAUSS datasets for now.

aptech

1,338


0



Thanks. After changing the code like you suggested this error message appears:

efrcode(244) : error G0152 : Variable not initialized

Below is the code around the line of the error (it is the same code downloaded from the publisher's website 'Journal of Applied Economics'):

? "reading";
if leer eq 1;
    elseif datatype eq 2;
        load d[] = "ECBData.csv";    
    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);    //Error on this line

    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);
    ? rows(ECBData); 
    ? ECBData[rows(ECBData),.]; 

save_to_dataset = 0;
load_from_dataset = 0;
if save_to_dataset ne 0;
  saved(ECBData,"ECBData",v);
elseif load_from_dataset; ne 0;//Error on this line
   ECBData = loadd("ECBData");
   v = getname("ECBData");
endif;

Please help.



0



A variable uninitialized error from this line

ECBData = reshape(d,rows(d)/42,42);

appears to be coming because d is not being set in this block of code above

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

Looking at the entire original code block, it looks like the intent of the code is to be like this:

//If we need to read in one of the following CSV files:
//ECBData.csv, ECBData_commonfactor.csv, ECBData_crises.csv
//and create a GAUSS dataset from it for later analysis
if leer eq 1;
    if datatype eq 1;
        print "Error: datatype must equal 2, 3 or 4";
        end;
    elseif datatype eq 2;
        load d[] = "ECBData.csv";
    elseif datatype eq 3;
        load d[] = "ECBData_commonfactor.csv";
    elseif datatype eq 4;
        load d[] = "ECBData_crises.csv";
    else;
        print "Error: datatype must equal 2, 3 or 4";
        end;
    endif;

    //Reshape data loaded from the CSV file to
    //have 42 columns
    ECBData = reshape(d,rows(d)/42,42);

    //Variable names for dataset
    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
        };

    //Replace any values in 'ECBData' that are equal to
    //the value of 'nulo' to a GAUSS missing value
    ECBData = miss(ECBData,nulo);

    //Print the number of rows in the matrix 'ECBData'
    ? rows(ECBData);

    //Print out the final row of the matrix 'ECBData'
    ? ECBData[rows(ECBData),.];

    //Create a GAUSS Dataset named 'ECBData.dat' from
    //the matrix 'ECBdata' using the variable names in 'v'
    saved(ECBData,"ECBData",v);
else;
    //This 'else' case means that we already have a GAUSS dataset
    //named 'ECBData.dat' and do not need to create one from a CSV file

    //Load the data from the dataset into a GAUSS matrix
    ECBData = loadd("ECBData");

    //Load the variable names from the GAUSS dataset
    v = getname("ECBData");
endif;

With this code, if you want to read in one of these CSV files ECBData.csv, ECBData_commonfactor.csv, ECBData_crises.csv and save them to a GAUSS dataset (which I am assuming is what the rest of the code requires), you can set datatype equal to 2, 3 or 4 to make your choice.

If you want to apply this code to your own data and have questions, we are happy to assist with that. I would recommend that you run it successfully with one of the provided CSV files first and then try running with your data.

Finally, if you are using a more recent version of GAUSS (16 or 17) we can simplify that initial loading code quite a lot. Let us know if you would like help with that.

aptech

1,338


0



Many thanks for your support (unfortunately I am not using GAUSS 16 or 17).

As suggested, I am trying to run the code with the CSV file provided (ECBData.csv), then I will apply it to my own data. I would need your help again since that error message appears after having implemented your suggestion above:

efrcode(1038) : error G0152 : Variable not initialized

/* 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]'; //Error on that line
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)'.<.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'.<a_boot_tre)';
    a_boot_dis = a_boot_dis | a_boot_tre;
    i=i+1;
endo;
a_boot_stat = a_boot_stat | a_boot_mas|a_boot_dis;

xlswritem(p_boot',ArchXLS, "b2", 1, 0);
xlswritem(a_boot',ArchXLS, "b2", 2, 0);
xlswritem(p_boot_stat,ArchXLS, "b2", 3, 0);
xlswritem(a_boot_stat,ArchXLS, "b2", 4, 0);
xlswritem(A_orig,ArchXLS, "b2", 5, 0);
xlswritem(inv(A_orig),ArchXLS, "b10", 5, 0);
xlswritem(vdec_orig,ArchXLS, "b18", 5, 0);
xlswritem(vdec_boot',ArchXLS, "b2", 6, 0);

/*clear A; clear a_boot; clear a_boot_dis; clear a_boot_mas; clear a_boot_max; clear a_boot_min; clear a_boot_stat; clear a_boot_ste; clear a_boot_tre; clear A_orig; clear A_para; clear A_redd; clear A_redp; clear A_rest; clear bb_boot; clear beta_rf; clear boot; clear d; clear Data; clear Data_e; clear DataCol; clear DataGMM; clear DataMask; clear DataNorm; clear DataOri; clear DataProv; clear DataReg; clear DataRoll; clear datatype; clear DataVCX; clear DataVCX_orig; clear DataWind; clear dd; clear dist; clear ECBData; clear gama; clear gmm; clear gmmpen; clear gmmprov; clear gmmvar; clear GMMvar_orig; clear gmmvcx; clear gmo; clear gmp; clear i; clear i_cont; clear i_ilge; clear i_ilus; clear i_isge; clear i_isus; clear i_nber; clear i_smge; clear i_smus; clear i_usge; clear invA; clear j; clear k; clear lags; clear leer; clear limit; clear metodoA; clear metodocom; clear metodoint; clear metodonor; clear metodored; clear metodoreg; clear metodoret; clear metodotim; clear metodovar; clear minobs; clear n; clear NBERDum; clear nulo; clear p_boot; clear p_boot_dis; clear p_boot_mas; clear p_boot_max; clear p_boot_min; clear p_boot_stat; clear p_boot_ste; clear p_boot_tre; clear p_c; clear p_f; clear p_g; clear p_r; clear p_x; clear p_x_orig; clear param_b; clear param_o; clear penalty; clear prov; clear resi_rf; clear sigE; clear sigEreg; clear sigEunc; clear sigz; clear sigzreg; clear sigZunc; clear t; clear v; clear vardecomp; clear vdec; clear vdec_boot; clear vdec_orig; clear win; clear winfin; clear winini; clear x; clear xx; clear xxt; clear yy;*/
stop;

I suppose the non initialized variable is p_boot since it is defined only when boot NE 0 but boot=0 at the top of the code.
How should I define p_boot in the case boot=0 in order to implement the bootstrap for the significance of parameter estimates?
Thanks.



0



Looking at the code you posted, I would guess that it is not really set up to run without boot=0. Most if not all of the matrices of interest towards the end of the code appear to have been created in the bootstrap section. Therefore it seems most likely to me that boot should be set to some nonzero value so the code will run through that section.

I also noticed that this section

else;
? "problems with metodored";
stop;
endif;

does not appear to have an opening if statement. I don't know if there is more code above what you posted which resolves this problem, in which case you can ignore this, or if it needs to be removed. However, I thought it might be helpful to bring to your attention.

aptech

1,338


0



Many thanks for your help. There is more code above what I posted, sorry for having not clarified that before.
As you suggested I set boot to a nonzero value and the code run through that section.

After the bootstrap section, the code generate an xls file and then stops because of the following command:


xlswritem(p_boot',ArchXLS, "b2", 1, 0);
xlswritem(a_boot',ArchXLS, "b2", 2, 0);
xlswritem(p_boot_stat,ArchXLS, "b2", 3, 0);
xlswritem(a_boot_stat,ArchXLS, "b2", 4, 0);
xlswritem(A_orig,ArchXLS, "b2", 5, 0);
xlswritem(inv(A_orig),ArchXLS, "b10", 5, 0);
xlswritem(vdec_orig,ArchXLS, "b18", 5, 0);
xlswritem(vdec_boot',ArchXLS, "b2", 6, 0);

/*clear A; clear a_boot; clear a_boot_dis; clear a_boot_mas; clear a_boot_max; clear a_boot_min; clear a_boot_stat; clear a_boot_ste; clear a_boot_tre; clear A_orig; clear A_para; clear A_redd; clear A_redp; clear A_rest; clear bb_boot; clear beta_rf; clear boot; clear d; clear Data; clear Data_e; clear DataCol; clear DataGMM; clear DataMask; clear DataNorm; clear DataOri; clear DataProv; clear DataReg; clear DataRoll; clear datatype; clear DataVCX; clear DataVCX_orig; clear DataWind; clear dd; clear dist; clear ECBData; clear gama; clear gmm; clear gmmpen; clear gmmprov; clear gmmvar; clear GMMvar_orig; clear gmmvcx; clear gmo; clear gmp; clear i; clear i_cont; clear i_ilge; clear i_ilus; clear i_isge; clear i_isus; clear i_nber; clear i_smge; clear i_smus; clear i_usge; clear invA; clear j; clear k; clear lags; clear leer; clear limit; clear metodoA; clear metodocom; clear metodoint; clear metodonor; clear metodored; clear metodoreg; clear metodoret; clear metodotim; clear metodovar; clear minobs; clear n; clear NBERDum; clear nulo; clear p_boot; clear p_boot_dis; clear p_boot_mas; clear p_boot_max; clear p_boot_min; clear p_boot_stat; clear p_boot_ste; clear p_boot_tre; clear p_c; clear p_f; clear p_g; clear p_r; clear p_x; clear p_x_orig; clear param_b; clear param_o; clear penalty; clear prov; clear resi_rf; clear sigE; clear sigEreg; clear sigEunc; clear sigz; clear sigzreg; clear sigZunc; clear t; clear v; clear vardecomp; clear vdec; clear vdec_boot; clear vdec_orig; clear win; clear winfin; clear winini; clear x; clear xx; clear xxt; clear yy;*/
stop; //line 1094

Thus the following appears:

Execution stopped in line 1094 of C:\mteng8.0\efrcode

Then the code continues as follow:


/********************/
/********************/
/* */
/* PROCEDURES */
/* */
/********************/
/********************/

proc (5)=parametros(A,A_rest,param,n,dir);
local i,j,plim,plimvar,t,A_std,Sigma_std,param_c,cmle,xi,xj,param_b,gama, sigZreg;

cmle = 0;
plim = 100;
plimvar = 1000000000;

/* this initializes all the variables using n (number of regimes) and A_ret */
if dir eq 0;
A = zeros(n,n);
t=1;
param_o = 0;
param_b = 0~0;
i=1; do while i le n;
j=1; do while j le n;
if A_rest[i,j] eq 0;
param_o = param_o|0.005; t=t+1;
param_b = param_b|-plim~plim;
elseif A_rest[i,j] eq 1;
param_o = param_o|0.01; t=t+1;
param_b = param_b|0~plim;
elseif A_rest[i,j] eq -1;
param_o = param_o|-0.01; t=t+1;
param_b = param_b|-plim~0;

elseif A_rest[i,j] eq 10;
param_o = param_o|0.005; t=t+1;
param_b = param_b|-1~1;
elseif A_rest[i,j] eq 11;
param_o = param_o|0.01; t=t+1;
param_b = param_b|0~1;
elseif A_rest[i,j] eq -11;
param_o = param_o|-0.01; t=t+1;
param_b = param_b|-1~0;

elseif A_rest[i,j] eq 50;
param_o = param_o|0.005; t=t+1;
param_b = param_b|-plim~plim;

elseif A_rest[i,j] eq 60;
param_o = param_o|-0.01; t=t+1;
param_b = param_b|-plim~plim;

elseif A_rest[i,j] eq 80;
elseif A_rest[i,j] eq 81;
param_o = param_o|0.01; t=t+1;
param_b = param_b|0~1;
elseif A_rest[i,j] eq -81;
param_o = param_o|-0.01; t=t+1;
param_b = param_b|-1~0;

elseif A_rest[i,j] eq 90;
elseif A_rest[i,j] eq 99;
a[i,j] = 1;
else;
? "PROBLEM"; stop;
endif;
j=j+1; endo;
i=i+1; endo;
param_o = trimr(param_o,1,0);
param_b = trimr(param_b,1,0);

if metodocom eq 0;
gama = 0;
sigZreg = 0;
else;
gama = 1*ones(n-1,1);
sigZreg = 1*ones(cols(datareg),1);
param_o = param_o|gama;
param_b = param_b| -plim*ones(rows(gama),1)~plim*ones(rows(gama),1);

param_o = param_o|sigZreg;
param_b = param_b| zeros(rows(sigZreg),1)~plimvar*ones(rows(sigZreg),1);
endif;

retp(A,gama,sigZreg,param_o,param_b);

/* changes from param to A */
elseif dir eq 1;
t=1;
A = A_rest*0;
param_b = miss(A*0,0);
i=1; do while i le cols(A_rest);
j=1; do while j le rows(A_rest);
if A_rest[i,j] eq 0;
A[i,j] = param[t]; t=t+1;
elseif A_rest[i,j] eq 1;
A[i,j] = param[t]; t=t+1;
elseif A_rest[i,j] eq -1;
A[i,j] = param[t]; t=t+1;

elseif A_rest[i,j] eq 10;
A[i,j] = param[t]; t=t+1;
elseif A_rest[i,j] eq 11;
A[i,j] = param[t]; t=t+1;
elseif A_rest[i,j] eq -11;
A[i,j] = param[t]; t=t+1;

elseif A_rest[i,j] eq 50;
A[i,j] = 0; t=t+1;
elseif A_rest[i,j] eq 60;
A[i,j] = 0; t=t+1;
elseif A_rest[i,j] eq 80;
elseif A_rest[i,j] eq 81;
A[i,j] = 0; t=t+1;
elseif A_rest[i,j] eq -81;
A[i,j] = 0; t=t+1;

elseif A_rest[i,j] eq 90;
A[i,j] = 0;
elseif A_rest[i,j] eq 99;
A[i,j] = 1;
else;
? "in parametros";
stop;
endif;
j=j+1; endo;
i=i+1; endo;

t=1;
param_b = miss(A*0,0);
i=1; do while i le cols(A_rest);
j=1; do while j le rows(A_rest);
if A_rest[i,j] eq 0;
A[i,j] = param[t]; t=t+1;
elseif A_rest[i,j] eq 1;
A[i,j] = param[t]; t=t+1;
elseif A_rest[i,j] eq -1;
A[i,j] = param[t]; t=t+1;

elseif A_rest[i,j] eq 10;
A[i,j] = param[t]; t=t+1;
elseif A_rest[i,j] eq 11;
A[i,j] = param[t]; t=t+1;
elseif A_rest[i,j] eq -11;
A[i,j] = param[t]; t=t+1;

elseif A_rest[i,j] eq 50;
xi = trunc(A_para[i,j]/100);
xj = A_para[i,j]-100*xi;
if (param[t]*A[xi,xj] ge 0);
A[i,j] = param[t]; t=t+1;
param_b[i,j] = 0;
else;
A[i,j] = 0; t=t+1;
param_b[i,j] = penalty*abs(param[t]);
endif;

elseif A_rest[i,j] eq 60;
xi = trunc(A_para[i,j]/100);
xj = A_para[i,j]-100*xi;
if (param[t]*A[xi,xj] le 0);
A[i,j] = param[t]; t=t+1;
param_b[i,j] = 0;
else;
A[i,j] = 0; t=t+1;
param_b[i,j] = penalty*abs(param[t]);
endif;

elseif A_rest[i,j] eq 80;
xi = trunc(A_para[i,j]/100);
xj = A_para[i,j]-100*xi;
A[i,j] = A[xi,xj];
elseif A_rest[i,j] eq 81;
xi = trunc(A_para[i,j]/100);
xj = A_para[i,j]-100*xi;
A[i,j] = A[xi,xj] + param[t]; t=t+1;
elseif A_rest[i,j] eq -81;
xi = trunc(A_para[i,j]/100);
xj = A_para[i,j]-100*xi;
A[i,j] = A[xi,xj] + param[t]; t=t+1;

elseif A_rest[i,j] eq 90;
A[i,j] = 0;
elseif A_rest[i,j] eq 99;
A[i,j] = 1;
else;
? "in parametros";
stop;
endif;
j=j+1; endo;
i=i+1; endo;

if metodocom eq 0;
gama = 0;
sigZreg = zeros(cols(datareg),1);
else;
gama = ones(n,1);
i=2; do while i le n;
gama[i] = param[t]; t=t+1;
i=i+1; endo;

sigZreg = ones(cols(datareg),1);
i=1; do while i le rows(sigZreg);
sigZreg[i] = param[t]; t=t+1;
i=i+1; endo;
endif;

retp(A,gama,sigZreg,param_o,param_b);
else;
stop;
endif;
endp;

/*********************************/
/* procedure finding the regimes */
/*********************************/
proc FindARegimes(param,Data);
local i, j, gmmprov, gmmprob, gama, sigZreg, gmmweig, xi, xj, invA, gmmred;

if metodored eq 0;
if metodocom le 1;
{A,gama,sigZreg,param_o,gmmpen} = parametros(A,A_rest,param,n,1);
gmmweig = gmmvar[1,.]/sumc(gmmvar[1,.]');

gmm = 0;
i=1; do while i le cols(DataVCX);
gmmprov = xpnd(DataVCX[.,i]);
gmmprov = A * gmmprov * A';
gmmprov = gmmprov - (gama*gama' * sigZreg[i]);
gmmprov = diagrv(gmmprov,( (diag(gmmprov).<0).*abs(diag(gmmprov))*penalty ));
gmmprov = vech(gmmprov);
gmmprov = packr(gmmprov);

gmm = gmm|(gmmprov*gmmweig[i]);
i=i+1; endo;

gmm = trimr(gmm,1,0);
gmo = gmm;
gmm = -(sumc(abs(gmm)^2));
else;
{A,gama,sigZreg,param_o,gmmpen} = parametros(A,A_rest,param_o,n,1);
gmmweig = A;

{A,gama,sigZreg,param_o,gmmpen} = parametros(A,A_rest,param,n,1);
A = gmmweig;
gmmweig = gmmvar[1,.]/sumc(gmmvar[1,.]');
gmmweig = gmmvar[1,.];

gmm = 0;
i=1; do while i le cols(DataVCX);
gmmprov = xpnd(DataVCX[.,i]);
gmmprov = A * gmmprov * A';
gmmprov = gmmprov - (gama*gama' * sigZreg[i]);
gmmprov = diagrv(gmmprov,( (diag(gmmprov).<0).*abs(diag(gmmprov))*penalty ));
gmmprov = vech(gmmprov);
gmmprov = packr(gmmprov);

gmm = gmm|(gmmprov*gmmweig[i]);
i=i+1; endo;

gmm = trimr(gmm,1,0);
gmo = gmm;
gmm = -(sumc(abs(gmm)^2))/rows(gmm);
endif;

elseif metodored eq 1;
{A,gama,sigZreg,param_o,gmmpen} = parametros(A,A_rest,param,n,1);
gmmweig = gmmvar[1,.]/sumc(gmmvar[1,.]');

gmm = 0;
i=1; do while i le cols(DataVCX);
gmmprov = xpnd(DataVCX[.,i]);
gmmprov = A * gmmprov * A';
gmmprov = gmmprov - (gama*gama' * sigZreg[i]);
gmmprov = diagrv(gmmprov,( (diag(gmmprov).<0).*abs(diag(gmmprov))*penalty ));
gmmprov = vech(gmmprov);
gmmprov = packr(gmmprov);

gmm = gmm|(gmmprov*gmmweig[i]);
i=i+1; endo;

gmm = trimr(gmm,1,0);
gmo = gmm;

/* REDUCED FROM PENALTIES */
gmmred = 0;
if det(A) eq 0;
? "you are screwed"; stop;
else;
invA = inv(A);
i=1; do while i le n;
j=1; do while j le n;
if A_redd[i,j] eq 0;
elseif A_redd[i,j] eq 1;
gmmred = gmmred | (invA[i,j]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]);
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;

But it seems not to work because the following error message appears:

c:\mteng8.0\src\xls.src(95) : error G0474 : ' xlsReadM(file, range, sheet, vls)' : Illegal creation of global
c:\mteng8.0\src\xls.src(96) : error G0017 : 'local a,r,c,err,rowsvals' : WARNING: local outside of procedure
c:\mteng8.0\src\xls.src(97) : error G0474 : 'r' : Illegal creation of global

How should be the procedure correctly run? Thanks for your support.



0



Hmmm...that is strange. Let's verify that xlsReadM and xlsWriteM are working properly for you. Run this code

new;
tmp = { 14   21,
         9  2.4 };

fname = "temp.xls";
call xlsWriteM(tmp, fname, "A1", 1, "");
tmp_2 = xlsReadM(fname, "A1", 1, "");
print "tmp_2 = " tmp_2;

and report what it returns.

aptech

1,338


0



Thanks, I found out that was an Excel problem and I fixed it. Now the code stops at line 1094, i.e. at the stop; command and the following appears:

Execution stopped in line 1094 of C:\mteng8.0\efrcode

Don't know if it clear for you, but what the whole "PROCEDURE" code below the stop; command is about?
Is that part of the code executed? Nothing about that part is been displayed in the Command Input-Output window.

A clarification about the following part of the code (from the stop; command onwards) would be really apreciated:


xlswritem(p_boot',ArchXLS, "b2", 1, 0);
xlswritem(a_boot',ArchXLS, "b2", 2, 0);
xlswritem(p_boot_stat,ArchXLS, "b2", 3, 0);
xlswritem(a_boot_stat,ArchXLS, "b2", 4, 0);
xlswritem(A_orig,ArchXLS, "b2", 5, 0);
xlswritem(inv(A_orig),ArchXLS, "b10", 5, 0);
xlswritem(vdec_orig,ArchXLS, "b18", 5, 0);
xlswritem(vdec_boot',ArchXLS, "b2", 6, 0);

clear A; clear a_boot; clear a_boot_dis; clear a_boot_mas; clear a_boot_max; clear a_boot_min; clear a_boot_stat; clear a_boot_ste; clear a_boot_tre; clear A_orig; clear A_para; clear A_redd; clear A_redp; clear A_rest; clear bb_boot; clear beta_rf; clear boot; clear d; clear Data; clear Data_e; clear DataCol; clear DataGMM; clear DataMask; clear DataNorm; clear DataOri; clear DataProv; clear DataReg; clear DataRoll; clear datatype; clear DataVCX; clear DataVCX_orig; clear DataWind; clear dd; clear dist; clear ECBData; clear gama; clear gmm; clear gmmpen; clear gmmprov; clear gmmvar; clear GMMvar_orig; clear gmmvcx; clear gmo; clear gmp; clear i; clear i_cont; clear i_ilge; clear i_ilus; clear i_isge; clear i_isus; clear i_nber; clear i_smge; clear i_smus; clear i_usge; clear invA; clear j; clear k; clear lags; clear leer; clear limit; clear metodoA; clear metodocom; clear metodoint; clear metodonor; clear metodored; clear metodoreg; clear metodoret; clear metodotim; clear metodovar; clear minobs; clear n; clear NBERDum; clear nulo; clear p_boot; clear p_boot_dis; clear p_boot_mas; clear p_boot_max; clear p_boot_min; clear p_boot_stat; clear p_boot_ste; clear p_boot_tre; clear p_c; clear p_f; clear p_g; clear p_r; clear p_x; clear p_x_orig; clear param_b; clear param_o; clear penalty; clear prov; clear resi_rf; clear sigE; clear sigEreg; clear sigEunc; clear sigz; clear sigzreg; clear sigZunc; clear t; clear v; clear vardecomp; clear vdec; clear vdec_boot; clear vdec_orig; clear win; clear winfin; clear winini; clear x; clear xx; clear xxt; clear yy;
stop;

/********************/
/********************/
/* */
/* PROCEDURES */
/* */
/********************/
/********************/

proc (5)=parametros(A,A_rest,param,n,dir);
local i,j,plim,plimvar,t,A_std,Sigma_std,param_c,cmle,xi,xj,param_b,gama, sigZreg;

cmle = 0;
plim = 100;
plimvar = 1000000000;

/* this initializes all the variables using n (number of regimes) and A_ret */
if dir eq 0;
A = zeros(n,n);
t=1;
param_o = 0;
param_b = 0~0;
i=1; do while i le n;
j=1; do while j le n;
if A_rest[i,j] eq 0;
param_o = param_o|0.005; t=t+1;
param_b = param_b|-plim~plim;
elseif A_rest[i,j] eq 1;
param_o = param_o|0.01; t=t+1;
param_b = param_b|0~plim;
elseif A_rest[i,j] eq -1;
param_o = param_o|-0.01; t=t+1;
param_b = param_b|-plim~0;

elseif A_rest[i,j] eq 10;
param_o = param_o|0.005; t=t+1;
param_b = param_b|-1~1;
elseif A_rest[i,j] eq 11;
param_o = param_o|0.01; t=t+1;
param_b = param_b|0~1;
elseif A_rest[i,j] eq -11;
param_o = param_o|-0.01; t=t+1;
param_b = param_b|-1~0;

elseif A_rest[i,j] eq 50;
param_o = param_o|0.005; t=t+1;
param_b = param_b|-plim~plim;

elseif A_rest[i,j] eq 60;
param_o = param_o|-0.01; t=t+1;
param_b = param_b|-plim~plim;

elseif A_rest[i,j] eq 80;
elseif A_rest[i,j] eq 81;
param_o = param_o|0.01; t=t+1;
param_b = param_b|0~1;
elseif A_rest[i,j] eq -81;
param_o = param_o|-0.01; t=t+1;
param_b = param_b|-1~0;

elseif A_rest[i,j] eq 90;
elseif A_rest[i,j] eq 99;
a[i,j] = 1;
else;
? "PROBLEM"; stop;
endif;
j=j+1; endo;
i=i+1; endo;
param_o = trimr(param_o,1,0);
param_b = trimr(param_b,1,0);

if metodocom eq 0;
gama = 0;
sigZreg = 0;
else;
gama = 1*ones(n-1,1);
sigZreg = 1*ones(cols(datareg),1);
param_o = param_o|gama;
param_b = param_b| -plim*ones(rows(gama),1)~plim*ones(rows(gama),1);

param_o = param_o|sigZreg;
param_b = param_b| zeros(rows(sigZreg),1)~plimvar*ones(rows(sigZreg),1);
endif;

retp(A,gama,sigZreg,param_o,param_b);

/* changes from param to A */
elseif dir eq 1;
t=1;
A = A_rest*0;
param_b = miss(A*0,0);
i=1; do while i le cols(A_rest);
j=1; do while j le rows(A_rest);
if A_rest[i,j] eq 0;
A[i,j] = param[t]; t=t+1;
elseif A_rest[i,j] eq 1;
A[i,j] = param[t]; t=t+1;
elseif A_rest[i,j] eq -1;
A[i,j] = param[t]; t=t+1;

elseif A_rest[i,j] eq 10;
A[i,j] = param[t]; t=t+1;
elseif A_rest[i,j] eq 11;
A[i,j] = param[t]; t=t+1;
elseif A_rest[i,j] eq -11;
A[i,j] = param[t]; t=t+1;

elseif A_rest[i,j] eq 50;
A[i,j] = 0; t=t+1;
elseif A_rest[i,j] eq 60;
A[i,j] = 0; t=t+1;
elseif A_rest[i,j] eq 80;
elseif A_rest[i,j] eq 81;
A[i,j] = 0; t=t+1;
elseif A_rest[i,j] eq -81;
A[i,j] = 0; t=t+1;

elseif A_rest[i,j] eq 90;
A[i,j] = 0;
elseif A_rest[i,j] eq 99;
A[i,j] = 1;
else;
? "in parametros";
stop;
endif;
j=j+1; endo;
i=i+1; endo;

t=1;
param_b = miss(A*0,0);
i=1; do while i le cols(A_rest);
j=1; do while j le rows(A_rest);
if A_rest[i,j] eq 0;
A[i,j] = param[t]; t=t+1;
elseif A_rest[i,j] eq 1;
A[i,j] = param[t]; t=t+1;
elseif A_rest[i,j] eq -1;
A[i,j] = param[t]; t=t+1;

elseif A_rest[i,j] eq 10;
A[i,j] = param[t]; t=t+1;
elseif A_rest[i,j] eq 11;
A[i,j] = param[t]; t=t+1;
elseif A_rest[i,j] eq -11;
A[i,j] = param[t]; t=t+1;

elseif A_rest[i,j] eq 50;
xi = trunc(A_para[i,j]/100);
xj = A_para[i,j]-100*xi;
if (param[t]*A[xi,xj] ge 0);
A[i,j] = param[t]; t=t+1;
param_b[i,j] = 0;
else;
A[i,j] = 0; t=t+1;
param_b[i,j] = penalty*abs(param[t]);
endif;

elseif A_rest[i,j] eq 60;
xi = trunc(A_para[i,j]/100);
xj = A_para[i,j]-100*xi;
if (param[t]*A[xi,xj] le 0);
A[i,j] = param[t]; t=t+1;
param_b[i,j] = 0;
else;
A[i,j] = 0; t=t+1;
param_b[i,j] = penalty*abs(param[t]);
endif;

elseif A_rest[i,j] eq 80;
xi = trunc(A_para[i,j]/100);
xj = A_para[i,j]-100*xi;
A[i,j] = A[xi,xj];
elseif A_rest[i,j] eq 81;
xi = trunc(A_para[i,j]/100);
xj = A_para[i,j]-100*xi;
A[i,j] = A[xi,xj] + param[t]; t=t+1;
elseif A_rest[i,j] eq -81;
xi = trunc(A_para[i,j]/100);
xj = A_para[i,j]-100*xi;
A[i,j] = A[xi,xj] + param[t]; t=t+1;

elseif A_rest[i,j] eq 90;
A[i,j] = 0;
elseif A_rest[i,j] eq 99;
A[i,j] = 1;
else;
? "in parametros";
stop;
endif;
j=j+1; endo;
i=i+1; endo;

if metodocom eq 0;
gama = 0;
sigZreg = zeros(cols(datareg),1);
else;
gama = ones(n,1);
i=2; do while i le n;
gama[i] = param[t]; t=t+1;
i=i+1; endo;

sigZreg = ones(cols(datareg),1);
i=1; do while i le rows(sigZreg);
sigZreg[i] = param[t]; t=t+1;
i=i+1; endo;
endif;

retp(A,gama,sigZreg,param_o,param_b);
else;
stop;
endif;
endp;

/*********************************/
/* procedure finding the regimes */
/*********************************/
proc FindARegimes(param,Data);
local i, j, gmmprov, gmmprob, gama, sigZreg, gmmweig, xi, xj, invA, gmmred;

if metodored eq 0;
if metodocom le 1;
{A,gama,sigZreg,param_o,gmmpen} = parametros(A,A_rest,param,n,1);
gmmweig = gmmvar[1,.]/sumc(gmmvar[1,.]');

gmm = 0;
i=1; do while i le cols(DataVCX);
gmmprov = xpnd(DataVCX[.,i]);
gmmprov = A * gmmprov * A';
gmmprov = gmmprov - (gama*gama' * sigZreg[i]);
gmmprov = diagrv(gmmprov,( (diag(gmmprov).<0).*abs(diag(gmmprov))*penalty ));
gmmprov = vech(gmmprov);
gmmprov = packr(gmmprov);

gmm = gmm|(gmmprov*gmmweig[i]);
i=i+1; endo;

gmm = trimr(gmm,1,0);
gmo = gmm;
gmm = -(sumc(abs(gmm)^2));
else;
{A,gama,sigZreg,param_o,gmmpen} = parametros(A,A_rest,param_o,n,1);
gmmweig = A;

{A,gama,sigZreg,param_o,gmmpen} = parametros(A,A_rest,param,n,1);
A = gmmweig;
gmmweig = gmmvar[1,.]/sumc(gmmvar[1,.]');
gmmweig = gmmvar[1,.];

gmm = 0;
i=1; do while i le cols(DataVCX);
gmmprov = xpnd(DataVCX[.,i]);
gmmprov = A * gmmprov * A';
gmmprov = gmmprov - (gama*gama' * sigZreg[i]);
gmmprov = diagrv(gmmprov,( (diag(gmmprov).<0).*abs(diag(gmmprov))*penalty ));
gmmprov = vech(gmmprov);
gmmprov = packr(gmmprov);

gmm = gmm|(gmmprov*gmmweig[i]);
i=i+1; endo;

gmm = trimr(gmm,1,0);
gmo = gmm;
gmm = -(sumc(abs(gmm)^2))/rows(gmm);
endif;

elseif metodored eq 1;
{A,gama,sigZreg,param_o,gmmpen} = parametros(A,A_rest,param,n,1);
gmmweig = gmmvar[1,.]/sumc(gmmvar[1,.]');

gmm = 0;
i=1; do while i le cols(DataVCX);
gmmprov = xpnd(DataVCX[.,i]);
gmmprov = A * gmmprov * A';
gmmprov = gmmprov - (gama*gama' * sigZreg[i]);
gmmprov = diagrv(gmmprov,( (diag(gmmprov).<0).*abs(diag(gmmprov))*penalty ));
gmmprov = vech(gmmprov);
gmmprov = packr(gmmprov);

gmm = gmm|(gmmprov*gmmweig[i]);
i=i+1; endo;

gmm = trimr(gmm,1,0);
gmo = gmm;

/* REDUCED FROM PENALTIES */
gmmred = 0;
if det(A) eq 0;
? "you are screwed"; stop;
else;
invA = inv(A);
i=1; do while i le n;
j=1; do while j le n;
if A_redd[i,j] eq 0;
elseif A_redd[i,j] eq 1;
gmmred = gmmred | (invA[i,j]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]);
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;

Thanks.



0



The section of the code below the stop command and the comment

/********************/
/********************/
/* */
/* PROCEDURES */
/* */
/********************/
/********************/

contains the GAUSS procedures that they presumably use other places in the code. A GAUSS procedure is just a way for you to create your own GAUSS function. For example, we can build our own GAUSS procedure named hypotenuse to compute the hypotenuse of a triangle like this:

a = 3;
b = 4;
c = hypotenuse(a, b);
print "c = " c;

proc (1) = hypotenuse(a, b);
   local c;
   c = a.^2 + b.^2;
   retp(sqrt(c));
endp;

The above code will print out:

c = 5.00

The GAUSS stop command will end a GAUSS program. Sometimes GAUSS users place a stop command after the main program and before the procedures to notify the user that only user-defined procedures are below (i.e. no more main code is below in the file). We can see this, by adding the stop command to our simple program above and seeing that they run exactly the same:

a = 3;
b = 4;
c = hypotenuse(a, b);
print "c = " c;

stop;

proc (1) = hypotenuse(a, b);
   local c;
   c = a.^2 + b.^2;
   retp(sqrt(c));
endp;

aptech

1,338


0



Many thanks for the clarification. Would you be so kind to help me with the following part of the same code (it is used to create "rolling windows variances of 20 2-day observations for each variable", as explained by the author, and knowing that "a regime is identified by having at least 16 observations for which the relative variances of one or several asset returns exceed their average value plus one standard deviation"):

/* rolling window of second moments */
? "creating the regimes";

DataRoll = ones(win,1)*sqrt(diag(vcx(packr(Data[.,DataCol+1:Cols(Data)]))))';
i=win+1;
do while i le rows(Data);
    DataRoll = DataRoll | sqrt(diag(vcx(Data[i:i-win,DataCol+1:Cols(Data)])))';
    i=i+1;
endo;

Data     = Data.*miss(1-(missrv(DataRoll[.,1],nulo).==nulo),0);

Data     = packr(Data);
DataRoll = packr(DataRoll);

DataWind = DataRoll[1,.]+limit*sqrt(diag(vcx(DataRoll)))';
DataWind = (DataRoll.>DataWind);
? rows(data)~rows(dataroll);

/* 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);
        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;
            DataReg  = DataReg~DataProv;
        endif;
        i=i+1;
    endo;
endif;

Considering that above that part of the code the following is set (please let me know if you need any other information in order to understand the code):

win       = 20;             /* number of consecutive observations to compute 
                                the rolling window      */
limit     = 1.0;
minobs    = 4*4;

How should I change the code in order to create windows of single-day observation instead of 2?
Thanks for your time.



0



Am I correct to say that you want to end up with 'rolling window variances of 20 1 day observations for each variable'? How is your data set up? I assume each column is a different variable. Is each row a daily observation?

aptech

1,338


0



Actually, the original dataset (used by the code I posted) had a daily frequency and the code was intended to build rolling window variances of 20 2-day observations for each variable. The dataset I would like to use now has weekly frequancy, thus I would like to end up with rolling window variances of 20 1-week observations for each variable.
Indeed, each column is a different variable and dates in DataCol are expressed as sequential numbers with 7 units gap between each other (e.g. my first observation is dated "38261" and the second one is dated "38268"). Please note that I am considering to re-date them as well, if it would help to implement the code.



0



Dear Valentina,

 

Did you manage to make the code in the end run and give the correct results ?

 

Do you by chance still have the file?

 

 

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