a series of 1's and -1's

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

a series of 1's and -1's

mark leeds-4
Does anyone know of a simple test
in any R package that given
a series of negative ones and positive
ones ( no other values are possible in the series )
returns a test of whether the series is random or not.
( a test at each point would be good but
I can use the apply function to implement
that ) ?
 
                                       thanks.
                                 


**********************************************************************
This email and any files transmitted with it are confidentia...{{dropped}}

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: a series of 1's and -1's

McGehee, Robert
I would compare the Shannon entropy of your test vector with the entropy
of your expected probability distribution to see if they are close. That
is, if you're binary probability distribution is half 1 and half -1,
then if your string is long you would expect about half the numbers in
your vector to be 1 and half to be -1, i.e. H(s)=1. Moreover, you should
also look at the entropy of every subset of the vector and compare that
to your distribution as well. For instance, does the sequence (1, 1)
show up just as often as (1, -1), (-1, 1) and (-1, 1)? As this problem
is specific to a certain random process, I doubt there is a canned test
in R.

Also, the sample entropy should converge to the distribution of the
underlying process as the sample size increases for all subsets of the
sample, probably following a t-distribution (Central Limit Theorem),
although I'd need to noodle on this a bit more. You can then construct a
test of significance if you know the sample size and how far the sample
entropy is from the hypothesized process's distribution. Unfortunately,
it's been a while since I've done information encoding, but hopefully
this gets you started.

You can read up on informational entropy here:
http://en.wikipedia.org/wiki/Informational_entropy

And if you do find a test in R, I would be interested as well.

Best,
Robert

-----Original Message-----
From: Mark Leeds [mailto:[hidden email]]
Sent: Wednesday, January 11, 2006 4:46 PM
To: R-Stat Help
Subject: [R] a series of 1's and -1's

Does anyone know of a simple test
in any R package that given
a series of negative ones and positive
ones ( no other values are possible in the series )
returns a test of whether the series is random or not.
( a test at each point would be good but
I can use the apply function to implement
that ) ?
 
                                       thanks.
                                 


**********************************************************************
This email and any files transmitted with it are
confidentia...{{dropped}}

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: a series of 1's and -1's

Roger Bivand
In reply to this post by mark leeds-4
On Wed, 11 Jan 2006, Mark Leeds wrote:

> Does anyone know of a simple test
> in any R package that given
> a series of negative ones and positive
> ones ( no other values are possible in the series )
> returns a test of whether the series is random or not.
> ( a test at each point would be good but
> I can use the apply function to implement
> that ) ?

help.search("runs") points to function runs.test() in package tseries,
with examples:

x <- factor(sign(rnorm(100))) # randomness
runs.test(x)
x <- factor(rep(c(-1, 1), 50)) # over-mixing
runs.test(x)

which looks like your case

>  
>                                        thanks.
>                                  
>
>
> **********************************************************************
> This email and any files transmitted with it are confidentia...{{dropped}}
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: [hidden email]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Roger Bivand
Department of Economics
NHH Norwegian School of Economics
Helleveien 30
N-5045 Bergen, Norway
Reply | Threaded
Open this post in threaded view
|

Re: a series of 1's and -1's

Ingmar Visser
You could try to zip your data file and see whether there is a change in
file size that you feel is significant in which case the series is not
random (-:
To be sure, there is no such thing as a positive test for randomness, only
tests for specific deviations of randomness of which the runs.test and the
entropy are just two examples. Zip programs use a whole bunch of these tests
to compress files by finding structure in the data.
best, ingmar

> From: Roger Bivand <[hidden email]>
> Reply-To: [hidden email]
> Date: Thu, 12 Jan 2006 08:42:25 +0100 (CET)
> To: Mark Leeds <[hidden email]>
> Cc: R-Stat Help <[hidden email]>
> Subject: Re: [R] a series of 1's and -1's
>
> On Wed, 11 Jan 2006, Mark Leeds wrote:
>
>> Does anyone know of a simple test
>> in any R package that given
>> a series of negative ones and positive
>> ones ( no other values are possible in the series )
>> returns a test of whether the series is random or not.
>> ( a test at each point would be good but
>> I can use the apply function to implement
>> that ) ?
>
> help.search("runs") points to function runs.test() in package tseries,
> with examples:
>
> x <- factor(sign(rnorm(100))) # randomness
> runs.test(x)
> x <- factor(rep(c(-1, 1), 50)) # over-mixing
> runs.test(x)
>
> which looks like your case
>
>>  
>>                                        thanks.
>>                
>>
>>
>> **********************************************************************
>> This email and any files transmitted with it are confidentia...{{dropped}}
>>
>> ______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>>
>
> --
> Roger Bivand
> Economic Geography Section, Department of Economics, Norwegian School of
> Economics and Business Administration, Helleveien 30, N-5045 Bergen,
> Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
> e-mail: [hidden email]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: a series of 1's and -1's

Johannes Huesing
> You could try to zip your data file and see whether there is a change in
> file size that you feel is significant in which case the series is not
> random (-:

... after converting the -1s and 1s to bits, of course.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html