Seed Media Group

Deltoid

Sixth-degree polynomial fits, just say no

A local regression gives a much better idea of temperature trends than a high-degree polynomial fit.

Search

Search older postings


Profile

Tim Lambert Tim Lambert (deltoidblog AT gmail.com) is a computer scientist at the University of New South Wales.

Deltoid Facebook Group

Recent Posts

Recent Comments

Categories

Archives

Links

Blogroll

Archives of previous Deltoid

16th

Subscribe via Email

Stay abreast of your favorite bloggers' latest and greatest via e-mail, via a daily digest.

Sign me up!

« Open Thread 19 | Main

Sixth-degree polynomial fits, just say no

Category: Global Warming
Posted on: January 16, 2009 7:02 AM, by Tim Lambert

When discussing Jon Jenkin's use of a ridiculous sixth-degree poynomial fit to temperatures to argue that they were steeply trending down, I suggested that local regression (loess) was a much better method for showing trends. I was going to get around to plotting one, but Tamino has saved me the trouble by producing a loess smooth on GISS temperatures.

smooth.jpg

See Tamino's post for more graphs, including one showing how Dennis Avery misrepresented temperature trends even worse than Jenkins did.

Comments

#1

Oh man, I missed that the first time round... What possible excuse could there be for using a sixth-order poly, other than "I've been playing around in Excel and that gave me the trendline I wanted"?

Posted by: Dunc | January 16, 2009 7:46 AM

#2

Yep, that looks correct.

Posted by: Paul | January 16, 2009 7:54 AM

#3

i m still waiting for Jenkins showing a 3rd degree polynomial that bends downward at both ends. (he claimed the degree wouldn t matter...)

