How to specify a series range

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

eviews1
Posts: 18
Joined: Mon May 02, 2016 8:55 am

How to specify a series range

Postby eviews1 » Tue May 03, 2016 8:04 am

Hello,

Could you help to restrict the series that I add to a series of groups I create?
I am trying to create groups (can_x_us_x{!i}) from two series (can_x and us_x) with the same start date (1961) and different end dates (2010 tp 2014).
It seems that sample command does not do that.

'create recursive groups
for !i=2010 to 2014
group can_x_us_x{!i}
' smpl 1961 !i 'does not constraint
can_x_us_x{!i}.add can_x us_x
next

Thank you.

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

Re: How to specify a series range

Postby EViews Gareth » Tue May 03, 2016 8:06 am

Your question doesn't make sense. All series in a workfile page, and thus all groups, have the same start date and end date.

eviews1
Posts: 18
Joined: Mon May 02, 2016 8:55 am

Re: How to specify a series range

Postby eviews1 » Tue May 03, 2016 8:11 am

Yes I see that all groups created by the code are of the same size.

I am trying to create say group can_x_us_x2010 that contains two original series in the range 1961-2010 etc (original series are from 1961 to 2014)

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

Re: How to specify a series range

Postby EViews Gareth » Tue May 03, 2016 8:16 am

Groups are always of the same size as the workfile range. Typically in EViews you would set the sample to be the observations you are interested in, then do your analysis. EViews only uses whatever observations are in the current sample.

eviews1
Posts: 18
Joined: Mon May 02, 2016 8:55 am

Re: How to specify a series range

Postby eviews1 » Tue May 03, 2016 8:19 am

But you can run a regression on smaller size than your sample. In the same way I assume there should be a way to specify groups on sub-samples. (Eventually I try to run Johansen cointegration tests on those sub-sample groups)

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

Re: How to specify a series range

Postby EViews Gareth » Tue May 03, 2016 8:26 am

No, you cannot run a regression on a smaller size than your sample. If you want to run a regression on a smaller sample than the current sample, you set a different sample. Everything is based on the sample.

startz
Non-normality and collinearity are NOT problems!
Posts: 3797
Joined: Wed Sep 17, 2008 2:25 pm

Re: How to specify a series range

Postby startz » Tue May 03, 2016 8:27 am

Think of series, and thus groups, as always holding the maximum amount of information. You then use smpl to do procedures on selected subsamples.

eviews1
Posts: 18
Joined: Mon May 02, 2016 8:55 am

Re: How to specify a series range

Postby eviews1 » Tue May 03, 2016 8:28 am

Gareth as you said "Typically in EViews you would set the sample to be the observations you are interested in, then do your analysis.". Ho w can I do that in a piece of my code.

startz
Non-normality and collinearity are NOT problems!
Posts: 3797
Joined: Wed Sep 17, 2008 2:25 pm

Re: How to specify a series range

Postby startz » Tue May 03, 2016 8:31 am

Gareth as you said "Typically in EViews you would set the sample to be the observations you are interested in, then do your analysis.". Ho w can I do that in a piece of my code.
I'm not sure I really understand your question, but

Code: Select all

smpl 1940 1960 ls y c x

eviews1
Posts: 18
Joined: Mon May 02, 2016 8:55 am

Re: How to specify a series range

Postby eviews1 » Tue May 03, 2016 8:39 am

Startz what you posted applies to a regression. You restrict the sample size to what you want. It is correct.

I am trying to do a slightly different thing . I want to create groups with different sample sizes. I thought smpl date1 to date2 in the piece of code below would do that but it did not work

After running the code below I expected to have the following groups (The original series can_x and us_x have the sample size 1961-2014).

can_x_us_x2010 (containing two series can_x us_x over 1961-2010)
can_x_us_x2011 (containing two series can_x us_x over 1961-2011)
...
can_x_us_x2011 (containing two series can_x us_x over 1961-2014)

create recursive groups
for !i=2010 to 2014
group can_x_us_x{!i}
' smpl 1961 !i 'does not constraint
can_x_us_x{!i}.add can_x us_x
next

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

Re: How to specify a series range

Postby EViews Gareth » Tue May 03, 2016 8:42 am

I'm not sure how we can say this any differently.

Groups cannot have different lengths. They always have the same number of rows. That number of rows is equal to the number of observations in the workfile. That cannot change. You cannot create groups with different numbers of rows.

You should create a group containing the series you are interested in, then set the sample to the rows you are interested in, then do your analysis (regression, cointegration test, make a graph, whatever). Then if you want to do something on a different set of rows, change the sample again and use the same group.

eviews1
Posts: 18
Joined: Mon May 02, 2016 8:55 am

Re: How to specify a series range

Postby eviews1 » Tue May 03, 2016 8:58 am

Ok. How then select a series with a size that is smaller than the sample size.

Say my series is X from 1961 to 2014. I would like to have it only from 1961 to 2010. I tried X(1961, 2010) X(1961 2010) but it did not work.

startz
Non-normality and collinearity are NOT problems!
Posts: 3797
Joined: Wed Sep 17, 2008 2:25 pm

Re: How to specify a series range

Postby startz » Tue May 03, 2016 9:02 am

You don't select aspects of the particular series. The smpl statement tells EViews to apply all operations to the selected sample. This is different from what's done in general purpose programming languages.

You might want to take a look at http://www.eviews.com/illustrated/EView ... trated.pdf.

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

Re: How to specify a series range

Postby EViews Gareth » Tue May 03, 2016 9:03 am

Ok. How then select a series with a size that is smaller than the sample size.

Say my series is X from 1961 to 2014. I would like to have it only from 1961 to 2010. I tried X(1961, 2010) X(1961 2010) but it did not work.
You don't. A series has a set size. You cannot change the size of a series. If you only want to use the observations between 1961 and 2010, set the sample to be 1961 2010, and EViews will only use those observations.

eviews1
Posts: 18
Joined: Mon May 02, 2016 8:55 am

Re: How to specify a series range

Postby eviews1 » Tue May 03, 2016 10:32 am

Richard and Gareth, I got your point that you cannot change series but can select specific observations. How then I can tweak my code to select specific observations. I thought smpl 1961 !1 will do that.

'create recursive groups
for !i=2013 to 2014
group can_x_us_x{!i} 'create groups
smpl 1961 !i 'use specified range of observations
can_x_us_x{!i}.add can_x us_x 'add series to a group
next

Thank you.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests