BookmarkSubscribe
Choose Language Hide Translation Bar
shock88us
Community Trekker

Writing a JMP formula

I have a data set from 1985-1996 showing yearly reductions in about 16 different cities. Not all of the cities have complete data sets. I have to find the mean of the yearly difference for each city. The data is listed by month but the numbers only actually change after the last month. There are holes all over the approximately 2000 lines of data. I would be fine if there were no holes, but I'm stumped. Can anyone steer me in the right direction?

0 Kudos
6 REPLIES 6
txnelson
Super User

Re: Writing a JMP formula

I have only a vague idea of what the data table actually looks like.....could you either attach the data table, or a subset of the data table?  That would really help in figuring out a solution.

Jim
0 Kudos
shock88us
Community Trekker

Re: Writing a JMP formula

Here is an excel version of the data set

0 Kudos
shock88us
Community Trekker

Re: Writing a JMP formula

I'm trying to subtract the new value in column D from the previous value every time the year in column B changes and then have it calculate the mean for each location

0 Kudos
shock88us
Community Trekker

Re: Writing a JMP formula

 
0 Kudos
txnelson
Super User

Re: Writing a JMP formula

The solution is quite simple...just simplify the data down to one row per year/location, and then add a new column with a simple formula and then generate a tabular report.  Below is a script that will perform the tasks.  The script was generated by performing the tasks required interactively and then having JMP generate the required script for each step in the solution

Names Default To Here( 1 );

// Create a handle pointing to the raw data table
dt = Current Data Table();

// Since all of the values for each year are the same,
// summarize the data by year and location to get just one
// row per year/location.......Min, Max, Mean, Median could 
// all be used for the statistic, since they would yield
// the same results, with all of the data being the same
dt2 = dt << Summary(
	Group(
		:Name( "Site of ARB_metals 2 final 2 By (Site, yr)" ),
		:Name( "yr of ARB_metals 2 final 2 By (Site, yr)" )
	),
	Max( :Name( "Mean(log(Pb))" ) ),
	Freq( "None" ),
	Weight( "None" ),
	statistics column name format( "column" )
);

// Add a new column, calculating the difference
dt2 << New Column( "Difference",
	formula(
		If(
			Row() == 1 | Lag( :Name( "Site of ARB_metals 2 final 2 By (Site, yr)" ) ) !=
			:Name( "Site of ARB_metals 2 final 2 By (Site, yr)" ),
			.,
			Lag( :Name( "Mean(log(Pb))" ) ) - :Name( "Mean(log(Pb))" )
		)
	)
);

// Run the Tabulate Platform to generated the desired table
dt2 << Tabulate(
	Show Control Panel( 0 ),
	Add Table(
		Column Table( Analysis Columns( :Difference ), Statistics( Mean ) ),
		Row Table(
			Grouping Columns(
				:Name( "Site of ARB_metals 2 final 2 By (Site, yr)" )
			)
		)
	)
);

I suggest that you read the document "Using JMP" as a good way to start to learn JMP

     Help==>Books==>Using JMP

Jim
0 Kudos
rwright
Community Trekker

Re: Writing a JMP formula

The mean of means is simply the mean of the sum of the means. 

 

Here's a website that discusses this: The Mean of Means | CK-12 Foundation - https://www.ck12.org/book/CK-12-Probability-and-Statistics-Concepts/section/9.6/

 

0 Kudos