Page 1 of 1

Create new time series object based on values of another

Posted: Mon May 23, 2016 8:24 pm
by PChindamo
I'm new to Eviews and this user forum. I need help with the following to create a new time series object called B:

A is an existing time series object; B is a new calculated time series object

IF(A>(2089.71+70), B = A -70))

IF(A >(180+3.49), B=(A-3.49+0.035*180)/1.035))

IF(A<180, B=(A-3.49))

Re: Create new time series object based on values of another

Posted: Mon May 23, 2016 8:32 pm
by startz
Look at @recode()

Re: Create new time series object based on values of another

Posted: Mon May 23, 2016 9:08 pm
by PChindamo
I did try recode but Eviews returned an error message about too many arguments.

Re: Create new time series object based on values of another

Posted: Mon May 23, 2016 9:15 pm
by EViews Gareth
You probably did something wrong.

Re: Create new time series object based on values of another

Posted: Mon May 23, 2016 9:20 pm
by PChindamo
That's really insightful - I thought I had probably done something wrong when Eviews returned an error. Is there any advice you can provide beyond "you probably did something wrong"?

Re: Create new time series object based on values of another

Posted: Mon May 23, 2016 9:24 pm
by EViews Gareth
Not without out knowing what you did.

Re: Create new time series object based on values of another

Posted: Mon May 23, 2016 9:58 pm
by startz
Well I know what you did.
You gave @recode more than 3 arguments.

Re: Create new time series object based on values of another

Posted: Mon May 23, 2016 10:22 pm
by PChindamo
yes I gave @recode more than 3 arguments. How do I fix this if there are three categories (arguments)? Do I need to do each one at a time?

Re: Create new time series object based on values of another

Posted: Mon May 23, 2016 10:30 pm
by EViews Gareth
You will have to nest a couple of recodes inside each other.

Code: Select all

Series a = @recode(x<5, @recode(x<3, 10, 20), 30)

Re: Create new time series object based on values of another

Posted: Mon May 23, 2016 11:52 pm
by PChindamo
thanks, I will give it a try.

Re: Create new time series object based on values of another

Posted: Tue Jun 07, 2016 2:59 am
by bob_dubai
Greetings:
I have a similar problem.
I have two series

First series : Personal_Income ( $ )
Second series : Age ( years old )

i would like to make a group with two new series :

Personal_Income_Of_Young :: Income of people below 25
Personal_income_Of_Old :: income of people above 50

If i could get these new series into a group , then i could call .testbtw and
get stats on the differences in these two age groups

there seems to be no way to "Freeze" a smpl command after i create one of
the new series.
Hope this is understandable ..

Many thanks for any hints or advice --!

Re: Create new time series object based on values of another

Posted: Tue Jun 07, 2016 3:07 am
by EViews Gareth
What you're describing doesn't really fit in with the structure of EViews.


All series in a workfile page have the same structure - the same number of observations.

So you have two series:

Code: Select all

Income Age 10,000 25 12,000 23 34,000 45 56,000 60 13,000 22
Which means you have 5 observations. Any new series you create will also have 5 observations. So in your case where you say you want to create a series that will contain income information for those under 25, what would the other 3 observations be?

Re: Create new time series object based on values of another

Posted: Tue Jun 07, 2016 3:12 am
by bob_dubai
thanks for the reply - I would NOT have 5 samples any more, I would have two unequal series

I found that I could create two (unequal length ) vectors and then do the
required stats on the vectors with my own code, but could not get
Groups to accept vectors as members so I could not call .testbtw on the group members .

I will try the "stats by classification " -
Oh well, thanks for the confirmation that my approach needs reconsideration

Re: Create new time series object based on values of another

Posted: Tue Jun 07, 2016 3:13 am
by EViews Gareth
I think a specific solution to your overall problem would be to do the following:
  • Create an indicator series that is equal to 1 for young people, 0 for middle aged and 2 for old people:

    Code: Select all

    series indicator = @recode(age>50,2, @recode(age<25,1,0))
  • set the sample to be if indicator>0 (i.e. only young or old people):

    Code: Select all

    smpl if indicator>0
  • Open up the income series and click on View->Descriptive Statistics->Equality Tests by Classification, and enter Indicator as the classifying series.