Matrices are not conformable (ss=gf*omega*gf')

In the following program for ECS estimation, showing error in line 37. Can you please help me to solve it? Thanks.

clear p, pold, y, x, h, z, zz, delp;
let h0 = 60;
let h1 = 40;
let ph = 0.5;
y0 = 720;
num = 20;
let b = 4.95 -14.22 0.082;
let omega = .01 0 0
    0 9 .04
    0 .04 .0004;
omega = .01*omega;
call ecs;
proc q(x,p);
    local y;
    p = x[1];
    y = x[2];
    z = b[1] + b[2]*p + b[3]*y;
    retp(z);
endp;
@====================================@
proc 0= ecs;
    local del, tcs, g, gf, vh, vy, lam, nety, p0, p1, i, cs, dwl, dpdx, ss, covy, np, ny, nb, nh;
    clear delp, tcs, vy;
    del = (h1-h0)/num;
    h = h0;
    y = y0;
    p = ph;
    pold = p;
    nh= rows(h);
    nb= rows(b);
    i= 1;
    do until i>num;
        nety= y-h'ph;
        zz= h|nety;
        p= px(zz);
        delp = p-pold;
        pold = p;
        g = gradp(&px,zz);
        gf = gradp(&pb,b);
        dpdx = g[.,1:nh]-g[.,nh+1]*pold';
        cs = -del'pold-.5*del'dpdx*del+del'ph;
        ss = gf*omega*gf';
        lam = del'g[.,nh+1];
        if (h == h0);
            vy = del'ss*del;
            covy = zeros(nb,1);
        else;
            vy = vy.*(1-lam)^2+del'ss*del.*(3-2*lam)+2*(lam-1)*del'gf*covy;
            covy = covy - omega*gf'del;
        endif;
        tcs = tcs + cs;
        h = h + del;
        y = y + cs;
        i = i + 1;
    endo;
    "TCS =" tcs;
    "stder TCS=" sqrt(vy);
endp;
proc pv (z,b);
    local i, g, h, nety, nh, f, pp0;
    nh = rows(z)-1;
    h = z[1:nh];
    nety = z[nh+1];
    p = pold + delp;
    pp0=p;
    i=1;
    do until i>500;
        x=p|(nety+h'p[1:nh]);
        f=h-q(x,b);
        g=gradp(&qx,x);
        p=p+inv(g[.,1:nh])*f;
        if abs(p-pp0)<0.000001;
            retp(p);
        endif;
        pp0=p;
        i=i+1;
    endo;
    "not converged";
    end;
endp;
proc px(zz);
    retp(pv(zz,b));
endp;
proc pb(b);
    retp(pv(zz,b));
endp;
proc qx(x);
    retp(q(x,b));
endp;
@======================================@

3 Answers



0



Matrices problems are solved. I used omega[3,3].

But, I am not getting the value of standard error. It only showing zero for all.

Can you please help me to solve this problem?

Thanks



0



I think you might prefer creating matrices in this manner:

omega = { .01 0 0,
        0   9   .04,
        0 .04 .0004 };

where commas separate rows and spaces separate elements in the row. I think it is a little more clear.

Now to the standard error. We can see that the GAUSS variable being printed as the standard error is:

"stder TCS=" sqrt(vy);

The variable vy is assigned to in only two locations:

vy = vy.*(1-lam)^2+del'ss*del.*(3-2*lam)+2*(lam-1)*del'gf*covy;

and

vy = del'ss*del;

I ran the code using the GAUSS debugger so I could stop on these lines and look at the value of the variables. It turns out that ss is always zero, because the assignment to gf here:

gf = gradp(&pb,b);

is always zero on every iteration. You should look into this.

aptech

1,773


0



Thank you very much.

I tried to solve it. But, I could not. Do you have any suggestion?

Your Answer

3 Answers

0

Matrices problems are solved. I used omega[3,3].

But, I am not getting the value of standard error. It only showing zero for all.

Can you please help me to solve this problem?

Thanks

0

I think you might prefer creating matrices in this manner:

omega = { .01 0 0,
        0   9   .04,
        0 .04 .0004 };

where commas separate rows and spaces separate elements in the row. I think it is a little more clear.

Now to the standard error. We can see that the GAUSS variable being printed as the standard error is:

"stder TCS=" sqrt(vy);

The variable vy is assigned to in only two locations:

vy = vy.*(1-lam)^2+del'ss*del.*(3-2*lam)+2*(lam-1)*del'gf*covy;

and

vy = del'ss*del;

I ran the code using the GAUSS debugger so I could stop on these lines and look at the value of the variables. It turns out that ss is always zero, because the assignment to gf here:

gf = gradp(&pb,b);

is always zero on every iteration. You should look into this.

0

Thank you very much.

I tried to solve it. But, I could not. Do you have any suggestion?


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 14 days for FREE

See what GAUSS can do for your data

© Aptech Systems, Inc. All rights reserved.

Privacy Policy