- JMP User Community
- :
- Discussions
- :
- Moving Average

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

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
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content

Created:
Jan 3, 2019 07:56 AM
| Last Modified: Jan 3, 2019 4:59 AM
(16108 views)

I have a table called drugs with columns drug and result, how do I calculate the moving average of the result column by taking the first 4 rows followed by the next 4 rows and similarly continue. Pfa the sample table for reference.

1 ACCEPTED SOLUTION

Accepted Solutions

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

The formula to use is

```
If( Mod( Row(), 4 ) == 0,
Mean( :Result[Index( Row() - 3, Row() )] )
)
```

I have attached your example data table, with a new column with the formula in it

Jim

11 REPLIES 11

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

hello ,

you can try with Formula column --> row --> moving average

Gianpaolo Polsinelli

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

Could you please explain the next step after this, I want to calculate the average of 4 consecutive samples

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

Do you have 4 columns of results, or 4 times as many rows as you show in your sample data table?

Jim

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

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

The formula to use is

```
If( Mod( Row(), 4 ) == 0,
Mean( :Result[Index( Row() - 3, Row() )] )
)
```

I have attached your example data table, with a new column with the formula in it

Jim

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

Thanks this worked

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

I think this will give you the moving average that you want (4 rows before and 4 rows after).

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

this did not work

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

Create a new column in your data table, and apply the folloing formula

`Col Moving Average( :Result, weighting = 1, before = 3, :Drug )`

Jim

- © 2024 JMP Statistical Discovery LLC. All Rights Reserved.
- Terms of Use
- Privacy Statement
- About JMP
- JMP Software
- JMP User Community
- Contact