cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar

For a novice JMP 14 user, what is the easiest way to compute a moving average on a column of data?

I have seen suggestions for using a COL(  ) [with arguments I do not comprehend] and another by right clicking on the column heading, then new formula column, then row, and then moving average. However, after a number of trials through the Weighting, items before, and items after boxes, I never get the results I want. Surely JMP has something as straight forward as Excel provides. Suggestions with very plain instructions would be much appreciated.

 

Steve

3 REPLIES 3
statman
Super User

Re: For a novice JMP 14 user, what is the easiest way to compute a moving average on a column of data?

First, welcome to the community.  This is perhaps not what you are looking for, but if your data is in time order and in one column, you can do this: Analyze>Quality and Process>Control Charts>IR   (Not exactly sure if this is the sequence as I'm on V16, but I think it is). Then enter the name of the column with the data in the Process window, select OK and you will get an individual chart of the data and a moving range chart.  The MR chart is quite useful as you can detect unusual data points (e.g., special cause variation, Deming) easily. I always recommend looking at the data with various plots before using any summary statistics.

I know others will have an easier process to get what you want.

"All models are wrong, some are useful" G.E.P. Box
txnelson
Super User

Re: For a novice JMP 14 user, what is the easiest way to compute a moving average on a column of data?

The function you want to use, is

Col Moving Average()

The example from the Scripting Index

txnelson_0-1640181931394.png

Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Big Class.jmp" );
Row() = 40;
Col Moving Average( :height, 1, 5, 0, :sex );

Calculates the Moving Average for column height(:height), weighting each value in the calculation as the full value (1), include the previous 5 rows of data (5), do not include any rows after the current row (0), and do this separately for Females and Males (:sex).;

The JSL also indicates to do this just for row 40, (Row() = 40;)

If you want to create a new column that contains the moving average for each row you would simply use the Col Moving Average() function in a formula for the new column.

Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Big Class.jmp" );
New Column("Moving Average",
formula(
     Col Moving Average( :height, 1, 5, 0, :sex );
) );

 

 

Jim
pmroz
Super User

Re: For a novice JMP 14 user, what is the easiest way to compute a moving average on a column of data?

You want the col moving average function in a column formula.  Here's an example for a 5-row moving average on the "# defects" column:

dt = open("$sample_data\Quality Control\Braces.jmp");

dt << New Column( "Defect MA", Numeric, "Continuous", Format( "Best", 12 ),
		Formula( Col Moving Average( :name("# defects"), weighting = 1, before = 5 ) )
);

Try running this code and you'll see how it works.

For your table, click on Cols > New columns...

Give the new column an appropriate name, and select Column properties > Formula

Double-click on the blue box labeled no formula, then click the little box in the upper right to maximize the editor.

Paste this formula in: Col Moving Average( :name("# defects"), weighting = 1, before = 5 )

Substitute the column to be averaged for # defects, and set the before parameter to how many rows you want to average.

Click OK and OK and you're all set.