Page 1 of 1

Series manipulation

Posted: Mon Dec 01, 2014 2:51 pm
by alex7312
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

Re: Series manipulation

Posted: Mon Dec 01, 2014 4:25 pm
by startz

Code: Select all

smpl if xyc=1 or rnd<.3

Re: Series manipulation

Posted: Mon Dec 01, 2014 4:38 pm
by EViews Gareth
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).

Re: Series manipulation

Posted: Tue Dec 02, 2014 12:51 pm
by alex7312
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

Re: Series manipulation

Posted: Tue Dec 02, 2014 1:01 pm
by EViews Gareth
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)

Re: Series manipulation

Posted: Tue Dec 02, 2014 1:23 pm
by alex7312
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!

Re: Series manipulation

Posted: Tue Dec 02, 2014 2:24 pm
by EViews Gareth

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.

Re: Series manipulation

Posted: Tue Dec 02, 2014 2:36 pm
by alex7312
Thank you again for a solution and explanation!
Regards from far far away :D