LOESS Utility – Awesome Update
by Jon Peltier
Thursday, October 8th, 2009
Peltier Technical Services, Inc., Copyright © 2012.
Licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
I talked about LOESS smoothing in LOESS Smoothing in Excel, where I showed my improved VBA function for calculating smoothed data. I introduced an improved LOESS Smoothing utility in LOESS Utility for Excel. Since I use the utility frequently, I encountered many things about it that I wanted to change. Since I am the developer of the utility, I have actually been able to make these changes. And after a few months of use and a few hour-long sessions aimed at making it do what I want it to do, I’ve developed this utility into something that is, in the local vernacular, “wicked awesome”. If you’ve never seen “Good Will Hunting”, that means “way cool”.
What makes this utility so great, you ask? The calculations were already perfectly adequate, and I didn’t change them at all. But I’ll show the new dialog, so you can see what has changed.

First, the previous interface for selecting input and output ranges was frustratingly restrictive. So I made the range selection function much more flexible. The colorful buttons on the left indicate the built-in options. In the most elementary case, all four entries (X input, Y input, X output, and Y output) are separate ranges, which can even be located on separate worksheets.

The options make range selection easier if some columns happen to be adjacent to each other, or if the same X values are to be used for both input and output. The range selection (Ref Edit) boxes and related labels update according to which option has been selected.
When the X input range has been selected, the program determines Npts, the number of points that should be used for the selected value of alpha. When the user changes alpha or Npts, the other parameter updates.
In the following case, one column serves as X input and X output (A7:A135), the adjacent column holds the Y input data (B7:B135), and the program will dump the Y output into a separate column (D7:D135).

Even this wasn’t smooth enough for me, because I got tired of scrolling up and down to select long ranges. So I made another improvement. I made the program smart enough to know that if only one row had been selected, it should use the range of data below the selected row, stopping at the first empty cell.

Couldn’t be easier.
The last change I made was to have the utility store the last LOESS parameters in each worksheet. This way, if I run a particular analysis on each sheet in a workbook, I only have to activate that sheet, run the program, and the dialog is pre-populated with the settings I need. What a time-saver!
PTS LOESS Utility Demo
Here is a demo of the new utility. This analysis only took a few minutes. I started with some Global Temperature Anomaly data from NASA.

I ran the utility to generate a smoothed temperature anomaly curve.

Then ran the utility a few more times to see the effect of alpha (number of points in the moving linear regression) on the shape of the smoothed curve. The values of 42, 25, and 12 points correspond to alpha values of 0.33, 0.2, and 0.1.

