Page 1 of 1

Grouping vectors

Posted: Tue Jul 19, 2016 12:36 pm
by skaiser
I have a large number of vectors that capture the r2 and tstat of rolling regressions. How do I collect all of those vectors into either a group or a matrix? I tried to create a group and then you MTOS but it doesn't seem to be working for me. Thanks very much.

Re: Grouping vectors

Posted: Tue Jul 19, 2016 12:46 pm
by EViews Gareth
Groups can only contain series, not vectors.

You'll have to put them in a matrix.

You can use the colplace command or the @hcat function

Re: Grouping vectors

Posted: Tue Jul 19, 2016 1:00 pm
by skaiser
I've not used @hcat before, am I able to loop through the vectors and append them or should I use colplace for that?

Re: Grouping vectors

Posted: Tue Jul 19, 2016 1:13 pm
by EViews Gareth
Either.

Re: Grouping vectors

Posted: Wed Aug 10, 2016 6:22 am
by skaiser
Thanks for the help. As a follow-up I am trying to store the residual from each step of a rolling regression. I tried the commands below but it is returning only the last 100 observations, which is the length of the rolling regression window. is there a better (i.e. correct) way to do this? Thanks for the help. Stuart

''Vector to store r^2 and t-stats
vector(!i) regmulti_r2_{%k}
regmulti_r2_{%k}(!i) = regmulti.@r2

vector(!i) regmulti_ts{%l}_{%k}
regmulti_ts{%l}_{%k}(!i) = regmulti.@tstats({%l})

vector(!i) regmulti_err_{%k}
regmulti.makeresid res1
regmulti_err_{%k} = res1

Re: Grouping vectors

Posted: Wed Aug 10, 2016 6:29 am
by skaiser
Is this just as simple as adding (!I) to the final line? If so, I'm an idiot.

vector(!i) regmulti_err_{%k}
regmulti.makeresid res1
regmulti_err_{%k}(!I) = res1(!I)

Re: Grouping vectors

Posted: Wed Aug 10, 2016 8:49 am
by EViews Gareth
What are you trying to save?

Re: Grouping vectors

Posted: Wed Aug 10, 2016 10:25 am
by skaiser
At each step of the rolling regression I am trying to save the residual from that regression.

Re: Grouping vectors

Posted: Wed Aug 10, 2016 10:57 am
by EViews Gareth
"residual" is not a scalar. It is a series.

Re: Grouping vectors

Posted: Wed Aug 10, 2016 11:28 am
by skaiser
In the context of a rolling regression the series is only going to be as long as the regression window so I think I need to grab the last observation and append those to a series.

Re: Grouping vectors

Posted: Wed Aug 10, 2016 11:50 am
by EViews Gareth
Use the @elem function to grab the single observation, or set the sample to be a single observation and take the max of the residuals.

Re: Grouping vectors

Posted: Mon Jun 18, 2018 5:22 am
by shineK
Hi there,

i have 2 svector sv1 and sv2, how do i collect both of them into matrix?
i had tried to use @hcat but it doesn't work...
do you have any idea for combining these 2 svec?
Thanks a lot!!!

Re: Grouping vectors

Posted: Mon Jun 18, 2018 7:11 am
by EViews Gareth
svectors cannot be put into a matrix.