What algorithm is used for the "Moving Average"

Have a suggestion for improving DPlot or a question about existing features? Let us know

Moderator: DPlotAdmin

Post Reply
John
Posts: 12
Joined: Sun Sep 11, 2005 4:58 am
Location: Salt Lake City, Utah

What algorithm is used for the "Moving Average"

Post by John »

I need to know what mathematical algorithm is used for the moving average calculations.

Normally, a moving average will require that the "end regions" of the graph not be included in the graph of the moving average, since, for example, a centered 11-day moving average can't provide data for the first 5 days and therefore can't be graphed. The same is true of the last 5 days in this example. I believe this problem is inherent in all moving average calculation varieties (though I'm open to being educated).

I bring it up because graphing the end-point regions of a moving average generates quite a bit of controversy in the climate sciences where I work because the end regions normally excluded in a moving average have to be filled in based on some sort of (often unscientific) assumption--even a simple "continue the trend" assumption.

Regardless of which moving average method (and extensions to graph end-points) is used, could you provide me with the algorithm and in the future include it in the help/pdf user manual, David? I've tried searching the forum & couldn't find anything. I just need to explain to those I'm presenting my graphs to how the calculations were made. Ideally, I'd prefer an option to exclude the extend-to-endpoint algorithms altogether.

Many thanks.
John
--John
Using Dell Optiplex GX 260, Windows XP Professional SP3, Intel Pentium 4 @ 2.66 GHz, 1GB RAM.
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

John,
The output is an average of the previous N points, where N is the interval chosen. This is identical to the Moving Average function of Excel's Analysis ToolPak, with the exception that Excel gives "#N/A" for the first N-1 points, while the DPlot plugin gives the average of the previous i points for the i'th point.

It would be easy enough to add a couple of options here:

1) Trailing points or centered (not sure what should happen in the latter case if N is even; probably shouldn't allow it.)

2) At the tails, either return an average or... don't.
Visualize Your Data
support@dplot.com
John
Posts: 12
Joined: Sun Sep 11, 2005 4:58 am
Location: Salt Lake City, Utah

Post by John »

I'll check out the Excel documentation (I'm assuming I'll find the formula there). And on centered moving averages, they do require an odd number of points.

Really appreciate the help. The climate community gets a little "paranoid" about what's going on behind the curtain when one is trying to draw temperature trend lines onto current data (not to mention future projections)--especially warming vs cooling ones. :wink:

--John
--John
Using Dell Optiplex GX 260, Windows XP Professional SP3, Intel Pentium 4 @ 2.66 GHz, 1GB RAM.
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

I think you'll like this one better:

http://www.dplot.com/plugins/generate/movavg.dll

Overwrite the existing <dplot folder>\plugins\generate\movavg.dll with this one. This will be included in the next release.
Visualize Your Data
support@dplot.com
John
Posts: 12
Joined: Sun Sep 11, 2005 4:58 am
Location: Salt Lake City, Utah

Post by John »

Love it. Now that's what you call customer service! :D
--John
Using Dell Optiplex GX 260, Windows XP Professional SP3, Intel Pentium 4 @ 2.66 GHz, 1GB RAM.
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

Thanks - glad you noticed :D

For anybody else following this thread who hasn't downloaded the updated plugin, here's a look at the new input:

Image

"Prior moving average" is what the plugin has always produced. "Include tails", if checked, acts the same way that the previous plugin did by default: for interval N and point i for i < N, with a "prior moving average" points 1 through (N-1) use (Y1+Y2+...+Yi)/i. If "Include tails" is unchecked, you only get output starting with point number N (1-based). Same sort of deal for "central moving average".
Visualize Your Data
support@dplot.com
Post Reply