Difference between series and vector

For questions that don't fall into one of the categories above, such as working with the RATS interface, using Wizards, etc.
ivory4
Posts: 144
Joined: Mon Aug 24, 2009 12:16 pm

Difference between series and vector

Unread post by ivory4 »

Series is an one dimensional "time" array

Vector is an one dimensional array starting from 1

The difference is "TIME" ?

Could you give an example to tell the difference?

Thanks

In addition, "A series consist of bookkeeping information such as defined length and a pointer to the data"

What does this mean in the manual?

PS: data(format=xls,org=col) / ue def ygap ue1 ue2 ***load the data***
display ue should show the series number (e.g. 1 here) , but now it says display doesnot show series.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Difference between series and vector

Unread post by TomDoan »

This is an example with a series:

Code: Select all

set xs 1 100 = %ran(1.0)
set ds = xs-xs{1}
xs is a series of 100 random numbers. ds is its first difference. The entries of ds and xs stay aligned, even though ds has 1 less entry. You can thus do things like:

Code: Select all

linreg ds
# constant xs{1} ds{1 2 3}
for an ADF test, without having to worry about aligning the data. Doing the same thing with Gauss or Matlab requires the user to carefully shift data so that the original entry 5's end up in entry 1 in the constructed matrix of regressors.

As a general rule, you want to keep data in series, and use vectors and matrices for derived calculations done most easily with matrix operations, or for keeping track of information that is naturally sequenced starting at 1.

Yes, DISPLAY doesn't work on series. Use PRINT instead. It has options and parameters for choosing the range to show.
ivory4
Posts: 144
Joined: Mon Aug 24, 2009 12:16 pm

Re: Difference between series and vector

Unread post by ivory4 »

TomDoan wrote:This is an example with a series:

Code: Select all

set xs 1 100 = %ran(1.0)
set ds = xs-xs{1}
xs is a series of 100 random numbers. ds is its first difference. The entries of ds and xs stay aligned, even though ds has 1 less entry. You can thus do things like:

Code: Select all

linreg ds
# constant xs{1} ds{1 2 3}
for an ADF test, without having to worry about aligning the data. Doing the same thing with Gauss or Matlab requires the user to carefully shift data so that the original entry 5's end up in entry 1 in the constructed matrix of regressors.

As a general rule, you want to keep data in series, and use vectors and matrices for derived calculations done most easily with matrix operations, or for keeping track of information that is naturally sequenced starting at 1.

Yes, DISPLAY doesn't work on series. Use PRINT instead. It has options and parameters for choosing the range to show.
So even though we think that xs and ds(as in Gauss) have different number of elements, but in Rats they are treated as aligned "series".

If xs and ds are set up as Vector, there will be difference?

What is the "display" function for Vector and Symmetric ?
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Difference between series and vector

Unread post by TomDoan »

ivory4 wrote: So even though we think that xs and ds(as in Gauss) have different number of elements, but in Rats they are treated as aligned "series".

If xs and ds are set up as Vector, there will be difference?
Yes. The equivalent done as a vector with something like

Code: Select all

dec vect xv(100)
compute xv=%ran(1.0)
compute dv=%xsubvec(xv,2,100)-%xsubvec(xv,1,99)
would have dv as a 99-vector with dv(1) corresponding to xv(2). As in Gauss, you would have to create a subvector of xv from 2 to 100 to get the two properly aligned for further calculations. Obviously, that's needlessly complicated when the SERIES data type handles that automatically.
ivory4 wrote: What is the "display" function for Vector and Symmetric ?
A VECTOR displays as a single row (to the extent possible - it will wrap if the line gets too long). A SYMMETRIC displays as its lower triangle.
ivory4
Posts: 144
Joined: Mon Aug 24, 2009 12:16 pm

Re: Difference between series and vector

Unread post by ivory4 »

TomDoan wrote:
ivory4 wrote: So even though we think that xs and ds(as in Gauss) have different number of elements, but in Rats they are treated as aligned "series".

If xs and ds are set up as Vector, there will be difference?
Yes. The equivalent done as a vector with something like

Code: Select all

