Hi,
I am trying to do a moving average and a weighted moving average on the data set that I have posted below.
I want to do a moving average to the 'Mean' column.
Also can I repeat this formula by the 'Sample' group in my data set
It's just a simple extension of your formula. You just have to keep track of when the :Sample changes, and then start the calculations from scratch
If( :sample != Lag( :sample, 1 ) | Row() == 1, counter = 0; startrow = Row(); ); counter = counter + 1; If( counter < 3, Mean( :Mean1[Index( startrow, Row() )] ), Mean( :Mean1[Index( Row() - (3 - 1), Row() )] ) );
Here is a moving average formula
Mean( Lag( :Points, 1 ), Lag( :Points, 2 ), Lag( :Points, 3 ), Lag( :Points, 4 ), Lag( :Points, 5 ) )
and a weighted moving average
Mean( Lag( :points, 1 ) * :mean, Lag( :points, 2 ) * :mean, Lag( :points, 3 ) * :mean, Lag( :points, 4 ) * :mean, Lag( :points, 5 ) * :mean )
Hi txnelson,
Is the below formula you suggested moving average for the 'Points' column?And you are using the Mean() formula?
How can I put this in a for loop to do it over all the rows?
Also I want to do this By Group
Using a formula to define the values of a column is an essential part of JMP. It is well documented in the JMP book called "Using JMP". I suggest you read that book. It was installed on your computer when you installed JMP. You get to it under the Help pulldown menu
Help==>Books==>Using JMP
Regardless, here is how to use the formula that I provided you, create a new column in your data table and then right click on the column header and select "Formula"
As you can see in my example, I named the new column "Moving Average"
The next window that will open up, is the Formula Editor
It allows you to point and click and create whatever formulas you want. However, you can also double click in the blue outlined box that has the wording "no formula" and the editor will come up
As seen in the above window, I just typed in the formula, or it can be pasted into the window. Then when you click on the "OK" button, you will see the graphical form of the formula
Then when you click on the "OK" button, or the "Apply" button the formula will be run for the new column
I was able to get the 3 point Moving Average using.I was able to apply the formula as well.
"If( Row() < 3,Mean( :Mean1[Index( 1, Row() )] ),Mean( :Mean1[Index( Row() - (3 - 1), Row() )] ))"
Ho can I do this By Group for the Column "Sample"?
For each value of Sample I want a moving average for the "Mean1" values and I have 239 Sample values.
Thank you for your help