Grouping vectors

For questions regarding the import, export and manipulation of data in EViews, including graphing and basic statistics.

Moderators: EViews Gareth, EViews Jason, EViews Steve, EViews Moderator

skaiser
Posts: 6
Joined: Tue Jul 19, 2016 12:32 pm

Grouping vectors

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.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 12067
Joined: Tue Sep 16, 2008 5:38 pm

Re: Grouping vectors

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

skaiser
Posts: 6
Joined: Tue Jul 19, 2016 12:32 pm

Re: Grouping vectors

I've not used @hcat before, am I able to loop through the vectors and append them or should I use colplace for that?

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 12067
Joined: Tue Sep 16, 2008 5:38 pm

Re: Grouping vectors

Either.

skaiser
Posts: 6
Joined: Tue Jul 19, 2016 12:32 pm

Re: Grouping vectors

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

skaiser
Posts: 6
Joined: Tue Jul 19, 2016 12:32 pm

Re: Grouping vectors

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)

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 12067
Joined: Tue Sep 16, 2008 5:38 pm

Re: Grouping vectors

What are you trying to save?

skaiser
Posts: 6
Joined: Tue Jul 19, 2016 12:32 pm

Re: Grouping vectors

At each step of the rolling regression I am trying to save the residual from that regression.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 12067
Joined: Tue Sep 16, 2008 5:38 pm

Re: Grouping vectors

"residual" is not a scalar. It is a series.

skaiser
Posts: 6
Joined: Tue Jul 19, 2016 12:32 pm

Re: Grouping vectors

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.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 12067
Joined: Tue Sep 16, 2008 5:38 pm

Re: Grouping vectors

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.

shineK
Posts: 24
Joined: Sat Jun 09, 2018 12:23 am
Location: New Taipei City,Taiwan
Contact:

Re: Grouping vectors

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!!!
Best,
SK

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 12067
Joined: Tue Sep 16, 2008 5:38 pm

Re: Grouping vectors

svectors cannot be put into a matrix.