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
- :
- rolling moving average

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

Highlighted
##

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

rolling moving average

Jun 21, 2020 11:23 PM
(301 views)

Hi,

I want to create a new column "moving average" and want this column to do rolling average of temp based on ID. I attached a sample file here. Can you please help with the formula?

thanks!

5 REPLIES 5

Highlighted
##

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

Re: rolling moving average

Assuming that your definition of "Rolling Average" is a "Moving Average" the formula is

Col Moving Average( :Temp, :ID )

Documentation and Examples of the Col Moving Average() are in the Scripting Index

Help==>Scripting Index

Jim

Highlighted
##

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

Re: rolling moving average

Hi Jim

I used this formula but this does not deliver what I was expecting.

First: I want to create column which is the mean of temp by ID

Then, I want to mean of the new column over "X (X is user defined)" number of IDs.

Can you please help with that?

Highlighted
##

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

Re: rolling moving average

If you read the documentation on the Col Moving Average() function, it allows for the setting of what I believe you are referring to as X.

Could you please provide some sample results. I am still not understanding your request.

Jim

Highlighted
##

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

Re: rolling moving average

Created:
Jun 22, 2020 3:03 PM
| Last Modified: Jun 23, 2020 6:21 AM
(242 views)
| Posted in reply to message from txnelson 06-22-2020

I looked into big class sample data set and created a column:

`Col Moving Average( :height, 1, 5, 0, :sex )`

What does 5 do in the calculation?

I was able to manually calculate the moving average until the row#9---How was 58.833333333 calculated? I am not able to generate the same number manually

Highlighted
##

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

Re: rolling moving average

The 5 in the function call is specifying the number of rows before the current row to include in the moving average. You can actually specify the function in the following way.....which is really the way it should be called, to make the script more readable

`Col Moving Average( :height, weighting=1, Before=5, after=0, :sex )`

In your manual calculation you have to remember that the moving average is being tracked for both Males and Females. And the average does not restart every time the data changes from F to M or M to F. It is treating the calculations as if there are 2 separate columns.

Jim