The fewer points (i.e., smaller alpha) in an analysis, the more that the smoothed curve follows local variations in the data.
Download and Install the Utility
Click this PTS LOESS Smoothing Utility link to download the utility. The download is a simple Excel add-in. Save it to any convenient directory, then install it following the instructions in Installing an Excel Add-In or Installing an Add-In in Excel 2007.
References
Cleveland, W.S. (1979), “Robust Locally Weighted Regression and Smoothing Scatterplots,” Journal of the American Statistical Association, Vol. 74, pp. 829-836.
Cleveland, W.S. and Devlin, S.J. (1988), “Locally Weighted Regression: An Approach to Regression Analysis by Local Fitting,” Journal of the American Statistical Association, Vol. 83, pp. 596-610.
NIST Engineering Statistics Handbook, 4.1.4.4. LOESS (aka LOWESS)
NIST Engineering Statistics Handbook, Example of LOESS Computations
Wikipedia, Local regression
Related Posts:
- LOESS Utility for Excel
- LOESS Smoothing in Excel
- LOESS Utility – What the Buttons Mean
- Deming Regression Utility
- Deming Regression
- Data Smoothing Perils (Series Lines Follow-Up)
Posted: Thursday, October 8th, 2009 under Utilities.
Comments: 70
Comments
Comment from Bob
Time: Thursday, October 8, 2009, 12:20 pm
Way to go Jon.
Can’t wait to play with this.
Cheers,
Bob
Comment from Jerry Betz
Time: Thursday, October 8, 2009, 1:52 pm
Jon,
Ayuh, wicked gorgeous. Many thanks.
Jerry
Comment from Kurt
Time: Thursday, October 8, 2009, 3:00 pm
Hi Jon,
tried your LOESS-Tool, it installs a Menu
“PTS Charts” in my Excel 2003. clicking this
menu I have *two* indentical menu-entries
“LOESS”
Do you have any hint, what mistake I made?
thanks
Kurt
Comment from Jon Peltier
Time: Thursday, October 8, 2009, 4:18 pm
Kurt -
I don’t know why that happened. Before you quit Excel next time, go to View menu > Toolbars > Customize, then you can click on the PTS Charts menu and drag it off the menu bar to delete it. When you restart Excel, there should then be only one LOESS item.
Comment from Bob
Time: Thursday, October 8, 2009, 5:24 pm
Hi Jon,
The same thing happened to me in Office 2007 SP2 and all the patches.
Works fine. I also have the error bar utility you cooked up for Excel 2007. Happy camper.
Thanks for your hard work.
Cheers,
Bob
Comment from Jon Peltier
Time: Thursday, October 8, 2009, 8:03 pm
I’ll have to check that when I get a chance. At least the underlying utility works. At least for N > 4, that is, because one early tester found problems with very small N.
Comment from Kurt
Time: Friday, October 9, 2009, 12:27 pm
Jon,
the sugested procedure did not work for me.anyway it is just a “cosmetic” thing.
thanks for making this tool available for free
Kurt
Comment from Jon Peltier
Time: Friday, October 9, 2009, 2:23 pm
Kurt – I’ll dig into the code, see what might be messing up the interface.
Comment from Stephen Hughes
Time: Monday, October 12, 2009, 8:40 am
Is there a minimum version of Excel needed to run this? I’ve got 97 but get a ‘Compile Error in Hidden Module: M_LOESS’ error when I try to run it.
Any suggestions would be appreciated as I need a program to smooth out experimental data.
Comment from Jon Peltier
Time: Monday, October 12, 2009, 10:26 am
Stephen -
There was a major upgrade of VBA between Excel 97 and Excel 2000, and Macs have never gotten this upgrade. I would expect all of my code to work fine in Excel 2000 and later, but I would expect problems in Excel 97 and Mac Excel.
I don’t know if I even still have Excel 97 disks. If I do, maybe I’ll install it in a VM and see where the code falls down.
Comment from Stephen Hughes
Time: Monday, October 12, 2009, 10:33 am
Hi Jon,
Anything you can manage would be appreciated! Meanwhile I’ll try (again) to persuade my boss of the benefits of having a modern computer and up-to-date software!
Comment from Jon Peltier
Time: Monday, October 12, 2009, 10:43 am
The bare minimum is Excel 2000, but I’m sure that would be nearly impossible to find. The best version so far is Excel 2003, and even that isn’t easy to get your hands on.
Comment from Omair Noor
Time: Thursday, December 17, 2009, 8:14 pm
Hi Jon,
I have approximately 2400 data points per column. I tried to use your LOESS utility function, but i get the following error:
Run-time error ’6′:
Overflow.
Any idea how should i be going about resolving this problem.
Thanking in anticipation.
Comment from Jon Peltier
Time: Thursday, December 17, 2009, 9:23 pm
Hi Omair -
I just did some fooling around, and had no problem with a data set with 5000 points. But I used some vanilla data, and yours may have some characteristic that makes it behave differently.
Is it possible to send me a sample? jonpeltier at-sign gmail period com.
Comment from tom
Time: Friday, January 29, 2010, 6:24 pm
I also experienced the runtime error.
Does it have to do with very small alpha values? I chose 20 points out of 2000.
bug #2:
The utility crashes from the menu if Excel is opened without any workbook.
bug #3:
Sometimes the dialog disappears when I am entering ranges in the text boxes.
idea:
Could you add something like a auto-fit for columns in the tool. I rather would like
to add full columns. The utility could start the range below the last text row and
would end the range before the first empty cell.
Comment from Jon Peltier
Time: Saturday, January 30, 2010, 10:36 am
Tom -
I don’t know what may have caused your first error. When it was reported last time, the problem was resolved by selecting just the data, not the entire column. I have added a slightly different dange auto-detect feature. Select the top cell in a range of data (the first data cell, not the header), and the utility will detect how far down the column the range extends.
I also don’t know about the second crash. Similar problems arise if not all upgrades and service packs have been installed.
How frequently does the dialog vanish? I see it once in a while, perhaps once every few dozen times I run the utility. I’ve just assumed it was related to the inherent instability of the RefEdit used to select the data ranges.
Comment from Nick
Time: Sunday, January 31, 2010, 8:22 pm
Hi Jon!
Nice little utility you have here! I’m utterly hopeless at math and I have a report involving normalizing microarray data, which requires me to apply LOESS to some data. I have trouble following your example of plotting LOESS for anomaly data for NASA. There are seven choices for entering the data and I don’t know which to choose! If you give a step by step instruction of how you used the add in, it would be great.
Please help the mathematically crippled biologist!
Comment from Jon Peltier
Time: Sunday, January 31, 2010, 10:41 pm
Nick – I’m preparing some documentation for a new article. Stay tuned.
Comment from K Hayhoe
Time: Thursday, April 15, 2010, 12:50 pm
any chance of a Mac versions for this and all your other great add-ins, pleeease?
Comment from Jon Peltier
Time: Thursday, April 15, 2010, 10:54 pm
Katharine -
The problem is that the version of Visual Basic in Mac Excel is a generation older than that in Windows Excel. There are some incompatibilities in the code because of this, and I have no means to test the older code.
Comment from david
Time: Wednesday, June 9, 2010, 11:37 am
Hi John,
I’m also attempting to run your loess app on some microarray data. I’m not certain if it’s working properly or not. My data consists of ~385k values (I can break into subsets of 2 30k and 2 150k).
I’m using the “3 adjacent column” button. When I hit it, the task manager says Excel is not responding. I’ve experienced this before with large data sets (this one is a smaller one for me), analysis and Excel. So I walk away — after a 1/2 hour it’s still not responding — with either the 30k, 150k or the 380k.
Should I wait longer??
Thanks
Excel 2007
Windows XP, x64 SP2
Dell Precision T5500, 2.27ghz, 24g RAM
Comment from Jon Peltier
Time: Wednesday, June 9, 2010, 5:44 pm
David -
That’s a lot of points. Is LOESS the right way to smooth your data set?
To get a handle on how long the analysis should take (on my computer) I started with some dummy data, and ran a series of LOESS analyses on it. I tested 10 to 10,000 points, with alpha=0.5. Times to calculate the LOESS fit are shown in this table. Each time shown is the average of six runs, except the time for 10,000 points is the average of three runs.