perhaps he ll show up to defend his claim, that all trendlines are equally right or false? as the IPCC future scenarios have the same predictive accuracy as his polynomial has for the future.... (ice age 15 years from now..

Posted by: sod | January 16, 2009 9:28 AM

#4

At first glance I read that as "Sith Degree" and was wondering which university offered it. I'd never heard of Polynomial University. It must be on the dark side of town...

Posted by: Ian | January 16, 2009 9:43 AM

#5

He used a sixth degree polynomial to fit data? I expect I could find high school students who could explain why that's probably a bad idea. Gah.

Posted by: Joshua Zelinsky | January 16, 2009 10:54 AM

#6

The truly frustrating thing is that Tamino has discussed lowess (and similar) smoothing on a number of occasions, and anyone with two scientific neurones and a synapse, who ventures into the blogosphere to discuss climatic (or any other type thereof!) time-series trendlines, should have at least a passing acquaintance with this eminently comprehensible work. It should certainly give any serious analyst pause for thought before reaching for the box of Polynomial Delights, and I still can't believe that he hasn't gagged on his 3rd-order comment, the one that sod keeps trying to draw his attention to.

Jenkins's preposterous notions on the initial thread continue to baffle me, and I would love to be a fly on the wall of his departmental tea-room if ever his colleagues discussed this amateurish fitting of a squiggle. I've seen similar discussions about analyses-gone-awry in my own institutions at various times, and I can imagine the professional irritation and embarrassment Jenkins might be causing his colleagues.

The interesting thing is that in just about every case the offending academic 'moved on' after not-so-many years. However, as an adjunct professor Jenkins might not be quite so prone to mobility, and I am sure that there are many institutions that would regard askance any future application of his, especially as Google is now the Interviewer's Friend...

There must be some peeved administrators at Bond.

Posted by: Bernard J. | January 16, 2009 11:12 AM

#7

including one showing how Dennis Avery misrepresented temperature trends

Did Avery do that or Andura Smetacek? Who IS Monsanto's new sock puppet these days, BTW?

But Zelinsky has an excellent point:

I expect I could find high school students who could explain why that's probably a bad idea

One can conclude that denialists have less than a high school education, or a highly-developed selection/conformation bias. This point narrows the choice considerably, methinks

Best,

D

Posted by: Dano | January 16, 2009 11:22 AM

#8

sod,

I believe one can get a third order polynomial to produce a curve that is downward at both ends by truncating the series between zero solutions of the derivative.

What that would mean for extrapolating from that function, though...

Posted by: luminous beauty | January 16, 2009 11:25 AM

#9

A high order polynomial could be a good method to model information, assuming you were only interested in appoximating the information "between" the known data points. It'd be horribly useless for any sort of prediction outside the "end" of the dataset.

Posted by: SpotWeld | January 16, 2009 4:09 PM

#10

They obviously should have used a 7th degree polynomial.

Posted by: ben | January 16, 2009 4:47 PM

#11

No, ben, that doesn't help.

Posted by: mz | January 16, 2009 6:27 PM

#12

It'd be horribly useless for any sort of prediction outside the "end" of the dataset.

Right, but so would just about any other trend that isn't model-based. How else would you make a prediction? Can a linear fit be used to project into the future? How far into the future? Will the temperature of the earth increase forever at the same linear rate?

Posted by: ben | January 16, 2009 6:38 PM

#13
A high order polynomial could be a good method to model information, assuming you were only interested in appoximating the information "between" the known data points.

Only if the data is completely noise-free. If you've got error, raising the order of the polynomial approximation will quickly cause it to become worse and worse...even between known points. You'll get weird and meaningless peaks and dips. By and large, the noisier the data set, the lower the degree at which this starts happening. (Basically this is because noise does really bad things to your estimates of the derivatives, and the derivatives usually have more influence on the higher-degree terms of the polynomial.)

Even if the data is noise-free, there are a lot of curves for which polynomial interpolation just doesn't converge. The absolute value function, for instance, and the function y=1/[1+x^2]. Again, raising the degree of the polynomial will make it a worse fit, not a better one. See Runge's Phenomenon for a nice illustrated example of this.

Posted by: Anton Mates | January 16, 2009 7:15 PM

#14

No Ben. The linear trend is useful because the data already shows significant linear trends. Any such derived trends get posted with lots of 'IF' statements. If you feel bold you might try an exponential, bearing in mind that the atmosphere is in no way exponentially heating. If you don't know maths or physics or you're trying to deceive ignorant people you can use a polynomial.

The linear fit is useful for extrapolation if and only if the linear trend continues. That's all it tells you and no more. I am sure that the long term trend is not linear, though in the short term (say 30 years) it may prove to be.

The obsession in denialist circles with every downward wiggle in this data is pure desperation. The recent use of polynomial fits takes this a step beyond. It's staggering to me that anyone with an education beyond first year maths would even consider such a thing.

Posted by: MarkG | January 16, 2009 7:39 PM

#15

MarkG

Know what you mean/getting at, but your terminology is likely the start of the slippery slope if not nipped. A linear fit is one using a polynomial of degree 1.

Posted by: P. Lewis | January 16, 2009 8:00 PM

#16

Indeed. I meant something more like "... The recent use of higher order polynomial fits..."

Posted by: MarkG | January 16, 2009 8:09 PM

#17

No, ben, that doesn't help.

Do you not recognize sarcasm?

The linear fit is useful for extrapolation if and only if the linear trend continues. That's all it tells you and no more.

That was my point.

If you've got error, raising the order of the polynomial approximation will quickly cause it to become worse and worse...even between known points.

That's not necessarily true. As long as the number of data points is significantly greater than the order of the polynomial then the fit match optimally for the assumption that the polynomial is a valid representation of the underlying dynamics.

And good grief, I'm just clowning around, I'm not defending the stupid fit used in the graph.

Posted by: ben | January 16, 2009 8:31 PM

#18
When discussing Jon Jenkin's use of a ridiculous sixth-degree poynomial fit to temperatures

I notice that Bond University doesn't have any degree program that has anything to do with atmospheric or basic physics. So they're likely to let him go on his merry way.

Posted by: Chris O'Neill | January 16, 2009 9:01 PM

#19
I notice that Bond University doesn't have any degree program that has anything to do with atmospheric or basic physics.

I should probably have said general physics instead of basic physics.

Posted by: Chris O'Neill | January 16, 2009 9:05 PM

#20

Anton says "Even if the data is noise-free, there are a lot of curves for which polynomial interpolation just doesn't converge"

Not sure what you mean there, but that doesn't seem quit right.

The Weierstrass approximation theorem states that $I$ is a closed interval and $f:I \to R$ is a continuous function then for any $\epsilon>0$ there is a polynomial $p$ such that $|p(x) -f(x)| < \epsilon$ for all $x \in I$.

Thus you can find a sequence of polynomials $(pn)$ with $(pn)$ converging to $f$ uniformly on $I$. I think the point is that there is no power series which converges to a function which isn't differentiable (or analytic). And of course you cannot make this work on an open interval (or the whole real line).

Also the degree of the polynomial tends to grow exponentially. For example to approx. the function |x| to within .001 you need a polynomial of degree very very very large. (I don't remember what the exact answer was, just that it was ridiculous)

Posted by: elspi | January 16, 2009 11:52 PM

#21

"I should probably have said general physics instead of basic physics." You should have said science,

BTW, where the hell do they get off calling THAT a university.

Posted by: elspi | January 16, 2009 11:58 PM

#22

Dunc gets it:Oh man, I missed that the first time round... What possible excuse could there be for using a sixth-order poly, other than "I've been playing around in Excel and that gave me the trendline I wanted"?

ben not:They obviously should have used a 7th degree polynomial.

Jenkins WAS using EXCEL. The polynomial trendline ONLY goes up to 6th order.

Pardon Eli, he has to go clean the carrot juice off the screen.

Posted by: Eli Rabett | January 17, 2009 12:42 AM

#23

What I "like" about this kind of denialist's models is their simplicity. what I've been wondering, what is the minimum number of linear equations to do a good fit to the temperature data? Like, insert the knowns, like the black-body T of earth, the atmospheric H2O, CO2, CH4, SO3 amounts (of N2O there is probably too short a record), ENSO data (there aren't probably long enough series on other oceanic variables), the solar cycle, albedo (from ice/snow data) and see if linear equations (though in reality they are not such) are enough to get a good fit (say... accuracy of 75%). This would mean at least 7 equations (assuming they do not affect each other, but only the surface temperature). Linear, non-interdependent equations are easier to get than the complex equations in the climate models that try to separate fe. the low, mid, and high troposphere. Assume yet a flat earth, so the calclulations could be done in cubes rather than in round grids (set a correction coefficient for the distortion). This sort of atmospheric model even I could try to do, and though I know it would be inaccurate, I'd know where the most outrageous inaccuracies are.

75% accuracy isn't much i admit (just assuming a rather large standard error on all variables). Though this sort of model would not predict anything, I think it'd help to understand the current climate models.

Posted by: jyyh | January 17, 2009 1:20 AM

#24

ben not:They obviously should have used a 7th degree polynomial. Jenkins WAS using EXCEL. The polynomial trendline ONLY goes up to 6th order.

Well then he should have done it twice to get 12th order.

Posted by: ben | January 17, 2009 3:10 AM

#25

jyyh--

You can get 76% accuracy (assuming by "accuracy" you mean "fraction of variance accounted for") with a simple linear fit between temperature anomaly and ln CO2 for 1880-2007. I did.

Posted by: Barton Paul Levenson | January 17, 2009 12:08 PM

#26

Ben:

If you've got error, raising the order of the polynomial approximation will quickly cause it to become worse and worse...even between known points.
That's not necessarily true. As long as the number of data points is significantly greater than the order of the polynomial then the fit match optimally for the assumption that the polynomial is a valid representation of the underlying dynamics.

Nope, not when noise is involved. Really, try it. Generate, say, a linear function. Add some noise in. Fit polynomials of increasing degree to the noisy data, and calculate the error between the polynomial approximation and the original curve. You will see that the high-degree polynomials are less accurate.

This is true even when the original curve is a polynomial (which of course a linear function is), and even when the number of points is much larger than the degree of the polynomial (I used 500 points and checked polynomials up to degree 20 in Octave just now.)

Noise and polynomial interpolation don't mix. And, as Ian said over on his Astroblog post on the subject, climate data is noisy as heck.

Posted by: Anton Mates | January 17, 2009 2:51 PM

#27

elspi,

Anton says "Even if the data is noise-free, there are a lot of curves for which polynomial interpolation just doesn't converge"

Not sure what you mean there, but that doesn't seem quit right.

The Weierstrass approximation theorem states that $I$ is a closed interval and $f:I \to R$ is a continuous function then for any $\epsilon>0$ there is a polynomial $p$ such that $|p(x) -f(x)| [is less than] \epsilon$ for all $x \in I$.

Thus you can find a sequence of polynomials $(pn)$ with $(pn)$ converging to $f$ uniformly on $I$.

You're quite correct that Weierstrass guarantees a convergent sequence of polynomials. The problem is that you are not guaranteed to get that sequence by interpolation on any particular table of nodes. Some node tables are more robust than others--Chebyshev is much better than equidistant nodes, of course--but for any given node table, there are continuous functions whose interpolating polynomials on those nodes will diverge.

Granted, any polynomial which approximates the original curve well is an interpolation of that curve on some set of nodes, but simply knowing that fact is not terribly helpful.

Posted by: Anton Mates | January 17, 2009 3:39 PM

#28

"Well then he should have done it twice to get 12th order. "

snorted out loud (i extrapolated this as a joke)

Posted by: z | January 17, 2009 3:44 PM

#29

could anyone direct me to a loess for dummies reference? preferably for sas users if that's an option? thanks

Posted by: z | January 17, 2009 3:50 PM

#30

z,

I don't know about dummies, but this one is for engineers:

http://www.itl.nist.gov/div898/handbook/pmd/section1/pmd144.htm

Hope that's close enough. It helped me.

Posted by: luminous beauty | January 17, 2009 4:23 PM

#31

z, I would suspect that the SAS online docs would offer a good starting point.

Posted by: sg | January 17, 2009 4:56 PM

#32

thanks sg, i'll give it a look. although i must say, i find that official sas publications never are a good starting point for anything....

Posted by: z | January 17, 2009 5:21 PM

#33

and thanks lumie, also (working my way upwards, here)

Posted by: z | January 17, 2009 5:24 PM

#34

I like the sas online docs. They're very thorough. Impossible to search and very badly laid out, and you have to know the procedure you're looking for to get anything out of them, but they're good when you finally get where you're going.

Posted by: sg | January 17, 2009 6:09 PM

#35

They are seriously phoning it in these days.

What's next, the Kabala?

Posted by: Marion Delgado | January 17, 2009 8:38 PM

#36

Sixth-degree polynomial fits, just say no

When I did polynomials, we were taught to just say O(n).

Posted by: Ezzthetic | January 17, 2009 10:03 PM

#37

Nope, not when noise is involved. Really, try it. Generate, say, a linear function. Add some noise in. Fit polynomials of increasing degree to the noisy data, and calculate the error between the polynomial approximation and the original curve. You will see that the high-degree polynomials are less accurate.

If the physics that produced the data match the polynomial you are using for the fit, then the fit will match the curve regardless of noise, provided that the number of data points is higher than the order of the polynomial.

Look, there is no closed form model for climate over time anyway, so any fit will be stupid, except for the linear fit. And that only shows the trend over whatever time period you pick for the fit. If you pick a long time period for the fit, then you will miss smaller time-scale changes, especially at the end points, and if you pick short time scales, then you will fit the short term variations, whoopee.

Posted by: ben | January 18, 2009 2:52 AM

#38

I am a public historian (labour and industrial history), though I did start out as a computer engineering major (many, many years ago). Maybe my old mind is just not retaining the math from my mispent youth, but can anyone, in layman's (historian's) terms tell me what a polynomial is? I think that I understand that attempting to smooth a curve using non-data from outside the curve leads to some weird effects, but beyond that? Historian. If someone could either explain (in simple terms) or point me to a site that has that information, I would be greatly appreciative.

Posted by: (((Billy))) | January 18, 2009 8:32 AM

#39

I think Jenkins could "prove" his point using lowess if he adjusted his parameters to narrow the window of weighting (essentially using just 2 or 3 adjacent points, meaning just reproducing the graph). W.S. Cleveland had a good explanation for non-specialists of the procedure in his 1985 book "The Elements of Graphing Data."

Posted by: mark | January 18, 2009 9:30 AM

#40

Billy

For a pretty good summary, our favourite know-it-all has something to say.

Posted by: Bernard J. | January 18, 2009 10:21 AM

#41

Ezzthetic:

teh funneh.

Best,

D

Posted by: Dano | January 18, 2009 12:34 PM

#42
If the physics that produced the data match the polynomial you are using for the fit, then the fit will match the curve regardless of noise, provided that the number of data points is higher than the order of the polynomial.

This simply isn't true, Ben; noise makes polynomial fits lose accuracy as their order increases. Again, I just ran through a few examples myself in Octave. You can too; it's a free program. I can tell you the (very short) code for an example if you'd like.

But if you don't believe me, then, again, look at Ian Musgrave's article. Look at the first picture. The original data is from a 1st-degree polynomial, plus noise; he gives its formula later on in the comments. The black curve is the linear fit--that is, a polynomial fit of degree 1. The green curve is a polynomial fit of degree 6. Which curve recovers the original line more accurately? It's really not hard to see that the linear fit is better.

Look, there is no closed form model for climate over time anyway, so any fit will be stupid, except for the linear fit.

That hardly follows. You don't need to fit a data series with exactly the same sort of function you believe produced the original data. Most sound waves are not in fact a finite sum of sinusoids, but that doesn't mean you can't usefully represent them with a finite Fourier series. Most population curves are not in fact exponential or logistic, but those functions can still represent them reasonably well (under the right conditions, anyway.)

A good curve-fitting technique just has to be capable of producing curves roughly like those you expect to see in the data, and it needs to be robust against noise. High-order polynomials meet the first criterion but not the second. Linear fits aren't as good on the first criterion but are way way better on the second. Local regression, as Tamino's graph shows, does quite well on both criteria.

Posted by: Anton Mates | January 18, 2009 8:05 PM

#43

The difference here seems to be that Mr. Jenkins et al. "want" a trend line to go in a very specific direction. But the goal of analysis is to reveal trend - noise as to discover what a trend line might be.

This is like spending all of your money as fast as you can because you've noticed your paycheck usually arrives when your bank account is at its lowest.

Posted by: Douglas Watts | January 19, 2009 2:24 AM

#44

This simply isn't true, Ben; noise makes polynomial fits lose accuracy as their order increases.

Sorry, I worded that incorrectly. For a given set of data, least squares will find the "optimal" fit to the data. Yes, as the noise increases the fit will become worse. Here's my example using Matlab:

% arbitrary coefficients a0 = 0.1; a1 = 0.2; a2 = 0.35; a3 = -0.2; a4 = -0.035; a5 = 0.001;

% the exact data for the model t = 0:0.01:10; x = a5t.^5 + a4t.^4 + a3t.^3 + a2t.^2 + a1.*t + a0;

% add noise for i = 1:max(size(t)) xn(i) = x(i) + 1e2*randn(1); end

figure(1); clf(1); plot(t,x) hold on plot(t,xn,'rx') hold off

And the resulting plots of data, noisy data, and the resulting fit, for a fifth order polynomial.

http://img.photobucket.com/albums/v665/hautlipz/noisyn5with_linear.jpg

Yes, the polynomial fit would get worse as the variance of the noise increased, to the point eventually where the polynomial fit would be useless. The linear fit would still show some sort of overall trend. This is all moot anyway, as there is no reason to expect that global temperatures would follow any sort of polynomial model over time. That is not, and never was my point. You guys don't seem to understand a joke. Argh!

The best you could do would be to have a proper model of the system dynamics and then you could estimate and/or smooth the data.

Posted by: ben | January 19, 2009 2:46 AM

#45

That link seems to be bad. Here's the right one:

http://img.photobucket.com/albums/v665/hautlipz/noisyn5with_linear.jpg

Posted by: ben | January 19, 2009 2:48 AM

#46

Dang, just go here

Posted by: ben | January 19, 2009 2:50 AM

Post a Comment

(Email is required for authentication purposes only. Comments are moderated for spam, your comment may not appear immediately. Thanks for waiting. Personal attacks on other commenters and other attempts to disrupt discussion will be disemvowelled.)





Having problems commenting? (UPDATED)

Blogs in the Network

Advertisement

Top Five: Most German

Search All Blogs

Science News From:

Science News from NYTimes.com