+ Reply to Thread
Results 1 to 3 of 3

Chi squared statistic function

  1. #1
    Registered User
    Join Date
    10-06-2008
    Location
    London
    Posts
    2

    Chi squared statistic function

    Hi!

    First post so I hope this is okay.

    I'm trying to write a VBA function which performs the chi squared test (a simple statistical test to compare proportions).

    It works (roughly) by comparing the difference between observed values for cells in (say) a two-by-two grid, and the expected values for those cells (calculated by multiplying the row total by the column total and dividing by the overall total).

    I hope to get it to work without having to calculate the expected values as set out in the CHITEST Excel function.

    I’m trying to convert over code which works in ASP, but I don’t think I’m calling it correctly, as I keep getting #VALUE! or #NUM!

    Here's the code...
    Please Login or Register  to view this content.
    ...and an example's attached.

    Thanks!

    Iain
    Attached Files Attached Files
    Last edited by igillesp; 10-06-2008 at 03:14 PM.

  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
    Using Integer you get overflow. Use Doubles.
    Please Login or Register  to view this content.
    Also, in this declaration,
    Please Login or Register  to view this content.
    ... everything but chival is declared as a Variant.

    You can do this,
    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    10-06-2008
    Location
    London
    Posts
    2
    Brilliant!

    Thanks!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How does this code output the coefficients of a trendline?
    By gshock in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-13-2010, 05:54 PM
  2. Excel 2007 error when adding custom help file to user defined function
    By sabotuer99 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-04-2009, 01:10 AM
  3. Modify a Function to add an extra condition
    By King_Quake in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-03-2008, 04:32 PM
  4. Link together different cells in specific order?
    By Sandman4432 in forum Excel Formulas & Functions
    Replies: 19
    Last Post: 01-03-2008, 05:01 AM
  5. Analysis Toolpak Function XIRR and VBA - XL 2007
    By rvExcelNewTip in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-02-2007, 04:35 AM

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