The slope of the right side of the curve is close to 2, which jibes with my faint recollection that the time to compute a regression is proportional to the number of points squared, and the LOESS fit is basically a set of regressions. If I extrapolate to 30k, 150k, and 380k points, I predict times of 31 minutes, 13 hours, and 86 hours.

Comment from DD
Time: Wednesday, June 23, 2010, 1:27 pm
Can’t get this to work at all in Excel 2007.
Steps to reproduce:
1. Go to Add-Ins and select “PTS Charts => LOESS”
2. Choose the button in the lower right (four columns)
3. Select 270 values for X
4. Select 270 next to it for Y
5. Do the same for output (other columns)
6. Type “0.25″ in the alpha box (Number of points updates to 67)
7. Press OK
Result is X output empty and Y output containing the same value repeated 270 times.
I can pick any data, and this is always the result.
Comment from Jon Peltier
Time: Wednesday, June 23, 2010, 2:24 pm
DD -
Does the X output range contain values? It should either contain values (e.g., if you want to specify different points than are in the X input range, or you should use an option that uses the X input range for input and output.
Comment from david
Time: Tuesday, June 29, 2010, 4:46 pm
Hi John,
Thanks for your excellent reply, and please accept my apology for my delayed response.
Yes, it’s many data points, but it’s actually a small data set for us (thus the use of Excel). I’ve some data sets that contain ~3 million data points, and yes a standard first pass is to do LOESS.
It would be nice to have a LOESS function in Excel — it’s more familiar and comfortable to some folks around here — rather than R. That’s why we were excited to come upon your solution. We do have some other ~20-30K datasets (and the above that I mentioned), but trusting Excel and XP to 30 minutes (or longer) of stable computing does seem to be living to close to edge for me!
Thanks for your excellent and informative blog.
David
Comment from Jon Peltier
Time: Tuesday, June 29, 2010, 7:56 pm
David -
Even though there are 385k input data points, you could output LOESS values for many fewer points, even just a thousand. This should cut down on most of the calculations.
Comment from DanF
Time: Saturday, July 10, 2010, 5:42 pm
I particularly like the remember last use feature.
However, after a half day of LOESSing all over the place, I can’t get the utility to work any longer. When I click the x input range, I get the normal selection box. When I try to put a y range in or click any of the input buttons or text boxes, it goes poof and the LOESS window closes. When I close Excel (thinking that a good old fashioned close it-open it sequence is the cure-all for just about anything), I get the password requests. I read your REF CTL commentary, but I didn’t see what I might have done to cause LOESS to go on strike.
Comment from Jon Peltier
Time: Sunday, July 11, 2010, 8:17 am
Dan -
I have not yet changed the LOESS utility to use textbox/inputbox instead of the flaky RefEdit. When it works, the RefEdit is nice, but when it doesn’t work, it is horrible.
Comment from Thomas Rand-Nash
Time: Thursday, July 22, 2010, 11:40 am
First and foremost, THANK YOU!! This is coming in incredibly handy for smoothing out an unruly data horde! My question has to do with an “PTS_LOESS Password” box which opened after I quit excel. Is there a password I should know?
Thanks
Comment from Jon Peltier
Time: Thursday, July 22, 2010, 1:13 pm
Thomas -
There’s no password you should know. Make sure you’ve installed all service packs and updates for the version of Office you’re running. If that doesn’t help, there’s some Registry diving that might help.
Comment from Nate
Time: Tuesday, August 3, 2010, 12:52 pm
Jon, I’m looking forward to trying this tool, but after installing it, I get the following error message when opening Excel 2007: “object library invalid or contains references to object definitions that could not be found”
Any ideas on what might cause that?
Comment from Nate
Time: Wednesday, August 4, 2010, 7:48 am
Jon, regarding my comment on the missing object library: I determined that this was being caused by a corrupted installation and not your add-in. I reinstalled E2007 and have it working now.
Comment from Jon Peltier
Time: Wednesday, August 4, 2010, 10:35 am
Nate -
Thanks for following up and reporting the fix. The error is more than likely due to the RefEdit issues I’ve discussed (Using RefEdit Controls in Excel Dialogs) and finally programmed away (Alternative to Excel’s Flaky RefEdit Control) in my commercial add-ins, but not the simple ones available with my blog posts.
Comment from Ann D
Time: Wednesday, September 8, 2010, 1:53 pm
I’m trying to load the Loess add-in, but when I click on “Click this PTS LOESS Smoothing Utility link to download the utility” I just get a bunch of garbely gook. Is the link still active?
Thanks.
Ann
Comment from Jon Peltier
Time: Wednesday, September 8, 2010, 5:26 pm
Hi Ann -
Weird. That just happened to me as well. Instead, right click on the link, and use Save As to save the file.
Comment from Ann D
Time: Friday, September 10, 2010, 12:40 pm
Thank you, John. Yes, that worked. Very cool utility and SO much friendlier than R.
Thank you for sharing it.
Ann
Comment from Lewis Mc
Time: Friday, November 5, 2010, 12:32 pm
I’ve been smoothing data by other tedious means for almost a year. Thank you for your help :)
Comment from Elizabeth Arias
Time: Monday, November 8, 2010, 1:43 pm
Just wanted to say thanks. I usually work in Stata, but am stuck working at home and needed to do some data smoothing. All I had access to was Excel…and there you were after a little searching. I downloaded the version for Excel 2007 and works “wicked awesome”!!!
Comment from DaleW
Time: Friday, November 19, 2010, 10:08 pm
Jon, great utility.
I would note that it still behaves oddly for me for really small N. For example, with that NIST data, try pushing it to N=3 resolution, and give it lots of resolution for output. (I know, it’s just *wrong* to use LOESS for linear interpolation.) But wait, why is it linearly interpolating, if jaggedly, when N=3? Linear interpolation implies N=2, right?
Comment from Jon Peltier
Time: Saturday, November 20, 2010, 8:42 am
Dale -
I notice the algorithm does something with the N values. Sometimes I’ll do a 3-month smoothing, and enter N=90. Depending on the total sample size and how alpha is rounded, the algorithm might actually use 89 or 91 instead of 90. This may be taking your N=3 and instead using N=2. Next time you run the routine, it shows the actual N used last time in the dialog.
I’ve been meaning to look at the code and try to enforce N instead of alpha, which makes more sense to me.
Comment from DaleW
Time: Saturday, November 20, 2010, 4:30 pm
Jon, I noticed your algorithm sometimes tweaks N. However, for my example it kept reporting back N=3 while clearly doing a sort of linear interpolation for N=2 points locally instead of LSQ with N=3 locally.
BTW, I like how Minitab handles excessively low alpha in its LOWESS implementation. It falls back to pure linear interpolation, meaning it uses the nearest point in each direction if at all possible (instead of true nearest two points as LOESS perhaps should, and your code actually does when reported N=3).
Comment from Rogan
Time: Sunday, January 16, 2011, 6:18 am
Hi Jon,
Nice program, thanks for making it available. But …
It worked fine for the first few times; then I stopped to do something else, and then when I came back, the box always disappears when I try to do anything on it. Not just about once every 10 or 12 times, but always. Can’t get it to work at all. Even just accepting the data there and clicking OK does nothing. I’ve read your pages about RefEdit and tried everything there, without success. Only thing remaining is to throw the computer out the window.
Note that I also get Loess twice on the menu, and can’t fix this – not that it really matters.
You mentioned that you might replace RefEdit with text boxes or input boxes: have you made any progress here?
Thanks,
Rogan.
Comment from Jon Peltier
Time: Sunday, January 16, 2011, 8:40 am
Rogan -
Bizzarre. I wonder what may have gone awry. That utility still uses RefEdits, but this sounds like a different (or additional) problem.
Try this: Go to Tools > Add-Ins (or the Excel 2007 equivalent) and uncheck the box in front of the LOESS entry (or entries). Then restart Excel, go back to the Add-Ins dialog, and recheck (or browse to) the LOESS utility.
Comment from Rogan
Time: Sunday, January 16, 2011, 3:22 pm
Hi Jon,
Thanks for your quick reply.
I had tried your suggestion, and did it again, just in case. Same result. (I should warn you that I am jinxed when it comes to electronics and computers. I don’t really believe in it myself, but, when I get close to any device, if anything can go wrong, it will. If a program can blow up, it will. I once wrote to Bill Gates about this (when I thought his software was at fault) and got a refund of my purchase price. But enough of that – it is my problem).
Sorry, I should have told you I am using Excel 2002. (I find 2007 excruciatingly slow; and 2010 just blows up on my machine, due to influences mentioned above). But I also tried all suggested remedies on Excel 2007, with the same result.
This is all a bit of a drag, because I cannot use your amazing interface; but I have taken your VBA code for the calculations, and got it working. Thanks.
I am now looking at allowing a 2nd order fit (as suggested by TV and others. Your response – some very nice pseudo-code plus the warning “You’ll have to figure out what to do with the weights” – was a good model. Just include the weights in each of the sums. EXCEPT: the algorithm assumes that the sum of the weights is 1; and when this is not so, it may change subtly).
Anyway, I’ll have it sussed within a day or two, and will post here the code to add to yours to allow the 2nd order as an option.
Rogan.
Comment from Rogan
Time: Tuesday, January 18, 2011, 2:04 am
Hi Jon,
I wanted to do the 2nd order by using the worksheet function Minverse to solve the three simultaneous equations. But Minverse requires a range input, and this must be a range on a worksheet, and you cannot change anything on a worksheet from a UDF. (If any of this is wrong, or there are any tricks to work around it, I would love to hear.) Of course, it can be done by a sub, and maybe your interface calls a sub.
But, for the moment, I had to resort to an explicit solution. The code follows:
1. Replace the function declaration with:
‘ New function declaration to allow for 2nd degree
Public Function LOESS(x As Variant, y As Variant, xDomain As Variant, nPts As Long, Degree As Integer) As Double()
2. Add the following variable declarations:
‘ Variables for 2nd degree
Dim SumWtX3 As Double, SumWtX4 As Double, SumWtX2Y As Double
Dim R1 As Double, R2 As Double, R3 As Double, R4 As Double, R5 As Double, R6 As Double, R7 As Double, R8 As Double
3. Put the following code just before the comment “do the sums of squares”:
‘ Test for linear (Degree=1) or 2nd degree
If Degree = 1 Then
4. Add the following code between and the statement yLoess(iPoint, 1) = … and the final Next:
‘ 2nd degree polynomial: Degree is anything but 1
Else
SumWts = 0
SumWtX = 0
SumWtX2 = 0
SumWtX3 = 0
SumWtX4 = 0
SumWtY = 0
SumWtXY = 0
SumWtX2Y = 0
For i = iMin To iMax
SumWts = SumWts + weight(i) ‘S0
SumWtX = SumWtX + x(i, 1) * weight(i) ‘S1
SumWtX2 = SumWtX2 + (x(i, 1) ^ 2) * weight(i) ‘S2
SumWtX3 = SumWtX3 + (x(i, 1) ^ 3) * weight(i) ‘S3
SumWtX4 = SumWtX4 + (x(i, 1) ^ 4) * weight(i) ‘S4
SumWtY = SumWtY + y(i, 1) * weight(i) ‘T0
SumWtXY = SumWtXY + x(i, 1) * y(i, 1) * weight(i) ‘T1
SumWtX2Y = SumWtX2Y + x(i, 1) ^ 2 * y(i, 1) * weight(i) ‘T2
Next
‘ Combine S & T variables
R1 = SumWtX2Y * SumWtX2 – SumWtY * SumWtX4 ‘T2S2-T0S4
R2 = SumWtX2 * SumWtX4 – SumWtX3 ^ 2 ‘S2S4-S3^2
R3 = SumWtX * SumWtX4 – SumWtX2 * SumWtX3 ‘S1S4-S2S3
R4 = SumWtX2Y * SumWtX3 – SumWtXY * SumWtX4 ‘T2S3-T1S4
R5 = SumWts * SumWtX4 – SumWtX2 ^ 2 ‘S0S4-S2^2
R6 = SumWtX2Y * SumWtX – SumWtY * SumWtX3 ‘T2S1-T0S3
R7 = SumWtX * SumWtX2 – SumWts * SumWtX3 ‘S1S2-S0S3
R8 = SumWts * SumWtX2Y – SumWtY * SumWtX2 ‘S0T2-T0S2
‘ Can now calculate directly
yLoess(iPoint, 1) = ((R3 * R6 + R4 * R7 – R2 * R8) * xNow ^ 2 + (R4 * R5 – R1 * R3) * xNow + R1 * R2 – R3 * R4) / (R3 ^ 2 – R2 * R5)
End If
The second degree fit is better at the ends (where the 1st degree tends to be linear) and is more faithful to the peaks and troughs, as you would expect. (By the same token, it will also be more sensitive to outliers).
Now I’m going to try and write a dll for the 3rd and higher degrees (despite the comment I saw somewhere that this is against the original spirit of Loess. It will be interesting to see the results). But that will be in my favourite language, Fortran.
Hope this is useful,
Rogan.
Comment from Blake
Time: Wednesday, February 16, 2011, 11:16 am
Jon,
I was curious if there is a way I can call this in VBA? I want to run a batch process on about 50 sets of data, and want to do the basic 3 Column: Shared X input and X output, Y input, Y output. I tried using your VBA code you posted, but it runs real, real slow for some reason, and isn’t giving the same results. Thanks!
Blake
Comment from Jon Peltier
Time: Wednesday, February 16, 2011, 3:14 pm
Blake -
I have not built an API for this add-in, so it cannot be called from another procedure.
Comment from andres
Time: Monday, March 21, 2011, 2:06 pm
hi Jon,
thanks so much for your work!
unfortunately, when I accessed the url where the download link is referred to (http://peltiertech.com/images/2009-10/PTS_LOESS.xla), but i get into a page with weird codes and symbols, and there is no obvious direction where to go to download the add-in
any suggestions where else can i access to the add-in from?
many thanks!
andres
Comment from Jon Peltier
Time: Monday, March 21, 2011, 2:40 pm
Andres -
I just tested the link, and it downloaded an add-in, that is, an Excel xla file. Right click on the link and do a Save As, so your browser doesn’t try to read the add-in.
Comment from andres
Time: Monday, March 21, 2011, 2:58 pm
thanks Jon!
andres
Comment from Dave Rents
Time: Monday, May 23, 2011, 4:48 pm
Jon, Thanks for this fantastic tool. Very easy to use. I was wondering if you have/or have plans to build in an interpolation function? I was hoping to use something of this nature for not only smoothing but future forecasting.
Thanks again
Dave
Comment from J Hey
Time: Friday, July 15, 2011, 10:53 am
Very useful utility.
However I am having a problem that seems similar to what a couple others found.
If I use the addin extensively in a particular sheet, and I save the file and then come back later, when I open the addin again it will have values in the form. If I click in any of the form windows, or click on a different model, the applet closes down. The only form window I can alter is for ‘shared Xinput and X output’. In effect there is no way to use the utility in that worksheet again. uninstalling the addin and reinstalling does not help. Only if I copy all the data to a new sheet, then can I use the applet on it.
thanks
J. Hey
Comment from Claire
Time: Thursday, September 22, 2011, 3:17 am
Hi Jon,
Does this work with Office 2010?
Thanks,
Claire
Comment from Jon Peltier
Time: Friday, September 23, 2011, 3:58 pm
Claire -
Yes. this program works in Excel 2010 (and 2007, 2003,…)
Comment from Claire
Time: Sunday, September 25, 2011, 2:20 am
Thanks Jon.
Looks like a great utility. I have it in my addin panel in the options window of excel but still nothing shows up in the add-ins pane of the ribbon (unlike other add-ins I have installed). I wondered if this was a compatibility issue but from your reply I guess not. I’ll keep trying.
Thanks,
Claire
Comment from Jon Peltier
Time: Sunday, September 25, 2011, 11:13 am
Claire -
If you’ve installed the add-in correctly, you should see on the Add-Ins tab, a button entitled PTS Charts. Click on this, and it will drop down to show LOESS (and any of a handful of other PTS Charts add-ins available from this blog).
Comment from Claire
Time: Sunday, September 25, 2011, 11:28 am
Thanks. Works fine on home computer – maybe a anti-virus problem or something at work.
Comment from K. A.
Time: Saturday, October 8, 2011, 3:39 am
Thank you Jon for this wonderful utility.
I am a new bee here and sorry for the dumb question.
My X and Y sets of data are as follows. For X =55 the corresponding value Y is unknown. Could someone kindly explain to me ,how I could predict the Y value for X= 55 and all corresponding Youtput values for each Xinput values using this utility? Which buttons to use is not clear to me due to my limited knowledge. Can I predict the Youtput value for X=55 this way? Thank you so much answering.
KA.
X Y
0 466
1 441
2 440
3 449
4 417
5 430
6 447
7 451
8 487
9 417
10 392
11 399
12 408
13 388
14 396
15 389
16 403
17 414
18 412
19 414
20 419
21 454
22 448
23 444
24 444
25 460
26 478
27 476
28 461
29 491
30 479
31 478
32 473
33 475
34 460
35 463
36 463
37 422
38 441
39 378
40 361
41 362
42 385
43 388
44 381
45 367
46 383
47 389
48 386
49 400
50 411
51 422
52 433
53 421
54 429
55 ?
Comment from Jon Peltier
Time: Tuesday, October 11, 2011, 6:50 am
K.A. -
First I plotted your data, then I ran the LOESS utility, using the top left button and an arbitrary 15 points in the analysis, to get a column of fitted values adjacent to the data values.
Then I put the desired X value into a cell, and reran the utility, again with 15 points. This time I used the first button in the second row, using the two columns of data in the first range selection box, and the two column range starting with the cell containing the desired X value. The fitted Y value appears next to this X value.
It looks like this:

Comment from K.A.
Time: Wednesday, October 12, 2011, 4:21 am
Thank you so much Jon. I will try to get my head around it :).
Comment from Mehdi
Time: Sunday, January 1, 2012, 4:28 pm
Hi Jon
Fantastic Job;
I was looking for something like this for ages and i got so excited when i saw your examples undertaken by LOESS, however, it didnt work for my data. Maybe i’m doing something wrong during introducing X,Y. I’ll be grateful if yo can look at my data.
How can i send you my file?
Comment from Jon Peltier
Time: Monday, January 2, 2012, 6:29 pm
Mehdi -
The program works okay on your data, but there are a couple important features in your data.
1. Your data should be sorted in order of increasing X values.
2. Your data seems to show two regions. There is a steep increase from 0 to to mid-50s, followed by a gradual increase from mid-50s to upper-60s.
There are only about 50 points in the initial steep region. Using the default setting of 0.3 for alpha means each output point uses 300 input points for the calculations, so the LOESS calculations don’t show much of the initial region. In fact, even using N=50 doesn’t show the full drop to zero at the start of the data.
You may want to investigate spline fitting for your data.
Comment from Bram
Time: Friday, January 20, 2012, 4:32 pm
Hi Jon,
Thank you for this very useful tool. I have used it succesfully to study time trends of various pollutants. However, for one pollutant I always get the error Runtime error 13: Type mismatch. I could not identify any difference with the other datasets that ran fine. Any thoughts?
Here’s the data:
2/13/2001 140
2/26/2001 129
3/5/2001 80
11/13/2001 23
3/8/2002 3
11/9/2002 138
12/18/2002 24
2/12/2003 110
2/3/2004 169
2/19/2004 12.2
2/27/2004 232
10/19/2004 28.1
10/28/2004 39
12/6/2004 4.89
1/10/2005 83.8
10/19/2005 4.14
11/10/2005 13.8
2/21/2006 23.8
3/1/2006 26.2
12/11/2006 7.4
2/23/2007 5.8
4/21/2007 2.9
9/24/2007 5
12/19/2007 5.7
1/24/2008 14.6
11/26/2008 26.3
12/16/2008 11.3
2/7/2009 2.6
3/5/2009 2.8
10/14/2009 21
12/8/2009 20
2/6/2010 24
10/7/2010 20
10/31/2010 47
2/17/2011 7.7
Comment from DaleW
Time: Friday, January 20, 2012, 9:36 pm
Bram – Your data ran fine for me from the Text Import Wizard. The early data has so much scatter that you might consider alpha=0.5, if you can get past the runtime error.
Comment from Bram
Time: Monday, January 23, 2012, 11:52 am
Dale,
Thanks for your response. It seems like its working now.
Bram
Comment from Jason
Time: Wednesday, March 7, 2012, 6:06 pm
Hi Jon,
Let me just say thanks for putting together a great tool. It’s perfect for analyzing my data and bringing datasets to a common scale for comparison. However, after some use of the add-in it’s started to exhibit some instability. It launches fine and I can click in the “X Input” box, but if I click anywhere else on the interface it closes immediately. I’m currently on Excel 2010, but had a similar issue on 2003.
Have you ever seen that before or have any recommendations for a fix?
Thanks,
Jason
Comment from Jon Peltier
Time: Wednesday, March 7, 2012, 6:24 pm
Hi Jason -
I use this utility frequently, at least once per day, mostly in 2003, and I’ve never encountered any instability. Do you get an error message.? Does it happen on sheets on which you’ve already used the utility, or on sheets on which you haven’t used the utility, or both? Does it happen right after Excel opens, or after it’s been running for a while? Is the data completely numeric?
Comment from Jason
Time: Wednesday, March 7, 2012, 6:31 pm
Sorry for the redundant post… I just read through the comments and it seems that I’m not the only one experiencing the self closing fluke. I’ll use J Hey’s work around and copy and paste data from one sheet to the other for the time being.
Thanks again for putting the time into this utility!
Comment from Shirley
Time: Tuesday, March 27, 2012, 4:46 am
Thanks for your instructions on dowloading the software, and again for you work on this dissertation saver.
I tried to use the loess utility and received a message similar to one of your other users: runtime error ’6′ overflow. The solution to this problem wasn’t on this listserv, can you please help me to figure out reasons for getting this error message.
Thanking you in advance,
Shirley
Comment from Jon Peltier
Time: Wednesday, March 28, 2012, 9:29 am
Shirley -
The problem is with your data. You have 635 input points, but only 5 distinct X values. This means that for large amounts of your data, there is no X variation. The moving regression cannot calculate a slope, because the data are aligned vertically and the sum of squares variation of X is zero. Dividing by zero then gives you an overflow (infinity). The formulation of the weighting factor exaggerates the problem.
If you use 100% of the data points, you can use the program, (50% still had an overflow). The LOESS result is slightly less interesting than simply looking at the averages.

Another thing: using the same X inputs and outputs means the program will calculate duplicate output values each time a duplicate X appears in the input range. Use a second table for the outputs, without the duplicate X values, to minimize calculation times.






Write a comment
I welcome comments from my readers. If you have an opinion on this post, if you have a question or if there is anything to add, I want to hear from you. Whether you agree or disagree, please join the discussion.
If you want to include an image in your comment, post it on your own site or on one of the many free image sharing sites, and include a link in your comment. I'll download your image and insert the necessary html to display the image inline.
Read the PTS Blog Comment Policy.