cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
TCM
TCM
Level IV

Looking for script for new column formula for either geometric mean or 5% trimmed mean

My rows are products;  my columns are ratings given by individual users. (The users saw most or all of the products). 

 

I would like to create a column of either geometric or 5% trimmed mean of rating for each of my product (I don't want the arithmetic mean which is the only option under Formula--> Statistical).  

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Thierry_S
Super User

Re: Looking for script for new column formula for either geometric mean or 5% trimmed mean

Have you considered transforming your data in log space, then calculate the mean, and use the anti-log of the means?
Thierry R. Sornasse

View solution in original post

TCM
TCM
Level IV

Re: Looking for script for new column formula for either geometric mean or 5% trimmed mean

Hi Thierry,

Thanks for your suggestion.  Yes, that would work if all cells are filled.  Your suggestion indeed is the formula in the Columns--> Combine--> New column--> formula geometric mean that Jeff suggests below to do.

 

I think what would work is a for loop script which does not count columns with no values.  Sadly, I do not do jsl scripting :(

View solution in original post

7 REPLIES 7
Thierry_S
Super User

Re: Looking for script for new column formula for either geometric mean or 5% trimmed mean

Have you considered transforming your data in log space, then calculate the mean, and use the anti-log of the means?
Thierry R. Sornasse
TCM
TCM
Level IV

Re: Looking for script for new column formula for either geometric mean or 5% trimmed mean

Hi Thierry,

Thanks for your suggestion.  Yes, that would work if all cells are filled.  Your suggestion indeed is the formula in the Columns--> Combine--> New column--> formula geometric mean that Jeff suggests below to do.

 

I think what would work is a for loop script which does not count columns with no values.  Sadly, I do not do jsl scripting :(

TCM
TCM
Level IV

Re: Looking for script for new column formula for either geometric mean or 5% trimmed mean

Thierry, with a few clicks and additional columns, I did get to a column of geometric means.  It turns out that I didn't have to worry about missing values with this approach.  

 

Thanks for this!

Re: Looking for script for new column formula for either geometric mean or 5% trimmed mean

You can easily make a formula for the geometric mean. It is simply the Nth root of the product of N values. Here is a picture of the formula for the case of four variables (X1-X4):

 

Screen Shot 2019-08-30 at 9.49.09 AM.png

TCM
TCM
Level IV

Re: Looking for script for new column formula for either geometric mean or 5% trimmed mean

Thanks, Mark. I hesitated to use this straight code since I have many columns and not all columns are filled.  

 

Would be helpful for JMP to include these mean options in addition to arithmetic mean in New columns--> formula.

 

 

jerry_cooper
Staff (Retired)

Re: Looking for script for new column formula for either geometric mean or 5% trimmed mean

Hello @TCM ,

Admittedly, it's a bit buried, but if you select all of the columns for which you want the geometric mean, right-click on one of them, then select New Formula Column->Combine->Geometric Mean, you may get what you're after. Some of the other options in the Combine menu may be helpful to construct other formulas when you have a lot of columns.

Hope this helps.

TCM
TCM
Level IV

Re: Looking for script for new column formula for either geometric mean or 5% trimmed mean

Hi Jerry,
Thanks for the tip! Didn't know it was lurking there in the background. This is useful.

However, it only works when all my columns are filled. To get the mean on those rows with missing values, I would have to evaluate each row and make on the spot formula revisions, deleting cols with no values- which I may have to do if there is no other way around it. (Thinking there may be a special treatment of cols with missing values such that those cells are excluded from the calculation).