Page 1 of 1
Using %xsubmat
Posted: Tue May 18, 2021 5:43 pm
by Narci4269
Hi Tom. I have a Matrix called hmpxt 5x5 which is updating several times (actually it is a covariance matrix from a Multivariate Garch).
I am trying to include some calculations:
Code: Select all
dec rect dcb2(1731,4)
do j = 1, 1731
com dcb = tr(inv(%xsubmat(hmpxt(j),1,4,1,4))*tr(%xsubmat(hmpxt(j),5,5,1,4)))
do i = 1, 4
com dcb2(j,i) = dcb(1,i)
end do i
end do j
But this error arises:
## MAT17. Can't Use Row Range of 1 to 4 in %XSUBMAT operation
The Error Occurred At Location 49, Line 2 of loop/block
What could I am doing wrong?
Regards,
Re: Using %xsubmat
Posted: Tue May 18, 2021 5:55 pm
by TomDoan
Is it possible that hmpxt(j) isn't defined for entry 1? That will only be defined over the range over which the GARCH model is run.
Re: Using %xsubmat
Posted: Wed May 19, 2021 9:22 am
by Narci4269
Thanks Tom. Is possible to use %xsubmat in hadjust for GARCH? I am trying but it is not working. Should I do something with declare before?
Regards,
Re: Using %xsubmat
Posted: Wed May 19, 2021 2:01 pm
by TomDoan
You're doing an HMATRICES=hmpxt option? That's only defined over the range for the GARCH instruction, which is probably *not* 1 to 1731. If you don't have the matrix, you can't compute the hedges. You should probably be able to do that with
do j=%regstart(),%regend()
...
end do j
instead, which restricts the calculation to the GARCH range.
Re: Using %xsubmat
Posted: Thu May 20, 2021 4:18 pm
by Narci4269
Ok Tom, but is possible to calculate a series from %xsubmat included in Hadjust? In the example I there is a row vector (1x4) that would be updated in each step. How can I obtain for every column a series (tx1).
For example i would have this line:
hadjust=%(coeffs = tr(inv(%xsubmat(hmecp(j),1,4,1,4))*tr(%xsubmat(hmecp(j),5,5,1,4))))
coeffs is the vector 1x4 that is updated each step. I don“t know how to do (included in the hadjust instruction) that could do, for example, coeff1 = coeffs(t,1), coeff2 = coeffs(t,2) or something in that way.
Thanks for your support.