# laubach and williams code

hi everyone

I'm using laubach and williams code in order to estimate the natural rate of interest. I'm a beginner in gauss.

i'm trying to inverse my matrix . But it doesn't work.

i have this error "matrix not positive define"

when i print my matrix, i see that my matrix is full of zero

What can i do?

Thank you

0

The error "matrix not positive definite" happens when you are trying to invert a matrix using the function, invpd. The invpd function requires that the input matrix is positive definite. Most of the time it is used to invert a moment matrix (X'X) which should be positive definite unless there is some linear dependence in the variables.

When you say your matrix is full of zeros, do you mean that it is entirely zeros? Or that it just has quite a few of them? You might be having a problem loading your data correctly. Can you post a link to the code so we can offer more help?

aptech

1,773

0

I mean when i use the function "print" to see my matrix. I see that it's entirely zeros

0

If your matrix is entirely zeros, then it is certainly singular. Does the program simulate data, or is this data that you loaded from a file?

aptech

1,773

0

thank you again

well,

here is my code

``````/* ----------------------------------------------------------------------
rstar_s1.g: First-stage estimation of the model without hours in
---------------------------------------------------------------------- */

library optmum;
optset;
output file = /mq/home/m1hxl00/work/nri/nrv2/n2v1.out reset;
format /rd 8,4;

dat[.,5] = dat[.,5]-dat[.,3]; /* Relative oil price inflation */
dat[.,6] = dat[.,6]-dat[.,3]; /* Relative import price inflation */
dat[.,7] = dat[.,7]-dat[.,4]; /* Ex ante real rate */
mv = miss(0,0);

nt = 166; /* Sample 61:1 - 02:2 */
nar = 7; /* Number of regressors */
nsv = 3; /* Number of state variables */
nst = nt; /* Startup periods for filter */
niter = 1000; /* Number of draws for generating error bands */
seed1 = 40;
indx = 0; /* Index for initialisation of P(0|0) during MC simulation */

/* Setting up system matrices:
a1 filtered state a(t|t)
a2 smoothed state a(t|T)
p1s covariance matrix of filtered state
p2s covariance matrix of smoothed state
b coefficients on explanatory variables in measurement equation
xr regressor matrix in measurement equation
z coefficients on state vector in measurement equation
h covariance matrix of measurement equation error
t transition matrix in transition equation
q covariance matrix of transition equation error */

a1 = zeros(nt+1,nsv);
a2 = zeros(nt+1,nsv);
p1s = zeros(nst*nsv,nsv);
p2s = zeros(nst*nsv,nsv);
b = zeros(2,nar);
z = zeros(2,nsv);
h = zeros(2,2);
t = zeros(nsv,nsv);
t[1:2,1] = ones(2,1);
t[3,2] = 1;
q = zeros(nsv,nsv);

/* Computing starting values for parameters */

/* Potential XBO proxied by segmented trend 60:1 to 00:4 */
xr = ones(nt+4,1)~seqa(1,1,nt+4);
xr = xr~(zeros(56,1)|seqa(1,1,nt-52))~(zeros(142,1)|seqa(1,1,nt-138));
xi = invpd(xr'xr);
bpot = xi*xr'dat[49:nt+52,1];
gpot = xr*bpot;
gap = 100*(dat[49:nt+52,1]-xr*bpot);

/* IS equation */
yis = gap[5:nt+4];
xis = gap[4:nt+3]~gap[3:nt+2];
//******************************************
//Line below fails
bis = invpd(xis'xis)*xis'yis;
ris = yis-xis*bis;
sis = sqrt(ris'ris/(nt-cols(xis)));

/* Phillips equation */
yph = dat[53:nt+52,3];
xph = dat[52:nt+51,3]~(dat[51:nt+50,3]+dat[50:nt+49,3]+dat[49:nt+48,3])/3;
xph = xph~(dat[48:nt+47,3]+dat[47:nt+46,3]+dat[46:nt+45,3]+dat[45:nt+44,3])/4;
xph = xph~gap[4:nt+3]~dat[52:nt+51,5]~dat[53:nt+52,6];
//******************************************
//Line below fails
bph = invpd(xph'xph)*xph'yph;
rph = yph-xph*bph;
sph = sqrt(rph'rph/(nt-cols(xph)));

/* Transition equation std devs */
s3 = 0.5;
d = 0.85;

/* Constructing data matrices and vector of initial values */
y = 100*dat[53:nt+52,1]~yph;
xr = 100*(dat[52:nt+51,1]~dat[51:nt+50,1])~xph[.,1:3]~xph[.,5:6];

startv = bis|bph[1:2]|bph[4:6]|d|sis|sph|s3;

output on;
"Starting values";
startv';
"";
output off;

err = reshape(mv,nt,2);
lf = reshape(mv,nt,1);
{val,f,g,retcode} = optmum(&li,startv);

/* res stores smoothed state, ref stores filtered state */

res = a2[2:nt+1,1];
ref = a1[2:nt+1,1];

/* Initial smoothed state and its covariance matrix are stored for
generating random draws during simulations */
stin = a2[2,.];
pp1 = p2s[1:nsv,.];
{tx,ty} = eigrs2(pp1);
dg = diagrv(eye(rows(tx)),tx);
hh2 = ty*sqrt(dg);

llf = lf;
dval = maxc(10^(-6)*abs(val')|ones(1,rows(val))*10^(-6));
bval = reshape(val,rows(val),rows(val))';
bval = diagrv(bval,val+dval);
i = 1;
do while i <= rows(val);
call li(bval[.,i]);
llf = llf~lf;
i = i+1;
endo;
llf = (llf[.,2:rows(val)+1]-llf[.,1])./dval';
info = invpd(llf'llf);
bse = sqrt(diag(info));

output on;
"Likelihood value";
-f;
"";
"MLE Parameters of Model, SE, t Statistics";
val~bse~(abs(val)./bse);
"";
"Sum of coeffs on gap in IS equation";
sumc(val[1:2]);
"";

"Box-Pierce Q Statistics, L = 1,...,16, and 5% critical values";
bpq = zeros(16,2);
i = 1;
do while i <= 16;
bpq[i,1] = ((err[1+i:nt,1]'err[1:nt-i,1])/(err[.,1]'err[.,1]))^2;
bpq[i,2] = ((err[1+i:nt,2]'err[1:nt-i,2])/(err[.,2]'err[.,2]))^2;
i = i+1;
endo;

i = 2;
do while i <= 16;
bpq[i,.] = bpq[i,.]+bpq[i-1,.];
i = i+1;
endo;
cv = {3.84,5.99,7.82,9.49,11.07,12.59,14.07,15.51,16.92,18.31,
19.68,21.03,22.36,23.69,25,26.3};
nt*bpq~cv;
"";

/* Computing error bands for state vector using Monte Carlo */

indx = 1; /* Switches computation of initial state from GLS to draw */
cum1 = zeros(nt,1);
cum2 = zeros(nt,1);
{tx,ty} = eigrs2(info);
dg = diagrv(eye(rows(tx)),tx);
hh = ty*sqrt(dg);
i = 1;
do while i <= niter;
theta = hh*rndns(rows(val),1,seed1)+val;
call li(theta);
cum1 = cum1+(a2[2:nt+1,1]-res[.,1]).*(a2[2:nt+1,1]-res[.,1]);
j = 1;
do while j <= nst-1;
cum2[j] = cum2[j]+p2s[j*nsv+1,1];
j = j+1;
endo;
cum2[nst:nt] = cum2[nst:nt]+ones(nt-nst+1,1)*p1s[(nst-1)*nsv+1,1];
i = i+1;
endo;
cum1 = cum1/niter;
cum2 = cum2/niter;
bnd2 = sqrt(cum1+cum2);

"Mean SE";
meanc(bnd2);
(100*dat[53:nt+52,1]-res[.,1])~bnd2;
res/100;

end;
/* ----- Define the log likelihood function for each observation ------*/
proc li(inp);
local p1,p2,i,f,fi,k,ldf,vv,j,flag1,c,x,om,yy,tmp;

/* Insert parameters into system matrices */

a1 = zeros(nt+1,nsv);
a2 = zeros(nt+1,nsv);
p1s = zeros(nst*nsv,nsv);
p2s = zeros(nst*nsv,nsv);
b = zeros(2,cols(xr));
b[1,1:2] = inp[1:2]';
b[2,1] = inp[5];
b[2,3:4] = inp[3:4]';
b[2,5] = 1-sumc(inp[3:4]);
b[2,6:7] = inp[6:7]';
z[1,1] = 1;
z[1,2:3] = -inp[1:2]';
z[2,2] = -inp[5];
c = inp[8]|zeros(nsv-1,1);
h[1,1] = inp[9]^2;
h[2,2] = inp[10]^2;
q[1,1] = inp[11]^2;

/* Starting values for a(0|0), P(0|0) */

if indx eq 1;
p1 = pp1;
a1[1,.] = (hh2*rndns(nsv,1,seed1)+stin')';
goto flag1;
endif;

x = z|z*t|z*t*t|z*t*t*t;
om = zeros(8,8);

/* First initialize lower triangular off-diagonal elements */
om[5:6,3:4] = z*t*q*z';
om[7:8,3:4] = z*t*t*q*z';
om[7:8,5:6] = z*(t*t*q*t'+t*q)*z';
/* Initialize upper triangular off-diagonal elements by adding transpose */
om = om+om';
/* Initialize diagonal elements */
om[1:2,1:2] = h;
om[3:4,3:4] = z*q*z'+h;
om[5:6,5:6] = z*(t*q*t'+q)*z'+h;
om[7:8,7:8] = z*(t*t*q*t'*t'+t*q*t'+q)*z'+h;

if det(om) le 10^(-6);
"om" det(om);
a1[1,.] = 100*gpot[5:3]';
p1 = 2*eye(nsv);
goto flag1;
endif;
om = invpd(om);
if det(x'om*x) le 10^(-6);
"x'om*x" det(x'om*x);
a1[1,.] = 100*gpot[5:3]';
p1 = 2*eye(nsv);
goto flag1;
endif;
p1 = invpd(x'om*x);
yy = y[1,.]'|y[2,.]'|y[3,.]'|y[4,.]';
tmp = b*xr[1,.]'|(b*xr[2,.]'+z*c)|(b*xr[3,.]'+z*c+z*t*c);
tmp = tmp|(b*xr[4,.]'+z*(eye(nsv)+t+t*t)*c);
a1[1,.] = (p1*x'om*(yy-tmp))';
tmp = yy-tmp-x*a1[1,.]';
p1 = p1*(tmp'tmp)/3;

flag1:

lf = zeros(nt,1);

/* Starting the Kalman filter:
a1 stores a(t|t), t = 0,...,nt, a2 stores a(t|t-1), t = 1,...,nt
p1s stores P(t|t), p2s stores P(t|t-1), t = 1,...,nst */

i = 1;
do while i <= nst;
a2[i,.] = a1[i,.]*t'+c';
err[i,.] = y[i,.]-a2[i,.]*z'-xr[i,.]*b';
p2 = t*p1*t'+q;
p2s[(i-1)*nsv+1:i*nsv,.] = p2;
f = z*p2*z'+h;
fi = inv(f);
k = p2*z'fi;
a1[i+1,.] = a2[i,.]+err[i,.]*k';
p1 = (eye(nsv)-k*z)*p2;
p1s[(i-1)*nsv+1:i*nsv,.] = p1;
lf[i,1] = -0.5*(cols(y)*ln(2*pi)+ln(det(f))+err[i,.]*fi*err[i,.]');
err[i,.] = err[i,.]./sqrt(diag(f))'; /* end filter */
i = i+1;
endo;

ldf = ln(det(f));

/* Begin steady state kalman filter */
i = nst+1;
do while i <= nt;
a2[i,.] = a1[i,.]*t'+c';
err[i,.] = y[i,.]-a2[i,.]*z'-xr[i,.]*b';
a1[i+1,.] = a2[i,.]+err[i,.]*k';
lf[i,1] = -0.5*(cols(y)*ln(2*pi)+ln(det(f))+err[i,.]*fi*err[i,.]');
err[i,.] = err[i,.]./sqrt(diag(f))'; /* end filter */
i = i+1;
endo;

/* Smoothing
In a2, a(t|t-1) is overwritten by a(t-1|T)
In p2s, P(t|t-1) is overwritten by P(t-1|T) */

/* Recursively with values from steady state filter for t = nt,...,nst */

j = p1s[(nst-2)*nsv+1:(nst-1)*nsv,.]*t'inv(p2s[(nst-1)*nsv+1:nst*nsv,.]);
a2[nt+1,.] = a1[nt+1,.];

i = 1;
do while i <= nt+1-nst;
a2[nt+1-i,.] = (a1[nt+1-i,.]'+j*(a2[nt+2-i,.]'-a2[nt+1-i,.]'))';
i = i+1;
endo;

/* Recursively with values from startup period for t = nst-1,...,1 */

p2s[(nst-1)*nsv+1:nst*nsv,.] = p1s[(nst-2)*nsv+1:(nst-1)*nsv,.]
+j*(p1s[(nst-1)*nsv+1:nst*nsv,.]-p2s[(nst-1)*nsv+1:nst*nsv,.])*j';
i = 1;
do while i <= nst-2;
j = p1s[(nst-2-i)*nsv+1:(nst-1-i)*nsv,.]
*t'inv(p2s[(nst-1-i)*nsv+1:(nst-i)*nsv,.]);
a2[nst-i,.] = (a1[nst-i,.]'+j*(a2[nst+1-i,.]'-a2[nst-i,.]'))';
p2s[(nst-1-i)*nsv+1:(nst-i)*nsv,.] = p1s[(nst-2-i)*nsv+1:(nst-1-i)*nsv,.]
+j*(p2s[(nst-i)*nsv+1:(nst+1-i)*nsv,.]
-p2s[(nst-1-i)*nsv+1:(nst-i)*nsv,.])*j';
i = i+1;
endo;

vv= sumc(lf);
retp(-vv);

endp;``````

it's not working in the lines that are marked as failing. Basically i don't understand why this matrix is entirely zero

thank again

0

What matrix is entirely zero? Do you mean xph and xis, or the matrices made from xph'xph, xis'xis, or another one? Is the data set you are using an example dataset that came with the code, or is it your data?

aptech

1,773

0

I mean in the IS equation, xis and yis, when i print i just see 2 columns of zero

Normally it's not suppose to do

i use data coming from a excel sheet

thanks so much for taking time to answer me

0

` `

``` 7,34 4,48 4,44 7,35 4,48 4,23 7,36 4,49 5,90 7,36 4,48 -1,40 7,35 4,46 -2,95 12,97 7,34 4,44 -2,49 6,33 7,35 4,43 -2,25 4,17 7,34 4,42 -0,05 2,07 7,38 4,43 -0,65 4,10 1,53 7,41 4,46 2,12 4,06 1,53 7,45 4,49 8,20 2,02 1,65 7,47 4,50 6,76 4,00 1,79 7,48 4,52 12,58 3,96 1,79 7,50 4,52 2,92 5,87 1,79 7,52 4,51 0,47 0,00 1,79 7,52 4,51 5,17 13,37 1,79 7,53 4,52 1,57 30,71 1,79 7,53 4,52 0,13 25,27 1,79 7,54 4,52 2,81 -1,64 1,79 7,57 4,55 0,81 -1,64 1,79 7,59 4,56 1,47 4,91 2,01 7,60 4,56 0,62 3,24 2,05 7,59 4,55 2,22 3,21 2,05 7,57 4,53 1,80 6,35 2,05 7,57 4,52 2,09 1,57 1,89 7,57 4,51 -0,34 1,57 1,58 7,58 4,51 -1,22 7,74 1,53 7,60 4,52 -0,37 6,08 1,53 7,63 4,54 1,28 5,99 1,53 7,65 4,55 0,39 4,44 1,75 7,66 4,56 1,52 5,84 2,01 7,66 4,57 1,15 5,76 2,43 7,66 4,58 1,63 4,26 2,57 7,67 4,58 2,66 5,61 2,79 7,67 4,57 3,87 2,78 4,88 2,93 7,68 4,58 2,34 6,86 -1,00 3,09 7,69 4,58 3,60 -41,56 4,88 3,09 7,69 4,58 2,58 -4,95 0,82 3,09 7,70 4,57 3,14 -5,39 -1,99 3,31 7,69 4,55 2,05 -1,96 -5,13 3,34 7,66 4,53 4,99 0,31 -8,58 2,75 7,66 4,51 0,94 -8,09 -3,84 1,89 7,69 4,53 0,73 -2,29 -2,79 1,84 7,71 4,54 0,51 -12,47 -1,37 2,36 7,73 4,56 2,60 -6,36 7,46 2,72 7,75 4,58 1,93 -20,42 3,13 3,28 7,75 4,58 2,58 -12,05 1,55 3,73 7,76 4,58 2,38 -3,63 3,34 4,14 7,78 4,58 1,01 1,89 8,68 -1,95 4,14 7,77 4,58 1,52 2,10 -0,09 -0,47 4,02 7,78 4,58 1,60 2,34 3,37 1,63 3,33 7,76 4,57 1,54 2,15 10,32 -1,41 3,09 7,77 4,56 0,69 1,69 -4,09 -0,20 3,09 7,79 4,56 1,25 1,59 -4,29 -0,23 3,09 7,80 4,56 1,64 1,63 8,85 -0,84 3,09 7,82 4,58 0,68 1,51 -0,14 0,91 3,09 7,84 4,58 1,40 1,56 -8,20 -4,48 3,09 7,85 4,59 1,46 1,50 -4,66 0,78 3,09 7,86 4,59 1,22 1,50 -7,16 -1,53 3,09 7,86 4,58 0,59 1,35 -11,18 2,89 3,09 7,88 4,59 1,16 1,41 13,65 3,09 3,09 7,89 4,60 1,33 1,47 -1,59 1,74 3,09 7,91 4,60 1,51 1,54 10,07 1,87 3,52 7,92 4,61 1,75 1,62 2,19 2,27 3,61 7,94 4,61 1,57 1,59 -5,32 4,37 3,61 7,95 4,62 0,95 1,43 -0,32 2,16 3,61 7,96 4,62 1,14 1,46 -5,85 -0,29 3,61 7,97 4,63 1,13 1,49 2,01 1,69 3,83 7,99 4,65 1,60 1,65 -1,88 2,92 4,11 8,00 4,66 1,26 1,62 4,18 -1,48 4,22 8,02 4,66 1,20 1,58 5,22 2,87 4,22 8,05 4,67 1,12 1,54 -8,48 4,85 4,32 8,07 4,68 1,96 1,73 -3,52 2,27 4,73 8,08 4,69 3,09 2,06 1,56 4,23 5,11 8,08 4,70 3,21 2,21 5,63 -1,70 5,64 8,09 4,70 3,33 2,29 -9,64 3,31 5,80 8,10 4,69 1,71 1,94 0,44 2,09 5,01 8,10 4,69 2,51 1,97 1,65 -3,60 4,13 8,11 4,69 3,54 2,14 12,26 -1,96 4,03 8,11 4,70 3,93 2,39 -7,36 1,71 4,32 8,13 4,70 4,63 2,62 -7,17 4,42 4,97 8,15 4,71 4,37 2,85 10,40 2,67 6,25 8,16 4,72 4,16 3,28 4,73 -0,04 6,21 8,16 4,73 4,58 3,78 -17,41 2,85 6,18 8,18 4,73 4,31 4,42 6,72 2,62 6,88 8,18 4,74 4,75 4,82 -0,69 1,86 8,81 8,19 4,75 4,56 4,73 0,13 1,97 9,53 8,18 4,74 4,49 4,84 -4,66 15,40 9,49 8,18 4,74 4,17 4,57 0,50 3,96 9,07 8,18 4,73 4,12 4,40 7,28 4,52 8,32 8,19 4,72 4,44 4,52 9,80 12,68 7,04 8,18 4,71 5,83 5,41 6,98 4,61 5,81 8,21 4,72 4,89 5,07 9,74 6,69 3,99 8,21 4,72 4,59 5,40 9,34 -1,97 4,74 8,22 4,72 3,73 4,50 17,90 4,68 5,70 8,22 4,73 2,26 3,70 1,42 4,50 4,93 8,24 4,74 4,00 4,14 -9,75 10,62 3,66 8,26 4,75 2,75 2,72 17,47 11,84 4,46 8,27 4,76 2,90 3,33 -4,20 8,28 4,92 8,29 4,77 2,44 2,71 11,95 8,20 5,35 8,32 4,78 2,77 2,92 13,57 12,76 6,85 8,33 4,79 5,14 4,06 27,88 33,15 8,25 8,32 4,80 4,83 4,24 42,56 15,37 11,30 8,33 4,81 4,65 4,54 110,95 20,73 10,67 8,32 4,80 6,53 5,33 299,16 15,76 9,93 8,33 4,80 9,44 7,58 96,31 35,60 12,08 8,32 4,80 10,82 9,70 1,74 30,45 13,05 8,31 4,78 9,35 9,19 -7,82 20,02 9,94 8,30 4,75 7,48 7,61 12,85 10,04 6,60 8,31 4,74 5,95 6,24 -3,68 0,91 5,65 8,32 4,75 5,77 5,84 -8,36 -15,28 6,44 8,34 4,77 6,11 5,67 9,96 -4,84 5,64 8,36 4,78 5,74 5,27 15,14 4,30 5,02 8,37 4,78 4,79 4,69 3,88 9,12 5,41 8,37 4,78 6,50 6,11 1,49 8,80 5,50 8,38 4,79 6,69 5,90 8,61 2,44 5,06 8,39 4,80 6,37 5,70 15,86 14,81 4,84 8,41 4,82 6,17 5,67 7,81 13,74 5,37 8,43 4,83 6,70 6,07 -1,26 7,01 6,07 8,43 4,84 5,86 5,43 1,77 3,52 6,83 8,43 4,85 6,45 5,98 -1,21 11,00 7,09 8,47 4,88 7,06 6,37 -2,08 13,46 7,66 8,48 4,88 6,78 6,06 -0,46 6,98 8,55 8,49 4,89 6,76 6,12 1,86 8,53 10,20 8,49 4,90 6,11 5,71 19,72 16,25 10,75 8,50 4,91 6,96 6,42 62,61 8,15 10,87 8,50 4,91 7,03 6,42 100,18 4,52 11,73 8,51 4,92 8,52 7,46 47,71 19,72 14,76 8,51 4,92 10,13 8,44 68,39 18,98 16,50 8,49 4,90 9,25 7,63 35,66 7,06 13,70 8,49 4,89 8,78 7,57 8,05 12,99 10,47 8,50 4,91 8,55 7,60 12,13 6,08 17,43 8,52 4,91 8,12 7,30 29,10 3,14 18,31 8,52 4,91 7,61 7,02 12,78 -1,00 19,76 8,53 4,91 8,20 7,61 -27,40 -6,20 19,52 8,52 4,91 7,59 7,04 -10,17 4,92 14,77 8,50 4,89 5,79 5,77 -4,78 0,38 15,49 8,50 4,89 5,64 6,07 -18,65 -2,85 15,85 8,50 4,88 6,17 6,61 9,15 -7,62 11,81 8,50 4,87 5,47 6,14 -4,28 -2,38 9,87 8,51 4,88 5,12 6,14 -44,71 1,29 9,17 8,54 4,89 4,34 5,84 1,84 0,91 9,33 8,55 4,91 4,77 6,36 10,16 -0,70 10,07 8,57 4,93 4,11 6,07 -5,83 -1,59 10,03 8,59 4,95 3,52 5,76 -0,11 2,36 10,32 8,61 4,96 4,15 6,32 4,34 4,60 11,29 8,62 4,96 3,55 5,12 -7,53 -3,90 12,24 8,63 4,97 3,35 4,56 -3,79 -2,22 9,85 8,64 4,98 4,61 5,38 -13,23 -8,27 8,97 8,64 4,98 4,05 4,33 3,93 1,27 8,36 8,66 4,99 3,60 4,10 -19,06 1,96 8,34 8,67 4,99 4,13 4,56 7,29 9,81 8,56 8,68 4,99 3,43 3,83 -78,30 11,96 8,26 8,68 4,99 3,35 3,67 -196,26 5,55 7,27 8,69 4,99 3,74 3,94 -57,27 8,88 6,50 8,69 5,00 3,91 4,03 42,86 2,46 6,56 8,70 5,01 4,37 4,42 83,47 8,24 6,51 8,71 5,02 4,34 4,40 40,58 9,71 6,98 8,72 5,03 3,63 3,81 15,35 3,30 7,18 8,74 5,04 4,73 4,76 -16,79 10,55 7,27 8,74 5,04 3,12 3,38 -53,48 10,30 6,99 8,76 5,05 5,05 4,97 -1,23 9,58 7,52 8,76 5,06 4,41 4,50 -26,19 -2,01 8,43 8,77 5,07 4,34 4,37 -38,43 8,99 8,97 8,79 5,08 4,26 4,33 72,22 3,56 10,05 8,79 5,08 3,50 3,76 67,60 -0,79 10,36 8,80 5,08 2,99 3,23 -35,71 -3,97 9,65 8,80 5,08 4,46 4,22 21,03 1,54 9,13 8,81 5,09 3,97 4,08 38,83 3,71 8,72 8,81 5,09 5,24 4,75 -81,18 0,82 8,72 8,81 5,08 4,42 4,41 89,71 2,54 8,62 8,80 5,08 3,98 4,12 148,17 6,21 8,17 8,80 5,06 4,41 4,14 -142,42 4,41 6,74 8,81 5,06 3,51 3,94 -61,69 -2,94 6,12 8,81 5,06 3,59 3,86 -11,74 -2,93 5,89 8,81 5,06 3,89 3,79 28,54 3,76 5,00 8,82 5,05 4,48 3,98 -66,80 4,29 4,16 8,83 5,06 3,08 3,88 52,02 -1,54 3,90 8,84 5,06 2,07 3,67 25,69 4,37 3,36 8,85 5,06 3,31 3,51 -13,62 1,70 3,13 8,85 5,07 2,56 3,50 -34,54 -3,39 3,13 8,86 5,08 2,85 3,64 15,21 2,98 3,09 8,86 5,09 1,77 3,38 -45,91 0,95 3,15 8,88 5,10 2,31 3,14 -30,80 2,60 3,08 8,89 5,10 1,46 2,52 -42,39 0,99 3,31 8,90 5,12 2,60 2,41 59,06 2,72 4,08 8,91 5,12 3,06 2,58 36,40 5,11 4,65 8,92 5,13 1,85 2,52 -23,26 5,61 5,38 8,92 5,14 2,72 2,63 21,51 3,38 6,06 8,92 5,14 2,36 2,57 36,54 5,75 6,29 8,93 5,15 2,08 2,50 -38,78 2,31 6,05 8,94 5,15 1,84 2,21 1,76 -0,76 5,97 8,95 5,15 1,80 2,01 34,87 -0,95 5,59 8,96 5,16 1,70 1,85 42,84 -1,03 5,46 8,97 5,16 1,56 1,69 1,21 -1,43 5,53 8,98 5,17 2,21 1,83 52,46 0,42 5,50 8,99 5,18 2,31 2,05 -17,60 -0,40 5,50 9,00 5,19 2,26 2,24 -67,72 -2,32 5,76 9,01 5,19 1,05 1,83 -8,27 0,05 5,77 9,02 5,20 1,24 1,48 3,06 -0,62 5,74 9,04 5,20 1,59 1,33 -98,10 -3,17 5,76 9,04 5,21 1,65 1,46 -41,49 -1,93 5,73 9,05 5,21 1,57 1,54 -31,13 -3,44 5,77 9,07 5,22 1,45 1,51 -5,73 0,33 5,05 9,07 5,23 1,31 1,43 -37,59 -0,24 4,91 9,08 5,23 1,43 1,40 139,85 -0,80 4,93 9,09 5,24 1,44 1,39 94,21 1,12 5,30 9,11 5,24 1,70 1,50 67,98 1,40 5,53 9,12 5,25 2,21 1,76 66,60 1,41 5,93 9,13 5,25 1,80 1,83 1,57 1,97 6,57 9,13 5,24 1,26 1,61 35,04 1,68 6,83 9,13 5,24 1,83 1,63 4,08 1,34 6,78 9,13 5,24 2,80 1,93 -55,29 2,53 5,84 9,13 5,24 1,17 1,83 -15,17 -5,07 4,48 9,13 5,23 0,75 1,66 -11,80 -5,84 3,61 9,13 5,22 2,71 1,69 -98,15 -3,33 2,19 9,14 5,21 1,42 1,62 -0,30 -2,22 1,77 9,15 5,21 1,64 1,94 107,21 2,03 1,79 where there is a blank space it's because there are missing values ```
``` link angenita 0 ```
``` 0 I know it is not the problem, but you don't want to invert a matrix because it's numerically not a good idea. I recommend the following. Instead of inv(X) or invpd(X), you should write eye(n)/X. This avoids the numerical problems of inverting a matrix. link sebszab 22 ```
``` Your Answer ```
``` ```
``` 8 Answers 0 The error "matrix not positive definite" happens when you are trying to invert a matrix using the function, invpd. The invpd function requires that the input matrix is positive definite. Most of the time it is used to invert a moment matrix (X'X) which should be positive definite unless there is some linear dependence in the variables. When you say your matrix is full of zeros, do you mean that it is entirely zeros? Or that it just has quite a few of them? You might be having a problem loading your data correctly. Can you post a link to the code so we can offer more help? linkaptech1,773 0 Thank you for answering me. I mean when i use the function "print" to see my matrix. I see that it's entirely zeros linkangenita0 0 If your matrix is entirely zeros, then it is certainly singular. Does the program simulate data, or is this data that you loaded from a file? linkaptech1,773 0 thank you again well, here is my code /* ---------------------------------------------------------------------- rstar_s1.g: First-stage estimation of the model without hours in Laubach-Williams, FEDS 2001-56. Last modified 09/03/02. ---------------------------------------------------------------------- */ library optmum; optset; output file = /mq/home/m1hxl00/work/nri/nrv2/n2v1.out reset; format /rd 8,4; load dat[218,7] = /mq/home/m1hxl00/work/nri/nrv2/nr2_0902.dat; dat[.,5] = dat[.,5]-dat[.,3]; /* Relative oil price inflation */ dat[.,6] = dat[.,6]-dat[.,3]; /* Relative import price inflation */ dat[.,7] = dat[.,7]-dat[.,4]; /* Ex ante real rate */ mv = miss(0,0); nt = 166; /* Sample 61:1 - 02:2 */ nar = 7; /* Number of regressors */ nsv = 3; /* Number of state variables */ nst = nt; /* Startup periods for filter */ niter = 1000; /* Number of draws for generating error bands */ seed1 = 40; indx = 0; /* Index for initialisation of P(0|0) during MC simulation */ /* Setting up system matrices: a1 filtered state a(t|t) a2 smoothed state a(t|T) p1s covariance matrix of filtered state p2s covariance matrix of smoothed state b coefficients on explanatory variables in measurement equation xr regressor matrix in measurement equation z coefficients on state vector in measurement equation h covariance matrix of measurement equation error t transition matrix in transition equation q covariance matrix of transition equation error */ a1 = zeros(nt+1,nsv); a2 = zeros(nt+1,nsv); p1s = zeros(nst*nsv,nsv); p2s = zeros(nst*nsv,nsv); b = zeros(2,nar); z = zeros(2,nsv); h = zeros(2,2); t = zeros(nsv,nsv); t[1:2,1] = ones(2,1); t[3,2] = 1; q = zeros(nsv,nsv); /* Computing starting values for parameters */ /* Potential XBO proxied by segmented trend 60:1 to 00:4 */ xr = ones(nt+4,1)~seqa(1,1,nt+4); xr = xr~(zeros(56,1)|seqa(1,1,nt-52))~(zeros(142,1)|seqa(1,1,nt-138)); xi = invpd(xr'xr); bpot = xi*xr'dat[49:nt+52,1]; gpot = xr*bpot; gap = 100*(dat[49:nt+52,1]-xr*bpot); /* IS equation */ yis = gap[5:nt+4]; xis = gap[4:nt+3]~gap[3:nt+2]; //****************************************** //Line below fails bis = invpd(xis'xis)*xis'yis; ris = yis-xis*bis; sis = sqrt(ris'ris/(nt-cols(xis))); /* Phillips equation */ yph = dat[53:nt+52,3]; xph = dat[52:nt+51,3]~(dat[51:nt+50,3]+dat[50:nt+49,3]+dat[49:nt+48,3])/3; xph = xph~(dat[48:nt+47,3]+dat[47:nt+46,3]+dat[46:nt+45,3]+dat[45:nt+44,3])/4; xph = xph~gap[4:nt+3]~dat[52:nt+51,5]~dat[53:nt+52,6]; //****************************************** //Line below fails bph = invpd(xph'xph)*xph'yph; rph = yph-xph*bph; sph = sqrt(rph'rph/(nt-cols(xph))); /* Transition equation std devs */ s3 = 0.5; d = 0.85; /* Constructing data matrices and vector of initial values */ y = 100*dat[53:nt+52,1]~yph; xr = 100*(dat[52:nt+51,1]~dat[51:nt+50,1])~xph[.,1:3]~xph[.,5:6]; startv = bis|bph[1:2]|bph[4:6]|d|sis|sph|s3; output on; "Starting values"; startv'; ""; output off; err = reshape(mv,nt,2); lf = reshape(mv,nt,1); {val,f,g,retcode} = optmum(&li,startv); /* res stores smoothed state, ref stores filtered state */ res = a2[2:nt+1,1]; ref = a1[2:nt+1,1]; /* Initial smoothed state and its covariance matrix are stored for generating random draws during simulations */ stin = a2[2,.]; pp1 = p2s[1:nsv,.]; {tx,ty} = eigrs2(pp1); dg = diagrv(eye(rows(tx)),tx); hh2 = ty*sqrt(dg); /* Computing gradients */ llf = lf; dval = maxc(10^(-6)*abs(val')|ones(1,rows(val))*10^(-6)); bval = reshape(val,rows(val),rows(val))'; bval = diagrv(bval,val+dval); i = 1; do while i <= rows(val); call li(bval[.,i]); llf = llf~lf; i = i+1; endo; llf = (llf[.,2:rows(val)+1]-llf[.,1])./dval'; info = invpd(llf'llf); bse = sqrt(diag(info)); output on; "Likelihood value"; -f; ""; "MLE Parameters of Model, SE, t Statistics"; val~bse~(abs(val)./bse); ""; "Sum of coeffs on gap in IS equation"; sumc(val[1:2]); ""; "Box-Pierce Q Statistics, L = 1,...,16, and 5% critical values"; bpq = zeros(16,2); i = 1; do while i <= 16; bpq[i,1] = ((err[1+i:nt,1]'err[1:nt-i,1])/(err[.,1]'err[.,1]))^2; bpq[i,2] = ((err[1+i:nt,2]'err[1:nt-i,2])/(err[.,2]'err[.,2]))^2; i = i+1; endo; i = 2; do while i <= 16; bpq[i,.] = bpq[i,.]+bpq[i-1,.]; i = i+1; endo; cv = {3.84,5.99,7.82,9.49,11.07,12.59,14.07,15.51,16.92,18.31, 19.68,21.03,22.36,23.69,25,26.3}; nt*bpq~cv; ""; /* Computing error bands for state vector using Monte Carlo */ indx = 1; /* Switches computation of initial state from GLS to draw */ cum1 = zeros(nt,1); cum2 = zeros(nt,1); {tx,ty} = eigrs2(info); dg = diagrv(eye(rows(tx)),tx); hh = ty*sqrt(dg); i = 1; do while i <= niter; theta = hh*rndns(rows(val),1,seed1)+val; call li(theta); cum1 = cum1+(a2[2:nt+1,1]-res[.,1]).*(a2[2:nt+1,1]-res[.,1]); j = 1; do while j <= nst-1; cum2[j] = cum2[j]+p2s[j*nsv+1,1]; j = j+1; endo; cum2[nst:nt] = cum2[nst:nt]+ones(nt-nst+1,1)*p1s[(nst-1)*nsv+1,1]; i = i+1; endo; cum1 = cum1/niter; cum2 = cum2/niter; bnd2 = sqrt(cum1+cum2); "Mean SE"; meanc(bnd2); (100*dat[53:nt+52,1]-res[.,1])~bnd2; res/100; end; /* ----- Define the log likelihood function for each observation ------*/ proc li(inp); local p1,p2,i,f,fi,k,ldf,vv,j,flag1,c,x,om,yy,tmp; /* Insert parameters into system matrices */ a1 = zeros(nt+1,nsv); a2 = zeros(nt+1,nsv); p1s = zeros(nst*nsv,nsv); p2s = zeros(nst*nsv,nsv); b = zeros(2,cols(xr)); b[1,1:2] = inp[1:2]'; b[2,1] = inp[5]; b[2,3:4] = inp[3:4]'; b[2,5] = 1-sumc(inp[3:4]); b[2,6:7] = inp[6:7]'; z[1,1] = 1; z[1,2:3] = -inp[1:2]'; z[2,2] = -inp[5]; c = inp[8]|zeros(nsv-1,1); h[1,1] = inp[9]^2; h[2,2] = inp[10]^2; q[1,1] = inp[11]^2; /* Starting values for a(0|0), P(0|0) */ if indx eq 1; p1 = pp1; a1[1,.] = (hh2*rndns(nsv,1,seed1)+stin')'; goto flag1; endif; x = z|z*t|z*t*t|z*t*t*t; om = zeros(8,8); /* First initialize lower triangular off-diagonal elements */ om[5:6,3:4] = z*t*q*z'; om[7:8,3:4] = z*t*t*q*z'; om[7:8,5:6] = z*(t*t*q*t'+t*q)*z'; /* Initialize upper triangular off-diagonal elements by adding transpose */ om = om+om'; /* Initialize diagonal elements */ om[1:2,1:2] = h; om[3:4,3:4] = z*q*z'+h; om[5:6,5:6] = z*(t*q*t'+q)*z'+h; om[7:8,7:8] = z*(t*t*q*t'*t'+t*q*t'+q)*z'+h; if det(om) le 10^(-6); "om" det(om); a1[1,.] = 100*gpot[5:3]'; p1 = 2*eye(nsv); goto flag1; endif; om = invpd(om); if det(x'om*x) le 10^(-6); "x'om*x" det(x'om*x); a1[1,.] = 100*gpot[5:3]'; p1 = 2*eye(nsv); goto flag1; endif; p1 = invpd(x'om*x); yy = y[1,.]'|y[2,.]'|y[3,.]'|y[4,.]'; tmp = b*xr[1,.]'|(b*xr[2,.]'+z*c)|(b*xr[3,.]'+z*c+z*t*c); tmp = tmp|(b*xr[4,.]'+z*(eye(nsv)+t+t*t)*c); a1[1,.] = (p1*x'om*(yy-tmp))'; tmp = yy-tmp-x*a1[1,.]'; p1 = p1*(tmp'tmp)/3; flag1: lf = zeros(nt,1); /* Starting the Kalman filter: a1 stores a(t|t), t = 0,...,nt, a2 stores a(t|t-1), t = 1,...,nt p1s stores P(t|t), p2s stores P(t|t-1), t = 1,...,nst */ i = 1; do while i <= nst; a2[i,.] = a1[i,.]*t'+c'; err[i,.] = y[i,.]-a2[i,.]*z'-xr[i,.]*b'; p2 = t*p1*t'+q; p2s[(i-1)*nsv+1:i*nsv,.] = p2; f = z*p2*z'+h; fi = inv(f); k = p2*z'fi; a1[i+1,.] = a2[i,.]+err[i,.]*k'; p1 = (eye(nsv)-k*z)*p2; p1s[(i-1)*nsv+1:i*nsv,.] = p1; lf[i,1] = -0.5*(cols(y)*ln(2*pi)+ln(det(f))+err[i,.]*fi*err[i,.]'); err[i,.] = err[i,.]./sqrt(diag(f))'; /* end filter */ i = i+1; endo; ldf = ln(det(f)); /* Begin steady state kalman filter */ i = nst+1; do while i <= nt; a2[i,.] = a1[i,.]*t'+c'; err[i,.] = y[i,.]-a2[i,.]*z'-xr[i,.]*b'; a1[i+1,.] = a2[i,.]+err[i,.]*k'; lf[i,1] = -0.5*(cols(y)*ln(2*pi)+ln(det(f))+err[i,.]*fi*err[i,.]'); err[i,.] = err[i,.]./sqrt(diag(f))'; /* end filter */ i = i+1; endo; /* Smoothing In a2, a(t|t-1) is overwritten by a(t-1|T) In p2s, P(t|t-1) is overwritten by P(t-1|T) */ /* Recursively with values from steady state filter for t = nt,...,nst */ j = p1s[(nst-2)*nsv+1:(nst-1)*nsv,.]*t'inv(p2s[(nst-1)*nsv+1:nst*nsv,.]); a2[nt+1,.] = a1[nt+1,.]; i = 1; do while i <= nt+1-nst; a2[nt+1-i,.] = (a1[nt+1-i,.]'+j*(a2[nt+2-i,.]'-a2[nt+1-i,.]'))'; i = i+1; endo; /* Recursively with values from startup period for t = nst-1,...,1 */ p2s[(nst-1)*nsv+1:nst*nsv,.] = p1s[(nst-2)*nsv+1:(nst-1)*nsv,.] +j*(p1s[(nst-1)*nsv+1:nst*nsv,.]-p2s[(nst-1)*nsv+1:nst*nsv,.])*j'; i = 1; do while i <= nst-2; j = p1s[(nst-2-i)*nsv+1:(nst-1-i)*nsv,.] *t'inv(p2s[(nst-1-i)*nsv+1:(nst-i)*nsv,.]); a2[nst-i,.] = (a1[nst-i,.]'+j*(a2[nst+1-i,.]'-a2[nst-i,.]'))'; p2s[(nst-1-i)*nsv+1:(nst-i)*nsv,.] = p1s[(nst-2-i)*nsv+1:(nst-1-i)*nsv,.] +j*(p2s[(nst-i)*nsv+1:(nst+1-i)*nsv,.] -p2s[(nst-1-i)*nsv+1:(nst-i)*nsv,.])*j'; i = i+1; endo; vv= sumc(lf); retp(-vv); endp; it's not working in the lines that are marked as failing. Basically i don't understand why this matrix is entirely zero thank again linkangenita0 0 What matrix is entirely zero? Do you mean xph and xis, or the matrices made from xph'xph, xis'xis, or another one? Is the data set you are using an example dataset that came with the code, or is it your data? linkaptech1,773 0 I mean in the IS equation, xis and yis, when i print i just see 2 columns of zero Normally it's not suppose to do i use data coming from a excel sheet thanks so much for taking time to answer me linkangenita0 0 7,34 4,48 4,44 7,35 4,48 4,23 7,36 4,49 5,90 7,36 4,48 -1,40 7,35 4,46 -2,95 12,97 7,34 4,44 -2,49 6,33 7,35 4,43 -2,25 4,17 7,34 4,42 -0,05 2,07 7,38 4,43 -0,65 4,10 1,53 7,41 4,46 2,12 4,06 1,53 7,45 4,49 8,20 2,02 1,65 7,47 4,50 6,76 4,00 1,79 7,48 4,52 12,58 3,96 1,79 7,50 4,52 2,92 5,87 1,79 7,52 4,51 0,47 0,00 1,79 7,52 4,51 5,17 13,37 1,79 7,53 4,52 1,57 30,71 1,79 7,53 4,52 0,13 25,27 1,79 7,54 4,52 2,81 -1,64 1,79 7,57 4,55 0,81 -1,64 1,79 7,59 4,56 1,47 4,91 2,01 7,60 4,56 0,62 3,24 2,05 7,59 4,55 2,22 3,21 2,05 7,57 4,53 1,80 6,35 2,05 7,57 4,52 2,09 1,57 1,89 7,57 4,51 -0,34 1,57 1,58 7,58 4,51 -1,22 7,74 1,53 7,60 4,52 -0,37 6,08 1,53 7,63 4,54 1,28 5,99 1,53 7,65 4,55 0,39 4,44 1,75 7,66 4,56 1,52 5,84 2,01 7,66 4,57 1,15 5,76 2,43 7,66 4,58 1,63 4,26 2,57 7,67 4,58 2,66 5,61 2,79 7,67 4,57 3,87 2,78 4,88 2,93 7,68 4,58 2,34 6,86 -1,00 3,09 7,69 4,58 3,60 -41,56 4,88 3,09 7,69 4,58 2,58 -4,95 0,82 3,09 7,70 4,57 3,14 -5,39 -1,99 3,31 7,69 4,55 2,05 -1,96 -5,13 3,34 7,66 4,53 4,99 0,31 -8,58 2,75 7,66 4,51 0,94 -8,09 -3,84 1,89 7,69 4,53 0,73 -2,29 -2,79 1,84 7,71 4,54 0,51 -12,47 -1,37 2,36 7,73 4,56 2,60 -6,36 7,46 2,72 7,75 4,58 1,93 -20,42 3,13 3,28 7,75 4,58 2,58 -12,05 1,55 3,73 7,76 4,58 2,38 -3,63 3,34 4,14 7,78 4,58 1,01 1,89 8,68 -1,95 4,14 7,77 4,58 1,52 2,10 -0,09 -0,47 4,02 7,78 4,58 1,60 2,34 3,37 1,63 3,33 7,76 4,57 1,54 2,15 10,32 -1,41 3,09 7,77 4,56 0,69 1,69 -4,09 -0,20 3,09 7,79 4,56 1,25 1,59 -4,29 -0,23 3,09 7,80 4,56 1,64 1,63 8,85 -0,84 3,09 7,82 4,58 0,68 1,51 -0,14 0,91 3,09 7,84 4,58 1,40 1,56 -8,20 -4,48 3,09 7,85 4,59 1,46 1,50 -4,66 0,78 3,09 7,86 4,59 1,22 1,50 -7,16 -1,53 3,09 7,86 4,58 0,59 1,35 -11,18 2,89 3,09 7,88 4,59 1,16 1,41 13,65 3,09 3,09 7,89 4,60 1,33 1,47 -1,59 1,74 3,09 7,91 4,60 1,51 1,54 10,07 1,87 3,52 7,92 4,61 1,75 1,62 2,19 2,27 3,61 7,94 4,61 1,57 1,59 -5,32 4,37 3,61 7,95 4,62 0,95 1,43 -0,32 2,16 3,61 7,96 4,62 1,14 1,46 -5,85 -0,29 3,61 7,97 4,63 1,13 1,49 2,01 1,69 3,83 7,99 4,65 1,60 1,65 -1,88 2,92 4,11 8,00 4,66 1,26 1,62 4,18 -1,48 4,22 8,02 4,66 1,20 1,58 5,22 2,87 4,22 8,05 4,67 1,12 1,54 -8,48 4,85 4,32 8,07 4,68 1,96 1,73 -3,52 2,27 4,73 8,08 4,69 3,09 2,06 1,56 4,23 5,11 8,08 4,70 3,21 2,21 5,63 -1,70 5,64 8,09 4,70 3,33 2,29 -9,64 3,31 5,80 8,10 4,69 1,71 1,94 0,44 2,09 5,01 8,10 4,69 2,51 1,97 1,65 -3,60 4,13 8,11 4,69 3,54 2,14 12,26 -1,96 4,03 8,11 4,70 3,93 2,39 -7,36 1,71 4,32 8,13 4,70 4,63 2,62 -7,17 4,42 4,97 8,15 4,71 4,37 2,85 10,40 2,67 6,25 8,16 4,72 4,16 3,28 4,73 -0,04 6,21 8,16 4,73 4,58 3,78 -17,41 2,85 6,18 8,18 4,73 4,31 4,42 6,72 2,62 6,88 8,18 4,74 4,75 4,82 -0,69 1,86 8,81 8,19 4,75 4,56 4,73 0,13 1,97 9,53 8,18 4,74 4,49 4,84 -4,66 15,40 9,49 8,18 4,74 4,17 4,57 0,50 3,96 9,07 8,18 4,73 4,12 4,40 7,28 4,52 8,32 8,19 4,72 4,44 4,52 9,80 12,68 7,04 8,18 4,71 5,83 5,41 6,98 4,61 5,81 8,21 4,72 4,89 5,07 9,74 6,69 3,99 8,21 4,72 4,59 5,40 9,34 -1,97 4,74 8,22 4,72 3,73 4,50 17,90 4,68 5,70 8,22 4,73 2,26 3,70 1,42 4,50 4,93 8,24 4,74 4,00 4,14 -9,75 10,62 3,66 8,26 4,75 2,75 2,72 17,47 11,84 4,46 8,27 4,76 2,90 3,33 -4,20 8,28 4,92 8,29 4,77 2,44 2,71 11,95 8,20 5,35 8,32 4,78 2,77 2,92 13,57 12,76 6,85 8,33 4,79 5,14 4,06 27,88 33,15 8,25 8,32 4,80 4,83 4,24 42,56 15,37 11,30 8,33 4,81 4,65 4,54 110,95 20,73 10,67 8,32 4,80 6,53 5,33 299,16 15,76 9,93 8,33 4,80 9,44 7,58 96,31 35,60 12,08 8,32 4,80 10,82 9,70 1,74 30,45 13,05 8,31 4,78 9,35 9,19 -7,82 20,02 9,94 8,30 4,75 7,48 7,61 12,85 10,04 6,60 8,31 4,74 5,95 6,24 -3,68 0,91 5,65 8,32 4,75 5,77 5,84 -8,36 -15,28 6,44 8,34 4,77 6,11 5,67 9,96 -4,84 5,64 8,36 4,78 5,74 5,27 15,14 4,30 5,02 8,37 4,78 4,79 4,69 3,88 9,12 5,41 8,37 4,78 6,50 6,11 1,49 8,80 5,50 8,38 4,79 6,69 5,90 8,61 2,44 5,06 8,39 4,80 6,37 5,70 15,86 14,81 4,84 8,41 4,82 6,17 5,67 7,81 13,74 5,37 8,43 4,83 6,70 6,07 -1,26 7,01 6,07 8,43 4,84 5,86 5,43 1,77 3,52 6,83 8,43 4,85 6,45 5,98 -1,21 11,00 7,09 8,47 4,88 7,06 6,37 -2,08 13,46 7,66 8,48 4,88 6,78 6,06 -0,46 6,98 8,55 8,49 4,89 6,76 6,12 1,86 8,53 10,20 8,49 4,90 6,11 5,71 19,72 16,25 10,75 8,50 4,91 6,96 6,42 62,61 8,15 10,87 8,50 4,91 7,03 6,42 100,18 4,52 11,73 8,51 4,92 8,52 7,46 47,71 19,72 14,76 8,51 4,92 10,13 8,44 68,39 18,98 16,50 8,49 4,90 9,25 7,63 35,66 7,06 13,70 8,49 4,89 8,78 7,57 8,05 12,99 10,47 8,50 4,91 8,55 7,60 12,13 6,08 17,43 8,52 4,91 8,12 7,30 29,10 3,14 18,31 8,52 4,91 7,61 7,02 12,78 -1,00 19,76 8,53 4,91 8,20 7,61 -27,40 -6,20 19,52 8,52 4,91 7,59 7,04 -10,17 4,92 14,77 8,50 4,89 5,79 5,77 -4,78 0,38 15,49 8,50 4,89 5,64 6,07 -18,65 -2,85 15,85 8,50 4,88 6,17 6,61 9,15 -7,62 11,81 8,50 4,87 5,47 6,14 -4,28 -2,38 9,87 8,51 4,88 5,12 6,14 -44,71 1,29 9,17 8,54 4,89 4,34 5,84 1,84 0,91 9,33 8,55 4,91 4,77 6,36 10,16 -0,70 10,07 8,57 4,93 4,11 6,07 -5,83 -1,59 10,03 8,59 4,95 3,52 5,76 -0,11 2,36 10,32 8,61 4,96 4,15 6,32 4,34 4,60 11,29 8,62 4,96 3,55 5,12 -7,53 -3,90 12,24 8,63 4,97 3,35 4,56 -3,79 -2,22 9,85 8,64 4,98 4,61 5,38 -13,23 -8,27 8,97 8,64 4,98 4,05 4,33 3,93 1,27 8,36 8,66 4,99 3,60 4,10 -19,06 1,96 8,34 8,67 4,99 4,13 4,56 7,29 9,81 8,56 8,68 4,99 3,43 3,83 -78,30 11,96 8,26 8,68 4,99 3,35 3,67 -196,26 5,55 7,27 8,69 4,99 3,74 3,94 -57,27 8,88 6,50 8,69 5,00 3,91 4,03 42,86 2,46 6,56 8,70 5,01 4,37 4,42 83,47 8,24 6,51 8,71 5,02 4,34 4,40 40,58 9,71 6,98 8,72 5,03 3,63 3,81 15,35 3,30 7,18 8,74 5,04 4,73 4,76 -16,79 10,55 7,27 8,74 5,04 3,12 3,38 -53,48 10,30 6,99 8,76 5,05 5,05 4,97 -1,23 9,58 7,52 8,76 5,06 4,41 4,50 -26,19 -2,01 8,43 8,77 5,07 4,34 4,37 -38,43 8,99 8,97 8,79 5,08 4,26 4,33 72,22 3,56 10,05 8,79 5,08 3,50 3,76 67,60 -0,79 10,36 8,80 5,08 2,99 3,23 -35,71 -3,97 9,65 8,80 5,08 4,46 4,22 21,03 1,54 9,13 8,81 5,09 3,97 4,08 38,83 3,71 8,72 8,81 5,09 5,24 4,75 -81,18 0,82 8,72 8,81 5,08 4,42 4,41 89,71 2,54 8,62 8,80 5,08 3,98 4,12 148,17 6,21 8,17 8,80 5,06 4,41 4,14 -142,42 4,41 6,74 8,81 5,06 3,51 3,94 -61,69 -2,94 6,12 8,81 5,06 3,59 3,86 -11,74 -2,93 5,89 8,81 5,06 3,89 3,79 28,54 3,76 5,00 8,82 5,05 4,48 3,98 -66,80 4,29 4,16 8,83 5,06 3,08 3,88 52,02 -1,54 3,90 8,84 5,06 2,07 3,67 25,69 4,37 3,36 8,85 5,06 3,31 3,51 -13,62 1,70 3,13 8,85 5,07 2,56 3,50 -34,54 -3,39 3,13 8,86 5,08 2,85 3,64 15,21 2,98 3,09 8,86 5,09 1,77 3,38 -45,91 0,95 3,15 8,88 5,10 2,31 3,14 -30,80 2,60 3,08 8,89 5,10 1,46 2,52 -42,39 0,99 3,31 8,90 5,12 2,60 2,41 59,06 2,72 4,08 8,91 5,12 3,06 2,58 36,40 5,11 4,65 8,92 5,13 1,85 2,52 -23,26 5,61 5,38 8,92 5,14 2,72 2,63 21,51 3,38 6,06 8,92 5,14 2,36 2,57 36,54 5,75 6,29 8,93 5,15 2,08 2,50 -38,78 2,31 6,05 8,94 5,15 1,84 2,21 1,76 -0,76 5,97 8,95 5,15 1,80 2,01 34,87 -0,95 5,59 8,96 5,16 1,70 1,85 42,84 -1,03 5,46 8,97 5,16 1,56 1,69 1,21 -1,43 5,53 8,98 5,17 2,21 1,83 52,46 0,42 5,50 8,99 5,18 2,31 2,05 -17,60 -0,40 5,50 9,00 5,19 2,26 2,24 -67,72 -2,32 5,76 9,01 5,19 1,05 1,83 -8,27 0,05 5,77 9,02 5,20 1,24 1,48 3,06 -0,62 5,74 9,04 5,20 1,59 1,33 -98,10 -3,17 5,76 9,04 5,21 1,65 1,46 -41,49 -1,93 5,73 9,05 5,21 1,57 1,54 -31,13 -3,44 5,77 9,07 5,22 1,45 1,51 -5,73 0,33 5,05 9,07 5,23 1,31 1,43 -37,59 -0,24 4,91 9,08 5,23 1,43 1,40 139,85 -0,80 4,93 9,09 5,24 1,44 1,39 94,21 1,12 5,30 9,11 5,24 1,70 1,50 67,98 1,40 5,53 9,12 5,25 2,21 1,76 66,60 1,41 5,93 9,13 5,25 1,80 1,83 1,57 1,97 6,57 9,13 5,24 1,26 1,61 35,04 1,68 6,83 9,13 5,24 1,83 1,63 4,08 1,34 6,78 9,13 5,24 2,80 1,93 -55,29 2,53 5,84 9,13 5,24 1,17 1,83 -15,17 -5,07 4,48 9,13 5,23 0,75 1,66 -11,80 -5,84 3,61 9,13 5,22 2,71 1,69 -98,15 -3,33 2,19 9,14 5,21 1,42 1,62 -0,30 -2,22 1,77 9,15 5,21 1,64 1,94 107,21 2,03 1,79 where there is a blank space it's because there are missing values linkangenita0 0 I know it is not the problem, but you don't want to invert a matrix because it's numerically not a good idea. I recommend the following. Instead of inv(X) or invpd(X), you should write eye(n)/X. This avoids the numerical problems of inverting a matrix. linksebszab22 You must login to post answers. ```
``` Forum Search Login Username Password Remember Me RegisterLost PasswordRecent TopicsMDCNEV_bhat_code_undefined_symbol_lpr errorImproving graph qualityBRENT and STEPBT in Optimization 3.1Import big data from excel into a programProblems with installing TSDLIBUser Forum Join our community to see why our users are considered some of the most active and helpful in the industry! User Forum ```
``` 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 GAUSS is the product of decades of innovation and enhancement by Aptech Systems, a supportive team of experts dedicated to the success of the worldwide GAUSS user community. Aptech helps people achieve their goals by offering products and applications that define the leading edge of statistical analysis capabilities. GET IN TOUCH WITH US .first-row td { padding: 0px 15px; vertical-align: text-top; } .second-row td { padding: 15px 15px 0px; vertical-align: text-top; } Email: [email protected] Hours of Operation (AZ MST): Monday-Thursday: 8:00 AM - 4:00 PM Friday: 8:00 AM - 3:00 PM Phone: (360) 886-7100 FAX: (360) 886-8922 Address: Aptech Systems, Inc PO Box 618 Higley, AZ 85236 © document.write(new Date().getFullYear()) Aptech Systems, Inc. All rights reserved. Privacy Policy ```
``` Thank you for signing up! .saboxplugin-wrap{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box;border:1px solid #eee;width:100%;clear:both;display:block;overflow:hidden;word-wrap:break-word;position:relative}.saboxplugin-wrap .saboxplugin-gravatar{float:left;padding:0 20px 20px 20px}.saboxplugin-wrap .saboxplugin-gravatar img{max-width:100px;height:auto;border-radius:0;}.saboxplugin-wrap .saboxplugin-authorname{font-size:18px;line-height:1;margin:20px 0 0 20px;display:block}.saboxplugin-wrap .saboxplugin-authorname a{text-decoration:none}.saboxplugin-wrap .saboxplugin-authorname a:focus{outline:0}.saboxplugin-wrap .saboxplugin-desc{display:block;margin:5px 20px}.saboxplugin-wrap .saboxplugin-desc a{text-decoration:underline}.saboxplugin-wrap .saboxplugin-desc p{margin:5px 0 12px}.saboxplugin-wrap .saboxplugin-web{margin:0 20px 15px;text-align:left}.saboxplugin-wrap .sab-web-position{text-align:right}.saboxplugin-wrap .saboxplugin-web a{color:#ccc;text-decoration:none}.saboxplugin-wrap .saboxplugin-socials{position:relative;display:block;background:#fcfcfc;padding:5px;border-top:1px solid #eee}.saboxplugin-wrap .saboxplugin-socials a svg{width:20px;height:20px}.saboxplugin-wrap .saboxplugin-socials a svg .st2{fill:#fff; transform-origin:center center;}.saboxplugin-wrap .saboxplugin-socials a svg .st1{fill:rgba(0,0,0,.3)}.saboxplugin-wrap .saboxplugin-socials a:hover{opacity:.8;-webkit-transition:opacity .4s;-moz-transition:opacity .4s;-o-transition:opacity .4s;transition:opacity .4s;box-shadow:none!important;-webkit-box-shadow:none!important}.saboxplugin-wrap .saboxplugin-socials .saboxplugin-icon-color{box-shadow:none;padding:0;border:0;-webkit-transition:opacity .4s;-moz-transition:opacity .4s;-o-transition:opacity .4s;transition:opacity .4s;display:inline-block;color:#fff;font-size:0;text-decoration:inherit;margin:5px;-webkit-border-radius:0;-moz-border-radius:0;-ms-border-radius:0;-o-border-radius:0;border-radius:0;overflow:hidden}.saboxplugin-wrap .saboxplugin-socials .saboxplugin-icon-grey{text-decoration:inherit;box-shadow:none;position:relative;display:-moz-inline-stack;display:inline-block;vertical-align:middle;zoom:1;margin:10px 5px;color:#444;fill:#444}.clearfix:after,.clearfix:before{content:' ';display:table;line-height:0;clear:both}.ie7 .clearfix{zoom:1}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-twitch{border-color:#38245c}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-addthis{border-color:#e91c00}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-behance{border-color:#003eb0}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-delicious{border-color:#06c}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-deviantart{border-color:#036824}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-digg{border-color:#00327c}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-dribbble{border-color:#ba1655}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-facebook{border-color:#1e2e4f}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-flickr{border-color:#003576}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-github{border-color:#264874}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-google{border-color:#0b51c5}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-googleplus{border-color:#96271a}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-html5{border-color:#902e13}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-instagram{border-color:#1630aa}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-linkedin{border-color:#00344f}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-pinterest{border-color:#5b040e}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-reddit{border-color:#992900}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-rss{border-color:#a43b0a}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-sharethis{border-color:#5d8420}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-skype{border-color:#00658a}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-soundcloud{border-color:#995200}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-spotify{border-color:#0f612c}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-stackoverflow{border-color:#a95009}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-steam{border-color:#006388}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-user_email{border-color:#b84e05}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-stumbleUpon{border-color:#9b280e}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-tumblr{border-color:#10151b}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-twitter{border-color:#0967a0}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-vimeo{border-color:#0d7091}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-windows{border-color:#003f71}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-whatsapp{border-color:#003f71}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-wordpress{border-color:#0f3647}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-yahoo{border-color:#14002d}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-youtube{border-color:#900}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-xing{border-color:#000202}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-mixcloud{border-color:#2475a0}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-vk{border-color:#243549}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-medium{border-color:#00452c}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-quora{border-color:#420e00}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-meetup{border-color:#9b181c}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-goodreads{border-color:#000}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-snapchat{border-color:#999700}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-500px{border-color:#00557f}.saboxplugin-socials.sabox-colored .saboxplugin-icon-color .sab-mastodont{border-color:#185886}.sab-patreon{border-color:#fc573b}.sabox-plus-item{margin-bottom:20px}@media screen and (max-width:480px){.saboxplugin-wrap{text-align:center}.saboxplugin-wrap .saboxplugin-gravatar{float:none;padding:20px 0;text-align:center;margin:0 auto;display:block}.saboxplugin-wrap .saboxplugin-gravatar img{float:none;display:inline-block;display:-moz-inline-stack;vertical-align:middle;zoom:1}.saboxplugin-wrap .saboxplugin-desc{margin:0 10px 20px;text-align:center}.saboxplugin-wrap .saboxplugin-authorname{text-align:center;margin:10px 0 20px}}body .saboxplugin-authorname a,body .saboxplugin-authorname a:hover{box-shadow:none;-webkit-box-shadow:none}a.sab-profile-edit{font-size:16px!important;line-height:1!important}.sab-edit-settings a,a.sab-profile-edit{color:#0073aa!important;box-shadow:none!important;-webkit-box-shadow:none!important}.sab-edit-settings{margin-right:15px;position:absolute;right:0;z-index:2;bottom:10px;line-height:20px}.sab-edit-settings i{margin-left:5px}.saboxplugin-socials{line-height:1!important}.rtl .saboxplugin-wrap .saboxplugin-gravatar{float:right}.rtl .saboxplugin-wrap .saboxplugin-authorname{display:flex;align-items:center}.rtl .saboxplugin-wrap .saboxplugin-authorname .sab-profile-edit{margin-right:10px}.rtl .sab-edit-settings{right:auto;left:0}img.sab-custom-avatar{max-width:75px;}.saboxplugin-wrap .saboxplugin-authorname {font-family:"Lato";}.saboxplugin-wrap .saboxplugin-desc {font-family:Lato;}.saboxplugin-wrap {margin-top:0px; margin-bottom:0px; padding: 0px 0px }.saboxplugin-wrap .saboxplugin-authorname {font-size:18px; line-height:25px;}.saboxplugin-wrap .saboxplugin-desc p, .saboxplugin-wrap .saboxplugin-desc {font-size:14px !important; line-height:21px !important;}.saboxplugin-wrap .saboxplugin-web {font-size:14px;}.saboxplugin-wrap .saboxplugin-socials a svg {width:18px;height:18px;}.saboxplugin-tabs-wrapper { width: 100%; display: block; clear: both; overflow: auto; } .saboxplugin-tabs-wrapper ul{ margin:0px; padding: 0px; } .saboxplugin-tabs-wrapper ul li { list-style: none; float: left; color: #222222; padding: 8px 20px; background-color: #e4e4e4; box-sizing: border-box; margin-right: 1px; border-bottom: 1px solid #c7c7c7; } .saboxplugin-tabs-wrapper ul li.active, .saboxplugin-tabs-wrapper ul li:hover{ color: #222222; background-color: #efefef; border-bottom: 1px solid #c7c7c7; cursor:pointer; } .saboxplugin-tab{ padding:20px; } .saboxplugin-tab ul{ margin:0px; padding: 0px; } .saboxplugin-tab ul li{ list-style: none; }.saboxplugin-authorname .sabox-job-title{font-size:12px;opacity:.7;display: inline-block;margin-left: 10px;} /* <![CDATA[ */ var wpcf7 = {"api":{"root":"https:\/\/www.aptech.com\/wp-json\/","namespace":"contact-form-7\/v1"}}; /* ]]> */ /* <![CDATA[ */ var pum_vars = {"version":"1.18.2","pm_dir_url":"https:\/\/www.aptech.com\/wp-content\/plugins\/popup-maker\/","ajaxurl":"https:\/\/www.aptech.com\/wp-admin\/admin-ajax.php","restapi":"https:\/\/www.aptech.com\/wp-json\/pum\/v1","rest_nonce":null,"default_theme":"21640","debug_mode":"","disable_tracking":"","home_url":"\/","message_position":"top","core_sub_forms_enabled":"1","popups":[],"cookie_domain":"","analytics_route":"analytics","analytics_api":"https:\/\/www.aptech.com\/wp-json\/pum\/v1"}; var pum_sub_vars = {"ajaxurl":"https:\/\/www.aptech.com\/wp-admin\/admin-ajax.php","message_position":"top"}; var pum_popups = {"pum-21652":{"triggers":[],"cookies":[],"disable_on_mobile":false,"disable_on_tablet":false,"atc_promotion":null,"explain":null,"type_section":null,"theme_id":"21646","size":"custom","responsive_min_width":"0%","responsive_max_width":"100%","custom_width":"360px","custom_height_auto":true,"custom_height":"380px","scrollable_content":false,"animation_type":"fade","animation_speed":"350","animation_origin":"center top","open_sound":"none","custom_sound":"","location":"right bottom","position_top":"100","position_bottom":"0","position_left":"0","position_right":"0","position_from_trigger":false,"position_fixed":true,"overlay_disabled":true,"stackable":false,"disable_reposition":false,"zindex":"1999999999","close_button_delay":"0","fi_promotion":null,"close_on_form_submission":false,"close_on_form_submission_delay":"0","close_on_overlay_click":true,"close_on_esc_press":true,"close_on_f4_press":false,"disable_form_reopen":false,"disable_accessibility":false,"theme_slug":"aptech","id":21652,"slug":"thank-you"}}; /* ]]> */ /* <![CDATA[ */ var wpcf7cf_global_settings = {"ajaxurl":"https:\/\/www.aptech.com\/wp-admin\/admin-ajax.php"}; /* ]]> */ /* <![CDATA[ */ var wpcf7_recaptcha = {"sitekey":"6Lf8Ln0UAAAAALE3vXP6zpQ4lsuw93talItU7HWt","actions":{"homepage":"homepage","contactform":"contactform"}}; /* ]]> */ /* <![CDATA[ */ var megamenu = {"timeout":"300","interval":"100"}; /* ]]> */ /* <![CDATA[ */ var sidebar_login_params = {"ajax_url":"\/wp-admin\/admin-ajax.php","force_ssl_admin":"0","is_ssl":"1","i18n_username_required":"Please enter your username","i18n_password_required":"Please enter your password","error_class":"sidebar-login-error"}; /* ]]> */ jQuery(document).ready(function(\$) { \$( '.mega-search-trigger .mega-menu-link' ).on( 'focus, click', function( event ) { event.preventDefault(); \$( '#full-screen-search' ).addClass( 'open' ); \$( '#full-screen-search input' ).focus(); }); }); ```