Using LINEST to fit quadratics or higher-order polynomials to a series
Enter "=linest(" and follow the prompts, or choose LINEST from the Insert Function menu (in Statistical).
Choose the Ys.
Choose one or more X columns (one for linear, two for quadratic etc; you have to make X X^2 X^3 etc columns)
Enter true, true (or 1, 1).
Enter a ")" to finish the function and hit Enter.
Select the cell, then shift-select 5 rows and 2 (for one X) or more columns
Hit F2 then control-shift-enter, incredibly. Bill Gates strikes again.
The polynomial is Y = m0 + m1.X + m2.X^2 +…
You can also fit polynomials with the Analysis Toolpak:
select Tools/Addin-ins/Analysis Toolpak,then Tools/Data Analysis/Regression.
For the examples below, I have added some statistics
y x x2
4.0 1 1
9.0
7.5 2 4
8.0
8.0 3 9
7.0 f(x) = - 1.18x^2 + 6.42x - 1
5.0 4 16 R² = 0.95
2.0 5 25 6.0
5.0
4.0
y
Quadratic -1.18 6.42 -1.00 coeffs m2 m1 m0
3.0
0.20 1.23 1.61 SEs SEm2 SEm1 SEm0
2.0
0.954 0.75 #N/A Rsq SEE -
20.97 2 #N/A F Deg Free - 1.0
23.67 1.13 #N/A SSreg SSres - 0.0
1 1 2 2 3 3 4 4
adj Rsq 0.909 See note below about bias in correlations. x
Rsq 0.954 Rsq=SSreg/(SSreg+SSres)
Linear -0.65 7.25 coeffs m1 m0 9.0
0.83 2.75 SEs SEm1 SEm0
8.0
0.170 2.62 Rsq SEE
0.62 3 F Deg Free 7.0
4.23 20.58 SSreg SSres 6.0 f(x) = - 0.65x + 7.25
R² = 0.17
5.0
adj Rsq -0.11 4.0
y
Rsq 0.170
3.0
Pearson -0.413
2.0
Pearson^2 0.170
1.0
0.0
Here is an example with data across the page: 1 1 2 2 3 3 4 4
Data are peak power (W) at various percents on 1RM on a Smith machine x
% of 1RM X 20 30 40 50 60 70 m2 m1 m0
X^2 400 900 1600 2500 3600 4900 err m2 err m1 err m0
Rsq SEE -
Subject
Ariel 790 805 815 800 760 720 -0.08 6.21 698.93
0.01 0.75 15.40
0.99 5.03 #N/A
Gene 640 690 700 705 695 670 -0.08 7.80 520.64
0.01 0.89 18.19
0.96 5.94 #N/A
Note about bias in correlations
R-squared is biased high, because it is always positive, even when the population correlation is zero.
The adjustment to remove the bias is not exact, but it is near enough.
I know it's not exact, because I did simulations to check it out.
The formula is a rejigging of one I found in the SAS manuals. It amounts to "variance explained" rather than "sums of squ
This is such an obvious formula that I am obviously reinventing the wheel. I don't have a reference.
I like to take the square root of the R-squared and interpret its magnitude, but the resulting R is also biased.
And you have a bit of a problem if the adjusted R-squared is negative, because you can't take the square root of a negativ
The Pearson correlation (the R with a single predictor) is also biased, but for a different reason:
The Fisher z transform of the Pearson is not biased (and it has a normal sampling distribution), so the Pearson itself has
(If a statistic is not biased, a non-linear transform of the statistic has to be biased one way or another.)
The Pearson is actually biased low. The corrected correlation is r(1 + (1-r^2)/2n), where n is the sample size (Fisher, 1915
The bias is max for r=0.50 and negligible for n=10 (corrected r = 0.52).
Fisher, R.A. (1915). Frequency distribution of the values of the correlation coefficient in samples from an indefinitely larg
X^3 etc columns)
f(x) = - 1.18x^2 + 6.42x - 1.00
R² = 0.95
1 2 2 3 3 4 4 5 5 6
x
f(x) = - 0.65x + 7.25
R² = 0.17
840
820
1 2 2 3 3 4 4 5 5 8006= - 0.0848214286x^2 + 6.2053571429x + 698.9285714286
f(x)
780
x 760
740
720
700
680
Maximum 660
occurs at value is 10 20 30 40 50 60 70 80
36.6 812.4
720
700= - 0.08125x^2 + 7.7982142857x + 520.6428571429
f(x)
680
660
640
620
600
720
700= - 0.08125x^2 + 7.7982142857x + 520.6428571429
f(x)
48.0 707.8 680
660
640
620
600
10 20 30 40 50 60 70 80
ed" rather than "sums of squares explained".
also biased.
the square root of a negative number..
), so the Pearson itself has to be biased.
he sample size (Fisher, 1915).
ples from an indefinitely large population. Biometrika, 10, 507-521.