Page 1 of 1

Help with MAT13 error

Posted: Fri Mar 20, 2020 7:46 am
by Ozmando
I am geting the following error:

## MAT13. Store into Out-of-Range Matrix or Series Element
The Error Occurred At Location 283, Line 8 of loop/block

The last error shows that the problem is in the last line below at "end".
Any help to solve the problem please?
oz

** compute here IRF and bands for each variable
** 4 = US gdp; 8 = JP gdp; 12 = DE gdp ; 16 = UK; 20 = FR gdp; 24 = IT gdp; 28 = CA gdp

dec vect[series] upper(nvar) lower(nvar) resp(nvar)
comp j = 16
do j = 1,nvar
smpl 1 ndraws
compute minlower=maxupper=0.0
clear lower(j) upper(j) resp(j)
do i=1,nstep
set work 1 ndraws = responses(t)(j,i)
compute frac=%fractiles(work,||.05,0.5,.95||)
compute lower(j)(i)=frac(1)
compute upper(j)(i)=frac(3)
compute resp(j)(i)=frac(2)
end do i
compute maxupper=%max(maxupper,%maxvalue(upper(j)))
compute minlower=%min(minlower,%minvalue(lower(j)))
/*
smpl 1 nstep
graph(ticks,min=minlower,max=maxupper,number=0) 3 j i
# resp(j)
# upper(j) / 2
# lower(j) / 2
*/
end

Re: Help with MAT13 error

Posted: Fri Mar 20, 2020 1:15 pm
by TomDoan
I'm not sure what:

comp j = 16

is supposed to be doing, since it's followed by the DO J.

The error is in line 8 of the DO J loop, which is

compute lower(j)(i)=frac(1)

I'm guessing that the problem comes from having that SMPL 1 NDRAWS instruction. (Is NDRAWS a small number, at least relative to NSTEP?) That applies to the CLEAR instruction, which you don't want. If you put CLEAR(LENGTH=NSTEP) LOWER(J) ... it will initialize those over the range that they need.

Re: Help with MAT13 error

Posted: Sun Mar 22, 2020 12:59 pm
by Ozmando
TomDoan wrote:I'm not sure what:

comp j = 16

is supposed to be doing, since it's followed by the DO J.

The error is in line 8 of the DO J loop, which is

compute lower(j)(i)=frac(1)

I'm guessing that the problem comes from having that SMPL 1 NDRAWS instruction. (Is NDRAWS a small number, at least relative to NSTEP?) That applies to the CLEAR instruction, which you don't want. If you put CLEAR(LENGTH=NSTEP) LOWER(J) ... it will initialize those over the range that they need.
Thanks Tom.
I managed to fix the problem now by running the code portion by portion and all seems to work. I am assuming the error could be because 'end' was written between /* *\, as this is the only thing I have not selected.
Will follow your recommendation though to see if that helps in running the code in one go.
Cheers
oz