Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Correlating binary variables

  • To: mathgroup at smc.vnet.net
  • Subject: [mg70311] Re: Correlating binary variables
  • From: "Philpp" <piotr at bigpond.net.au>
  • Date: Thu, 12 Oct 2006 05:37:53 -0400 (EDT)
  • References: <egi17o$j42$1@smc.vnet.net>

Mickey,

Although the numbers you've given are consisting of 0s and 1s, they are
interpreted as decimal integers by Mathematica. You need to "force"
them to be interpreted as binary and convert them to their decimal
representation before doing regression.

In[1]:=  Map[FromDigits[IntegerDigits[#, 10], 2] &, {10101000101010010,
          1010010100101001, 01010010100100101}]
Out[1]=  {86354, 107817, 42277}

or

In[2]:=  Clear[f];
         f[binaryAsdecimal_Integer] :=
          FromDigits[IntegerDigits[binaryAsdecimal, 10], 2];
         Map[f, {10101000101010010, 11010010100101001,
          01010010100100101}]
Out[4]=  {86354, 107817, 42277}

For comparison

In[5]:=  {2^^10101000101010010, 2^^11010010100101001,
          2^^01010010100100101}
Out[5]=  {86354, 107817, 42277}

Cheers,
Phil.

mickey wrote:

> Hi,
>
> I have a problem where I am trying to find the correlation between a
> series of binary variables.
>
> 10101000101010010
> 11010010100101001
> 01010010100100101
>
> and so on. What is good way of going about this? Linear regression
> doesnt seem to be that good a way of doing things when both variables
> are binary.
> 
> Thanks,
> -M


  • Prev by Date: Re: Definition of SE (standard error) in LinearRegress and NonlinearRegress
  • Next by Date: Re: recursive blues :(
  • Previous by thread: Re: Correlating binary variables
  • Next by thread: recursive blues :(