Using %xsubmat

For questions and discussion related to reading in and working with data.
Narci4269
Posts: 16
Joined: Sat Feb 06, 2021 5:29 am

Using %xsubmat

Unread post 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,
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Using %xsubmat

Unread post 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.
Narci4269
Posts: 16
Joined: Sat Feb 06, 2021 5:29 am

Re: Using %xsubmat

Unread post 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,
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Using %xsubmat

Unread post 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.
Narci4269
Posts: 16
Joined: Sat Feb 06, 2021 5:29 am

Re: Using %xsubmat

Unread post 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.
Post Reply