Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- Discussions
- :
- Calculate moving average for By-Groups

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jul 22, 2013 3:51 AM
(4607 views)

I'm trying to calculate a moving average for a data-set containing several rounds of the continuous data. That is, I want a calculated average for every data-point, including the first and last. The average should be 7 steps in either direction, except for either end, where non-existing data beyond the 7 step window should simply ignored. Of course I don't want data form different By-Groups to be included in the same average. I was hoping to use the "Col Mean" function, but I can't figure out how to make the average "move". Any suggestions?

BR

Jesper

Jesper

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jul 22, 2013 7:04 AM
(7131 views)
| Posted in reply to message from JesperJohansen 07/22/2013 06:51 AM

Hi Jesper,

You can use the Summation function with an If() condition to do this.

Here's a picture of what it would look like in the formula editor.

And here's the text version:

Summation(

i = Row() - 7,

Row() + 7,

If( :DAY* == :DAY*

:DIAMETER*,*

.

)

) / Summation( i = Row() - 7, Row() + 7, If( :DAY* == :DAY, 1, . ) )*

Hope that helps.

-Jeff

-Jeff

4 REPLIES 4

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Calculate moving average for By-Groups

Jul 22, 2013 4:11 AM
(4348 views)
| Posted in reply to message from JesperJohansen 07/22/2013 06:51 AM

Do you have ETS licenced? If so, there is functionality within PROC EXPAND to calculate moving averages

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Calculate moving average for By-Groups

I do have access to EST, but I have never used it. I was hoping to do it directly in the formula editor.

BR

Jesper

Jesper

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jul 22, 2013 7:04 AM
(7132 views)
| Posted in reply to message from JesperJohansen 07/22/2013 06:51 AM

Hi Jesper,

You can use the Summation function with an If() condition to do this.

Here's a picture of what it would look like in the formula editor.

And here's the text version:

Summation(

i = Row() - 7,

Row() + 7,

If( :DAY* == :DAY*

:DIAMETER*,*

.

)

) / Summation( i = Row() - 7, Row() + 7, If( :DAY* == :DAY, 1, . ) )*

Hope that helps.

-Jeff

-Jeff

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Calculate moving average for By-Groups

Jul 22, 2013 10:53 PM
(4348 views)
| Posted in reply to message from Jeff_Perkinson 07/22/2013 10:04 AM

That was exactly what I needed. Great! Thank you.

BR

Jesper

Jesper