+ Reply to Thread
Results 1 to 6 of 6

problem using CHITEST(IF...

  1. #1
    Registered User
    Join Date
    11-09-2010
    Location
    Denver
    MS-Off Ver
    Excel 2008
    Posts
    5

    problem using CHITEST(IF...

    Hello,

    I'm trying to compute CHITEST for several subsets inside the same sheet. But there is some problem when I combine CHITEST and IF:

    Writing:
    {=IF($A$2:$A$1606=$A2,$U$2:$U$1606)}
    I get: {2,1,1,0,1}
    (values in U2:U6)

    But if I write:
    {=CHITEST((IF($A$2:$A$1606=$A2,$U$2:$U$1606)),{1,1,1,1,1})}
    I get: #N/A

    However, writing:
    =CHITEST({2,1,1,0,1},{1,1,1,1,1})
    or
    =CHITEST(U2:U6,{1,1,1,1,1})
    I get: 0.73


    Any idea?

    (I'm using Office 2008 for Mac)

    Thank you in advance.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: problem using CHITEST(IF...

    Writing {=IF($A$2:$A$1606=$A2, $U$2:$U$1606)} I get: {2,1,1,0,1} (values in U2:U6)
    I don't think so; where col A values <> A2, you get FALSE, so you might get {2,1,1,0,1, FALSE, FALSE, ...}, right?

    That gives an unequal number of values, which causes NA.
    Last edited by shg; 11-09-2010 at 12:26 PM.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    11-09-2010
    Location
    Denver
    MS-Off Ver
    Excel 2008
    Posts
    5

    Re: problem using CHITEST(IF...

    Ok, thanks. That's the problem!

    Any idea to get rid of all the FALSE, FALSE,... of the first array? i.e. to pass from one array of 1606 values where only 5 are different than FALSE to an array of only those 5 elements.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: problem using CHITEST(IF...

    This has surely been done (maybe in MoreFunc?)

    Please Login or Register  to view this content.
    Then you can use

    =CHITEST(AggIf($A$2:$A$1606=$A2, $U$2:$U$1606), {1,1,1,1,1})

    ... confirmed with Ctrl+Shift+Enter

  5. #5
    Registered User
    Join Date
    11-09-2010
    Location
    Denver
    MS-Off Ver
    Excel 2008
    Posts
    5

    Re: problem using CHITEST(IF...

    Thanks a lot shg!

    The problem is that, as far as I know, with the office 2008 version for mac VBA is not available. I wish it was.

    I've just solved my problem in two steps: (taking into account the chi square formula and that my expected value is always 1):
    1. X2 {=SUM(IF($A$2:$A$1606=$A2,$U$2:$U$1606-1,0)^2)}
    computes chi square test

    2. =CHIDIST(X2,I2-1)
    where I2 has the number of observations.


    Anyway, whether I can ever use VBA I will use you function which is more general

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: problem using CHITEST(IF...

    Nicely done. (I should have noticed that you're using Excel 2008.)

    Performance-wise, native functions will usually (and substantially) outperform UDFs.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1