Error in seo and shin program

I don't know why i got this error, in my knowledge this is the part of program of seo and shin that i can't modified. please can you help me.

 

Line 256 in C:\Users\fayrouz\Desktop\prog modifié Fairouz.prg
Nested procedure definition G0155
Line 256 in C:\Users\fayrouz\Desktop\prog modifié Fairouz.prg
Syntax error G0008 : 'proc weight(n,t,de,w,t0)'
Closing: C:\Users\fayrouz\Desktop\prog modifié Fairouz.prg

 

the line 256 in the program is in bold:

/* input:
de: residuals
w : IV's
*/

proc weight(n,t,de,w,t0); // with given residuals
local v,vbar,i,dei,wi,iv;

5 Answers



0



The error Nested procedure definition G0155 means that there is a procedure inside of a procedure, like this:

// Start of procedure
proc (1) = hypotenuse(a, b);
    local c, a2, b2;

    // Start of procedure definition INSIDE
    // another procedure definition which is an
    // illegal 'nested procedure definition'
    proc (1) = square(x);
        retp(a .^ 2);
    endp;

    a2 = square(a);
    b2 = square(b);
    retp(sqrt(a2 + b2));
endp;

Does your code have a nested procedure definition like this?

aptech

1,773


0



yes I have in my code a nested procedure:

proc setiv(n,t,y,x,t0,jmy,jmx,jn);
    local er,er1,j,k,m,i,zyi,zxi,wi,sr,w,sj,mj;

    k = cols(x); // x[.,1]=1
    w = {};
    for i (1,n,1);
        zyi = y[(i-1)*(t)+1:i*(t)]; // (t)x1
        zxi = x[(i-1)*(t)+1:i*(t),.]; // (t)xk
        wi = {}; // (t-t0+1)xm
        er = 0;
        er1=0; // scalar

        for j (1,t-t0+1,1);
            sj = j+t0-jn-3;
            mj = 1+ minc(jmy|sj);
            wi = wi~zeros(t-t0+1,mj);
            sr = er+1; // scalar
            er1 = er+ mj; // scalar
            er = er1;
            wi[j,sr:er1]=1~zyi[maxc(1|sj-jmy+1):sj]';

            if k > 1;
                mj = (-1+k)*minc(jmx|sj);
                wi = wi~zeros(t-t0+1,mj);
                er = er1+ mj; // scalar
                wi[j,er1+1:er]= vec(zxi[maxc(1|sj-jmx+1):sj,2:k])';
            endif;
        endfor;

        w = w|wi; // (t-t0+1)xm
    endfor;
    retp(w);
endp;

/* input:
de: residuals
w : IV's
*/

