cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Instantly extract effect sizes, F-ratios, and FDR-adjusted p-values from your models with the Calculate Effects Sizes extension, available now in the JMP Marketplace!
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar

How do I compute a 24 hour rolling average

I need to compute a 24 hour rolling average for each individual subject. 

 

I have the following columns:

 

Subject ID

Time stamp

Milk yeild

 

Can anyone help direct me in the right direction?

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: How do I compute a 24 hour rolling average

Here is a simple script that creates your rolling average.  It creates a new column and uses a formula to generate the rolling average. Attached is a sample data table with the new column.  Please validate the calculations

Names Default To Here( 1 );
dt = Current Data Table();

dt << New Column( "Rolling Average",format("Percent",7,2),
	Formula(
		curTime = :Time stamp;
		curSubject = :Subject ID;
		Mean(
			:Milk yield[dt <<
			get rows where(
				:time stamp >= curTime - In Days( 1 ) & :time stamp
				 <= curTime & curSubject == Subject ID
			)]
		);
	)
);

 

Jim

View solution in original post

2 REPLIES 2
txnelson
Super User

Re: How do I compute a 24 hour rolling average

Here is a simple script that creates your rolling average.  It creates a new column and uses a formula to generate the rolling average. Attached is a sample data table with the new column.  Please validate the calculations

Names Default To Here( 1 );
dt = Current Data Table();

dt << New Column( "Rolling Average",format("Percent",7,2),
	Formula(
		curTime = :Time stamp;
		curSubject = :Subject ID;
		Mean(
			:Milk yield[dt <<
			get rows where(
				:time stamp >= curTime - In Days( 1 ) & :time stamp
				 <= curTime & curSubject == Subject ID
			)]
		);
	)
);

 

Jim

Re: How do I compute a 24 hour rolling average

This worked great! Just what I was looking for. Thank you

Recommended Articles