+ Reply to Thread
Results 1 to 3 of 3

Calculating R-squared while ignoring zeros and #N/A

  1. #1
    Forum Contributor
    Join Date
    12-22-2012
    Location
    Asia
    MS-Off Ver
    Microsoft 365
    Posts
    238

    Calculating R-squared while ignoring zeros and #N/A

    Hi

    I have a range of data from which I want to calculate r-squared and slope. However, some of the data are zeros or #N/A. How do I calculate r-squared and slope of the non-zero numbers only?

    thanks.

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,379

    Re: Calculating R-squared while ignoring zeros and #N/A

    The help files for these functions (rsq() https://support.office.com/en-us/art...d-a8364f2be08f ) indicate that these functions will ignore boolean or text values. The usual approach, then, is to replace your N/A and 0 values with a text or boolean value.

    1) If the current set of values are being generated by some function, then next the current function inside of an IF() function that will replace 0 and N/A errors with something ignored: =IFNA(IF(currentformula=0,"text",currentformula),"text").
    2) Using a helper column, enter something like =IFERROR(IF(value=0,"text",value),"text"), then use the helper column in your SLOPE() and RSQ() functions.
    3) Use an array function, where you use something like 2 inside of the SLOPE() and RSQ() function =SLOPE(IFERROR(...)) (confirm with ctrl-shift-enter).

    One consideration: there is duplicated effort in both 1 and 3 that may slow calculation down if this is a large data set. 2 might be preferable if this slows the spreadsheet down too much.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Valued Forum Contributor ranman256's Avatar
    Join Date
    07-29-2012
    Location
    Kentucky
    MS-Off Ver
    Excel 2003
    Posts
    1,190

    Re: Calculating R-squared while ignoring zeros and #N/A

    if cell =#NA, and is part of the formula,then make another cell that translates NA to 0.

    if B2 = #NA, then set C2 :=IFNA(B2,0)
    run slope on c (on col c for all cells)
    Last edited by ranman256; 01-22-2018 at 02:44 PM.

+ 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. [SOLVED] Calculating R-squared for selective data
    By L.LEE in forum Excel General
    Replies: 2
    Last Post: 12-23-2016, 11:55 PM
  2. [SOLVED] Calculating Sum of count of 2 variables squared per row
    By ChemistB in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-09-2015, 11:50 AM
  3. Min formula ignoring zeros.
    By jvandermolen in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-08-2014, 12:33 PM
  4. Ignoring values with zeros
    By exdox77 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-06-2013, 10:32 PM
  5. Median if - ignoring zeros
    By adame in forum Excel General
    Replies: 1
    Last Post: 05-24-2012, 11:57 AM
  6. linest r-squared bug when calculating forced through zero?
    By Filtration Guy in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 11-13-2005, 09:50 PM
  7. [SOLVED] Averaging, ignoring zeros
    By Mark in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 02-28-2005, 07:06 PM

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