proc weight(n,t,de,w,t0); // with given residuals
    local v,vbar,i,dei,wi,iv;

    v = 0; // scalar
    vbar = 0;

    for i (1,n,1);
        dei = de[(i-1)*(t-t0+1)+1:i*(t-t0+1),.]; // (t-2)x1
        wi = w[(i-1)*(t-t0+1)+1:i*(t-t0+1),.]'dei; // m x 1
        v = v + wi*wi'; // mxm
        vbar = vbar + wi; // mx1

    endfor;
    if rank(v/n-(vbar/n)*(vbar/n)') == cols(w);
        iv = inv(v/n-(vbar/n)*(vbar/n)'); // mxm
    else;
        "error 2";
        iv = invswp(v/n-(vbar/n)*(vbar/n)');
    endif;

    retp(iv);
endp;

proc weight1(n,t,w,t0); //analytic
    local m,v,i,j,wi,wj,iv;

    m = cols(w); // number of moments
    v = zeros(m+2,m+2);

    for i (1,n,1);
        wi = zeros(t-t0+3,m+2);
        wi[2:t-t0+2,2:m+1] = w[(i-1)*(t-t0+1)+1:i*(t-t0+1),.];

        for j (1,t-t0+2,1);
            wj = wi[j,.]'-wi[j+1,.]';
            v = v + wj*wj'; // mxm
        endfor;
    endfor;

    v = v[2:(m+1),2:(m+1)];
    if rank(v/n) == cols(w);
        iv = inv(v/n); // mxm
    else;
        "error";
        iv = invswp(v/n);
    endif;

    retp(iv);
endp;

// ===========================================================================
proc (1) = lagnmatrix(n,t,x,p);
    local k,lx,i;
    k = cols(x);
    lx = zeros(n*t,k);
    for i (1,k,1);
        lx[.,i] = vec(lagn(reshape(x[.,i],n,t)',p)); // ntx1
    endfor;

    retp(lx);
endp;

proc (1) = trimrmatrix(n,t,x,p,q);
    local k,y,i;
    k = cols(x);
    y = zeros(n*(t-p-q),k);
    for i (1,k,1);
        y[.,i] = vec(trimr(reshape(x[.,i],n,t)',p,q));
    endfor;
    retp(y);
endp;

// ===========================================================================
//outputs:
//dum1: s.e.; dum2: upper regime estimates and s.e.;
//dum3: long-run parameter estimates and s.e. dum4: Jstat and p-value

proc (4) = printout(n,t,t0,w,dy,q,ththat1,z1,z2,Jhat1,_con);
local dumm1,z,lz,dz,tmp,dehat1,iv,Gb,h,kn,s,ds,i,si,Gr,
sb1,sg1,se1,k2,p,tht2hat,se2,bt1,phi1,p1,bse1,bt2,phi2,p2,bse2,bt,bse;



0



It is possible that I missed it, but I do not see a nested procedure. I see a few procedures, but each of them is defined separately. They all open with the proc statement and end with the endp statement.

Do you see the difference between the nested procedure I wrote earlier, where a new proc is started INSIDE another proc, compared to yours where there are just a few separate procs?

Do you have the link from which you downloaded this code?

aptech

1,773


0



this is the link, the program is named invest03.prg.zip

https://sites.google.com/site/myunghseo/programs



0



I still have the same error and i don't know why? I can understand that is not a nested procedure but how can I fix this ?

Your Answer

5 Answers

0

The error Nested procedure definition G0155 means that there is a procedure inside of a procedure, like this:

// Start of procedure
proc (1) = hypotenuse(a, b);
    local c, a2, b2;

    // Start of procedure definition INSIDE
    // another procedure definition which is an
    // illegal 'nested procedure definition'
    proc (1) = square(x);
        retp(a .^ 2);
    endp;

    a2 = square(a);
    b2 = square(b);
    retp(sqrt(a2 + b2));
endp;

Does your code have a nested procedure definition like this?

0

yes I have in my code a nested procedure:

proc setiv(n,t,y,x,t0,jmy,jmx,jn);
    local er,er1,j,k,m,i,zyi,zxi,wi,sr,w,sj,mj;

    k = cols(x); // x[.,1]=1
    w = {};
    for i (1,n,1);
        zyi = y[(i-1)*(t)+1:i*(t)]; // (t)x1
        zxi = x[(i-1)*(t)+1:i*(t),.]; // (t)xk
        wi = {}; // (t-t0+1)xm
        er = 0;
        er1=0; // scalar

        for j (1,t-t0+1,1);
            sj = j+t0-jn-3;
            mj = 1+ minc(jmy|sj);
            wi = wi~zeros(t-t0+1,mj);
            sr = er+1; // scalar
            er1 = er+ mj; // scalar
            er = er1;
            wi[j,sr:er1]=1~zyi[maxc(1|sj-jmy+1):sj]';

            if k > 1;
                mj = (-1+k)*minc(jmx|sj);
                wi = wi~zeros(t-t0+1,mj);
                er = er1+ mj; // scalar
                wi[j,er1+1:er]= vec(zxi[maxc(1|sj-jmx+1):sj,2:k])';
            endif;
        endfor;

        w = w|wi; // (t-t0+1)xm
    endfor;
    retp(w);
endp;

/* input:
de: residuals
w : IV's
*/

proc weight(n,t,de,w,t0); // with given residuals
    local v,vbar,i,dei,wi,iv;

    v = 0; // scalar
    vbar = 0;

    for i (1,n,1);
        dei = de[(i-1)*(t-t0+1)+1:i*(t-t0+1),.]; // (t-2)x1
        wi = w[(i-1)*(t-t0+1)+1:i*(t-t0+1),.]'dei; // m x 1
        v = v + wi*wi'; // mxm
        vbar = vbar + wi; // mx1

    endfor;
    if rank(v/n-(vbar/n)*(vbar/n)') == cols(w);
        iv = inv(v/n-(vbar/n)*(vbar/n)'); // mxm
    else;
        "error 2";
        iv = invswp(v/n-(vbar/n)*(vbar/n)');
    endif;

    retp(iv);
endp;

proc weight1(n,t,w,t0); //analytic
    local m,v,i,j,wi,wj,iv;

    m = cols(w); // number of moments
    v = zeros(m+2,m+2);

    for i (1,n,1);
        wi = zeros(t-t0+3,m+2);
        wi[2:t-t0+2,2:m+1] = w[(i-1)*(t-t0+1)+1:i*(t-t0+1),.];

        for j (1,t-t0+2,1);
            wj = wi[j,.]'-wi[j+1,.]';
            v = v + wj*wj'; // mxm
        endfor;
    endfor;

    v = v[2:(m+1),2:(m+1)];
    if rank(v/n) == cols(w);
        iv = inv(v/n); // mxm
    else;
        "error";
        iv = invswp(v/n);
    endif;

    retp(iv);
endp;

// ===========================================================================
proc (1) = lagnmatrix(n,t,x,p);
    local k,lx,i;
    k = cols(x);
    lx = zeros(n*t,k);
    for i (1,k,1);
        lx[.,i] = vec(lagn(reshape(x[.,i],n,t)',p)); // ntx1
    endfor;

    retp(lx);
endp;

proc (1) = trimrmatrix(n,t,x,p,q);
    local k,y,i;
    k = cols(x);
    y = zeros(n*(t-p-q),k);
    for i (1,k,1);
        y[.,i] = vec(trimr(reshape(x[.,i],n,t)',p,q));
    endfor;
    retp(y);
endp;

// ===========================================================================
//outputs:
//dum1: s.e.; dum2: upper regime estimates and s.e.;
//dum3: long-run parameter estimates and s.e. dum4: Jstat and p-value

proc (4) = printout(n,t,t0,w,dy,q,ththat1,z1,z2,Jhat1,_con);
local dumm1,z,lz,dz,tmp,dehat1,iv,Gb,h,kn,s,ds,i,si,Gr,
sb1,sg1,se1,k2,p,tht2hat,se2,bt1,phi1,p1,bse1,bt2,phi2,p2,bse2,bt,bse;

0

It is possible that I missed it, but I do not see a nested procedure. I see a few procedures, but each of them is defined separately. They all open with the proc statement and end with the endp statement.

Do you see the difference between the nested procedure I wrote earlier, where a new proc is started INSIDE another proc, compared to yours where there are just a few separate procs?

Do you have the link from which you downloaded this code?

0

this is the link, the program is named invest03.prg.zip

https://sites.google.com/site/myunghseo/programs

0

I still have the same error and i don't know why? I can understand that is not a nested procedure but how can I fix this ?


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.