Page 1 of 1
How to compare two samples?
Posted: Wed Aug 20, 2014 11:30 am
by Liu
Hi,
I want to either directly compare two sample objects, or extract them into strings and then compare or manipuate them. How can I do that?
I tried direct comparison for samples, but it doesn't work.
For example:
sample s1 1921 2010
sample s2 1920 2010
if s1=s2 then %error="Samples are the same"
else %error="Samples are not the same"
endif
show %error
Thank you.
Re: How to compare two samples?
Posted: Wed Aug 20, 2014 3:08 pm
by EViews Gareth
What do you want to compare about them? Whether the text specification is the same, or whether they have identical observations?
Re: How to compare two samples?
Posted: Thu Aug 21, 2014 8:28 am
by Liu
I want to compare them as strings, or values. The reason is that I create multiple charts and they have different start and end date.
I have to write commands to save the information of each sample range for charts and compare them. That's why the sample comparison is very important to me.
Hope that make sense.
Re: How to compare two samples?
Posted: Thu Aug 21, 2014 12:53 pm
by EViews Gareth
When I asked the question above I imagined that we had added a datamember for a sample to return its string specification. Turns out we didn't. So you're pretty much out of luck. I can't think of a way to do it.
For the values, the only thing available is to set the workfile sample equal to each sample, generate a series, then compare the values of the series under each sample. Something like:
Code: Select all
smpl s1
series comparison1 = 1
smpl s2
series comparison2 = 1
smpl if comparison1<>comparison2
if @obssmp>0 then
'samples are different
endif
smpl @all