dec vect xv(100)
compute xv=%ran(1.0)
compute dv=%xsubvec(xv,2,100)-%xsubvec(xv,1,99)
would have dv as a 99-vector with dv(1) corresponding to xv(2). As in Gauss, you would have to create a subvector of xv from 2 to 100 to get the two properly aligned for further calculations. Obviously, that's needless complicated when the SERIES data type handles that automatically..
From this example, I can clearly tell the difference between a "Series" in Rats and a "Vector"
And "Vector" does not need declaration when it is created from functions, right?
Another question is when I declare a "Vector", when COMPUTE is used to assign value? I thought COMPUTE is used to assign a SINGLE REAL number.

For example, when we use DLM to estimate a State-SPace model, I would like to collect the states (Txk, T observations k variables)
declare vector beta(375)
set beta / = xstates(t)(1) OR compute?

Thanks


TomDoan wrote:
ivory4 wrote: What is the "display" function for Vector and Symmetric ?
A VECTOR displays as a single row (to the extent possible - it will wrap if the line gets too long). A SYMMETRIC displays as its lower triangle.
ivory4
Posts: 144
Joined: Mon Aug 24, 2009 12:16 pm

Re: Difference between series and vector

Unread post by ivory4 »

Based on my test, I know that Compute is needed to fill in values for a vector. But I still do not understand why I am filling a series of value and USING a command which generally fill in a single value.

Then how to create a "SERIES" with the same value as the vector?
Because for graph function, only SERIES is allowed.

THanks
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Difference between series and vector

Unread post by TomDoan »

Please don't quote entire messages, just the part that's relevant to a particular post.
ivory4 wrote:
From this example, I can clearly tell the difference between a "Series" in Rats and a "Vector"
And "Vector" does not need declaration when it is created from functions, right?
Another question is when I declare a "Vector", when COMPUTE is used to assign value? I thought COMPUTE is used to assign a SINGLE REAL number.
COMPUTE can be used for any calculation where the operands in the calculation are "self-contained". It can do matrices (standard linear algebra functions), scalars, strings. It can't do series because a series is a combination of data and range; the SET instruction includes parameters to control the range. It also can't do calculations with matrices which are elementwise operations, except for a handful of basic ones (+, -, .*, ./, .^ operations, %SQRT, %LOG, %EXP and %ABS functions). For other calculations like that, you need to use EWISE.
ivory4 wrote: For example, when we use DLM to estimate a State-SPace model, I would like to collect the states (Txk, T observations k variables)
declare vector beta(375)
set beta / = xstates(t)(1) OR compute?
You can't apply SET to a VECTOR. You can't apply COMPUTE because the formula needs to pull information out entry by entry. If you really need the information in a VECTOR rather than a SERIES (you might want to think that through), you would do it with EWISE:

Code: Select all

declare vector beta(375)
ewise beta(t)=xstates(t)(1)
ivory4
Posts: 144
Joined: Mon Aug 24, 2009 12:16 pm

Re: Difference between series and vector

Unread post by ivory4 »

TomDoan wrote: You can't apply SET to a VECTOR. You can't apply COMPUTE because the formula needs to pull information out entry by entry. If you really need the information in a VECTOR rather than a SERIES (you might want to think that through), you would do it with EWISE:

Code: Select all

declare vector beta(375)
ewise beta(t)=xstates(t)(1)
If I need to record the results in a series, what to do?
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Difference between series and vector

Unread post by TomDoan »

ivory4 wrote:If I need to record the results in a series, what to do?
That would be

Code: Select all

set beta = xstates(t)(1)
You just can't use beta (or any other variable name) as two different types in one program.
ivory4
Posts: 144
Joined: Mon Aug 24, 2009 12:16 pm

Re: Difference between series and vector

Unread post by ivory4 »

TomDoan wrote:
That would be

Code: Select all

set beta = xstates(t)(1)
You just can't use beta (or any other variable name) as two different types in one program.

And set beta =%scalar(xstates(t)) has the same effect?
But not good for the case if xstates include more than 1 variable's state?

If I would like to record the states at Time T, suppose states are Tx5, set beta T T =xstates(t)(1) Right and the firs T could be changed to any number smaller than T.
In this way "beta" is kept as series.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Difference between series and vector

Unread post by TomDoan »

%scalar(xstates(t)) and xstates(t)(1) are the same thing. %scalar(vector or matrix) is the 1st element in the vector or matrix. When you have 5 states, you can't use %scalar for more than the first state, so it probably makes more sense to pull everything out in a similar form which would be xstates(t)(component)
Post Reply