Series manipulation

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

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

alex7312
Posts: 6
Joined: Mon Dec 01, 2014 2:30 pm

Series manipulation

Postby alex7312 » Mon Dec 01, 2014 2:51 pm

Hi everybody. I have a binary series named xyc (default indicator, dependent variable) where ones are in minority.
I would like to form a new sample where all items which are ones are included and certain portion of zeros included (let's say 30% of the remaining series) but this remaining portion to be selected in a random manner...sort of bootstrapping ...can it be done ?

Best regards

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

Re: Series manipulation

Postby startz » Mon Dec 01, 2014 4:25 pm

Code: Select all

smpl if xyc=1 or rnd<.3

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

Re: Series manipulation

Postby EViews Gareth » Mon Dec 01, 2014 4:38 pm

Startz solution will give a sample including all the 1s, and where each 0 has a 30% chance of being included, which is not quite the same as saying that 30% of the zeros will be included (in a finite sample).

alex7312
Posts: 6
Joined: Mon Dec 01, 2014 2:30 pm

Re: Series manipulation

Postby alex7312 » Tue Dec 02, 2014 12:51 pm

Thanks a lot Starz, very elegant solution :)

Gareth do you have something else in mind? Let's say I want to include all defaults =1 and the first 1/3 zeros then second portion of 1/3 zeros and the last third (and to check different results of logit)...how to do it? can I use something @first....?

best regards

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

Re: Series manipulation

Postby EViews Gareth » Tue Dec 02, 2014 1:01 pm

ugly, but should work:

Code: Select all

smpl @first @first series trend0=xyc=1 smpl @first+1 @last series trend0 = @recode(xyc=1, trend0(-1), trend0(-1)+1) smpl if xyc=1 or trend0<(1/3)*@max(trend0) or trend0>(2/3)*@max(trend0)

alex7312
Posts: 6
Joined: Mon Dec 01, 2014 2:30 pm

Re: Series manipulation

Postby alex7312 » Tue Dec 02, 2014 1:23 pm

hey, far from ugly :)

Could I ask for some explanation (as it is a bit advanced for me...)??
e.g. @first @first - it means first two observations are taken ?

and the middle part

smpl @first+1 @last /excludes the first two??/

series trend0 = @recode(xyc=1, trend0(-1), trend0(-1)+1)
what does it mean? and how does it work :D ??


Thanks a lot!

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

Re: Series manipulation

Postby EViews Gareth » Tue Dec 02, 2014 2:24 pm

Code: Select all

smpl @first @first
first observation only.

Code: Select all

smpl @first+1 @last
second observation onwards.

Code: Select all

series trend0 = @recode(xyc=1, trend0(-1), trend0(-1)+1)
create a series, trend0, that is equal to the previous value of trend0 whenever xyc=1 and equal to the previous value plus one whenever xyc=0. It basically creates a trend, increasing by one whenever xyc=0.

alex7312
Posts: 6
Joined: Mon Dec 01, 2014 2:30 pm

Re: Series manipulation

Postby alex7312 » Tue Dec 02, 2014 2:36 pm

Thank you again for a solution and explanation!
Regards from far far away :D


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 2 guests