Difference between series and vector
Difference between series and vector
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.
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.
Re: Difference between series and vector
This is an example with a series:
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:
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.
Code: Select all
set xs 1 100 = %ran(1.0)
set ds = xs-xs{1}Code: Select all
linreg ds
# constant xs{1} ds{1 2 3}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.
Re: Difference between series and vector
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".TomDoan wrote:This is an example with a series:
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
set xs 1 100 = %ran(1.0) set ds = xs-xs{1}
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.Code: Select all
linreg ds # constant xs{1} ds{1 2 3}
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.
If xs and ds are set up as Vector, there will be difference?
What is the "display" function for Vector and Symmetric ?
Re: Difference between series and vector
Yes. The equivalent done as a vector with something likeivory4 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?
Code: Select all
dec vect xv(100)
compute xv=%ran(1.0)
compute dv=%xsubvec(xv,2,100)-%xsubvec(xv,1,99)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 wrote: What is the "display" function for Vector and Symmetric ?
Re: Difference between series and vector
From this example, I can clearly tell the difference between a "Series" in Rats and a "Vector"TomDoan wrote:Yes. The equivalent done as a vector with something likeivory4 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?
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..Code: Select all
dec vect xv(100) compute xv=%ran(1.0) compute dv=%xsubvec(xv,2,100)-%xsubvec(xv,1,99)
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: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 wrote: What is the "display" function for Vector and Symmetric ?
Re: Difference between series and vector
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
Then how to create a "SERIES" with the same value as the vector?
Because for graph function, only SERIES is allowed.
THanks
Re: Difference between series and vector
Please don't quote entire messages, just the part that's relevant to a particular post.
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:
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.
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: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?
Code: Select all
declare vector beta(375)
ewise beta(t)=xstates(t)(1)Re: Difference between series and vector
If I need to record the results in a series, what to do?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)
Re: Difference between series and vector
That would beivory4 wrote:If I need to record the results in a series, what to do?
Code: Select all
set beta = xstates(t)(1)Re: Difference between series and vector
TomDoan wrote:
That would be
You just can't use beta (or any other variable name) as two different types in one program.Code: Select all
set beta = xstates(t)(1)
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.
Re: Difference between series and vector
%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)