RSQ function
RSQ shows how much of the variation in one set of values is explained by another in a straight-line fit. It returns the square of the correlation coefficient, from 0 to 1.
Example
Read it as a sentence: measure how well a straight line fits the G1:G5 values against the F1:F5 values, which gives 0.6.
Excel shows 0.6
F
G
1
1
2
2
2
4
3
3
5
4
4
4
5
5
5
Data
Syntax
RSQ(known_y's, known_x's)
-
known_y's(required) - The dependent values.
-
known_x's(required) - The independent values.
Returns: The square of the correlation coefficient, from 0 to 1.
What Excel actually returns
Each formula below was run in desktop Excel. The result is exactly what the cell showed, errors included.
| Formula | Excel shows | Case |
|---|---|---|
=RSQ({2,4,5,4,5},{1,2,3,4,5}) | 0.6 | Array constants |
=RSQ(Data!G1:G5,Data!F1:F5) | 0.6 | Two ranges (y,x order as written) |
=RSQ(Data!I1:I5,Data!H1:H5) | 0.75 | Blank and text-number pairs dropped |
=RSQ(Data!G1:G2,Data!F1:F2) | 1 | Two pairs |
=RSQ({2,4,5,4,5},Data!F1:F5) | 0.6 | Row vs column same count |
=RSQ(Data!G1:G5,Data!K1:K3) | #N/A | Different sizes |
=RSQ(Data!G1:G5,Data!J1:J5) | #DIV/0! | Constant x |
=RSQ(Data!C1:C5,Data!F1:F5) | #N/A | Range containing #N/A |
The Data sheet these formulas read
A cell that starts with = holds that formula.
C
F
G
H
I
J
K
1
1
1
2
1
2
3
1
2
2
2
4
4
3
2
3
=NA()
3
5
3
5
3
3
4
4
4
4
4
4
3
5
5
5
5
5
5
3
Data
Watch out for
- Arrays must be the same length.
- High R-squared does not mean the model is right.
Where it works
- Excel
- RSQ is in every version of Excel from 2007 on.
- Google Sheets
- Same name, same behaviour for everyday use.
Part of Statistical functions. Every result on this page was measured in desktop Excel, build 16.0.20527. Last updated .