## Help with RECTANGULAR[series]

Use this forum to post questions about syntax problems or general programming issues. Questions on implementing a particular aspect of econometrics should go in "Econometrics Issues" below.

### Help with RECTANGULAR[series]

Hello all,

I am having some difficulties figuring out RECTANGULAR arrays and it seems like I end up using a number of do loops where more efficient methods should be available.

1. Can I do a vertical concatenation of two RECTANGULAR[series] arrrays? If A is (1,6) and B is (1,6), how do I make an array C that is (2X6) and contains all of the elements of A and B? It seems to me that:

compute C = A~~B

might work but either I have the syntax wrong or I do not understand this operator.

2. How do I set a single row of a RECTANGULAR[series] array? Suppose I have a RECTANGULAR[series] array A that is (6,6) and I have a VECTOR[series] B that is of dimension 6. Is there an efficient way to set A(3,*) = B?

3. How do I extract a single row of a RECTANGULAR[series] array? For example, suppose I have a RECTANGULAR[series] array A that is (6,6) and I want to look at all of the series contained in row 3. Is there an efficient way to extract this row as either a RECTANGULAR or a VECTOR?

This data type seems like a very powerful feature but I feel that I am missing some fairly basic concepts about how to use it. Any help would be much appreciated!

Thank you,

Geoff
writ

Posts: 6
Joined: Wed Jan 26, 2011 9:09 am

### Re: Help with RECTANGULAR[series]

RECT[SERIES] and VECT[SERIES] are mainly for organizing blocks of time series, and there aren't that many operators or functions which apply to them. Based on your questions, you might be better off doing these the other way around, as
SERIES[RECT].

writ wrote:Hello all,

I am having some difficulties figuring out RECTANGULAR arrays and it seems like I end up using a number of do loops where more efficient methods should be available.

1. Can I do a vertical concatenation of two RECTANGULAR[series] arrrays? If A is (1,6) and B is (1,6), how do I make an array C that is (2X6) and contains all of the elements of A and B? It seems to me that:

compute C = A~~B

might work but either I have the syntax wrong or I do not understand this operator.

No. ~~ only applies to real-valued matrices.

writ wrote:2. How do I set a single row of a RECTANGULAR[series] array? Suppose I have a RECTANGULAR[series] array A that is (6,6) and I have a VECTOR[series] B that is of dimension 6. Is there an efficient way to set A(3,*) = B?

The simplest would be:

Code: Select all
`do i=1,%cols(A)   set a(3,i) = b(i)end do i`

writ wrote:3. How do I extract a single row of a RECTANGULAR[series] array? For example, suppose I have a RECTANGULAR[series] array A that is (6,6) and I want to look at all of the series contained in row 3. Is there an efficient way to extract this row as either a RECTANGULAR or a VECTOR?

As in the previous example:

Code: Select all
`dec vect[series] b(%cols(a))do i=1,%cols(a)   set b(i) = a(3,i)end do i`

writ wrote:This data type seems like a very powerful feature but I feel that I am missing some fairly basic concepts about how to use it. Any help would be much appreciated!

Thank you,

Geoff
TomDoan

Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

### Re: Help with RECTANGULAR[series]

Thanks Tom,

The RECT[series] construct is definitely useful in some contexts but can be a bit constraining in others. I think it will take me some time before I figure out which is which...

For others who are interested, I ended up using the MAKE instruction which converts a VECT[series] into a matrix. This opens up the whole range of matrix operators and functions.

All the best,

Geoff
writ

Posts: 6
Joined: Wed Jan 26, 2011 9:09 am