scripts

Does anybody know how to read a specific setting from the Preferences? I need to read the status of ‘Use JMP locale settings’ and if 0 then change to 1 and give the user a message to restart JMP.

Several people had helpful suggestions, but unfortunately it’s just not a trivial problem. It’s a surprisingly tricky problem.

Challenges

First, by default Show Preferences() only shows the preferences that you’ve taken to change. You need to use Show Preferences(all) to see the defaults listed, too.

Second, Show Preferences(SomeSpecificPreferenceHere), although a good guess, doesn’t actually work. You’ll just get the usual output for Show Preferences() without an argument.

Lesson: when you supply an argument JMP doesn’t understand, sometimes you get errors, but a lot of the time it’s just ignored, silently. You get no indication that you did something that doesn’t work. The only way you can be sure it was ignored is to try it again without the argument, or with a different argument, and check whether anything changed.

Third, Show Preferences( [all] ) doesn’t return an expression. It returns missing. The information you need is echoed to the Log window, but it’s not returned as a string or an expression or a list or anything else you’d be able to do some work on. So you need to overcome that.

How to solve the basic problem

In JMP 9, you can Get Log(), which returns a list of strings, one for each line of whatever’s in the log. So to work efficiently, you need to Clear Log() first, then Show Preferences(all), then do Get Log().

Well! Now you have a list of strings, and you need to find the item in that list that is relevant, so you need to put a Contains() test inside a For() loop.

It’s a string, so you have to transform it into an expression with Parse() and some other bookkeeping, so that you can probe its argument with Arg().

Then check whether the argument is the desired one, and if not, change it, by editing the expression with Substitute() and then immediately doing Eval() on the result of that.

Now we need to let the user know we did something, and perhaps that they need to restart. So, put up a New Window() with a Text Box() saying that a preference has changed and they need to restart. Include a Button Box() for “OK” that closes the alert window.

So, that’s the gist of the strategy.

Abstract the script

But, why write all this just for this one specific preference? Why not write it to check and if necessary change any preference?

So, start out with a couple globals that set the preference and the desired value.

But wait! Marianne’s example involves a numeric argument, but other preferences have text arguments; consider Use JMP Locale Settings(0) vs. Report Table Style("Plain"). So we need to make sure our script can work properly whether the particular preference takes a numeric or string value.

And while Marianne’s example requires a restart for the changed preference to take effect, most preferences do not. Might as well set a restartNeeded=1 if it’s important, or 0 if it’s not.

In that alert window, we only need to tell them to restart if it’s important, not if it’s not, so let’s add an If Box() around the Text Box() that only shows the instruction if it’s needed.

If the preference was what we wanted in the first place, we should probably echo something to the Log window, just so we know it ran, if nothing else. We need a Write() statement for that.

Which version of JMP?

But wait, there’s more! The Get Log() command didn’t come along until JMP version 9. If you haven’t been able to upgrade yet, then you need to take another strategy to this whole problem.

There might be a better way to do this, but the only way I could find was to Save Log() to a text file, then Load Text File() to a string, then use Substr() and a bunch of arguments with Contains() to chop out the single preference we care about. From there, the script runs about the same way.

And we need to put all this inside a test for JMP Version(), which returns a string, and usually we need to Trim() it and then do an inequality test, e.g. If( Trim( JMP Version() ) > "9", …), where the first argument is the Get Log() strategy described first, and the second argument uses the Save Log() strategy.

What about nested preferences?

Yet another problem! The script so far deals with top-level preferences with simple, single arguments, either numeric or character. But some preferences are trickier, e.g.,

Preferences(
Fonts(
English(
Monospaced Font("Courier", 10)
)
)
);

In this case, the Parse() line will need to be more elaborate, and you’ll have to nest more Arg()s around it to dig down to the particular setting value of interest. Conditioning for such a situation is left as an exercise for the reader, primarily because it’s a hassle, it’s not what Marianne needs, and the syntax of the Preferences() command in JMP is arbitrary enough that we can’t really write code today that will be future-proof; we don’t know how deeply nested a given preference might be, nor what kind of arguments it might expect.

Nevertheless, the core of the script should be useful for anybody needing to query and change most preferences, and the elaboration necessary to adapt this script to a more deeply nested preference isn’t too complicated.

If you have any trouble with it, though, please feel free to contact us at Global Pragmatica LLC®; we’ll be happy to customize this script further for you at a nominal cost.

Purchase the code for $2

A finished, working, version-neutral script that has been tested on JMP 8 and 9 on Mac and Windows is available for purchase and immediate download for $2 US.

I am sending Marianne a coupon code for a complimentary copy, with my thanks for her intriguing question.

While the script itself might not be of immediate use to most readers, I hope that the strategies seen in the script will be of far greater value. Please contact me if you are in any way disappointed in the script, and I will arrange for an immediate bug-fix or refund upon receipt of your concerns.

Background

I know I can calculate a sample size for a one proportion test in JMP, but how do I test for 1 proportion?

Karen Copeland, Ph.D., from Boulder Statistics promptly gave a helpful explanation of how to do it in JMP. JMP handles the problem quite capably, but you have to know where to find it and remember a bunch of details about how to use it:

To test one proportion in JMP I use the distribution platform. When you run a distribution for a nominal variable then in the red drop down menu there is an option for testing probabilities.

Details:

If you have a data table with a column for your proportion then you can proceed straight to the distribution platform. If not then first create a summary table with two columns. The first column would be your outcome such as Y/N or 0/1 and the he second column would be your frequency column of how many of each outcome you observed.

Testing of a proportion:

1. With a column of outcomes: First make sure that your column is of the nominal type. Second, use the distribution platform to create a distribution of the outcome. Under the red triangle drop down menu select “Test Probabilities” and a dialog box will appear with various options for testing your probabilities. Note, you need only fill in the one probability that you are interested in testing.

2. With a summary table for your outcomes: Again, make sure that your outcome column is of the nominal type. Second, use the distribution platform with your outcome column as the Y and the frequency column as the “Freq”. Then continue as above by selecting the test probabilities from the red triangle menu.

Note that you will also find confidence intervals for your proportions in the red drop down menu.

Boulder Statistics LLC and Global Pragmatica LLC are strategic allies, pairing Boulder Statistics’ analytical expertise with Global Pragmatica’s JMP scripting expertise to deliver outstanding solutions to our clients. When I saw Karen’s explanation, I immediately thought this would be a great opportunity to collaborate with her and build a JSL widget to make this easier.

This script is the result, and Global Pragmatica and Boulder Statistics are proud to make it available free, in an encrypted (run-only) script you can download today.

How to use One Proportion Test

Launch the script. You are asked to choose a data table, which can be set up either of the two ways Dr. Copeland describes above. A dialog box requests the necessary column assignments. Click OK. At the bottom, fill in the details of the One Proportion Test. Use the Start Over button to restart the analysis with a different data table. For further help, see text at the top of the window and tooltips when hovering over buttons.

How encrypted scripts work (the free widget)

Encrypted scripts are run-only scripts. They are not human-readable, so you can’t modify them or adapt them for other purposes. If you would like to study the JSL, modify, or adapt the script, you should license the unencrypted version of this script instead.

Why pay for the unencrypted script?

Don’t! At least not right away… Start by “buying” the free widget. Try it out and see if you like it!

If you do, you might want to buy the full-price unencrypted script, so that you can modify, customize, or adapt the script for your own specialized needs, or so you can study a professional-quality script! This script demonstrates quite a few advanced scripting techniques, including:

building an elegant, all-in-one-window user interface using display objects

attaching scripts to buttons, radio buttons, column lists, etc.

including a custom logo graphic

implementing a different dialog box according to the user’s radio button choice

opening, closing, and deleting display tree elements dynamically

offering tips and help right in the window

including email and web links for more information, sending feedback, etc.

hiding globals—whether to protect intellectual property or to avoid cluttering up Show Globals() output

optimizing memory management and simplifying between-use value-clearing by storing problem-specific “globals” as entries in an Associative Array() instead of in globals

Compatibility

One Proportion Test has been tested on JMP 8 for Mac and Windows as well as current beta versions of JMP 9 for Mac and Windows.

Known issues

In the second (no longer current) early adopter release of JMP 9 for Windows, you have to start the script manually. (This is not a problem in JMP 8 or later beta releases of JMP 9.) There are several ways to do this:

press Ctrl-R, or

click the Run Script button in the toolbar, or

from the Edit menu, select Run Script

Buy now!

Run-only widget: $0.99
Editable script: $500.00

Note: be sure to choose either the $0 (widget) or $500 (script) option in the combo-box. For $0 orders, you can use the “No payment needed” payment method; for orders over $0, please use Google Checkout, a secure payment gateway for purchasing by credit card.

“Iterative Regression” is a script that Global Pragmatica LLC® developed for Ron Tanasichuk of the Canadian Department of Fisheries and Oceans, implementing his own interative regression technique. Performing the analysis is by hand is cumbersome and extremely slow and cumbersome. Automating the analysis reduces the processing time from weeks to minutes and eliminates the human error.

The method:

for a single Y response and multiple X factors, fit all possible models having one and two factors (no interactions)

for each model, exclude any outliers, and refit the model

repeat fitting and excluding until there are no outliers for the model

save the results from that model

re-include all rows (unexclude all rows) and begin again with the next factor combination

Sponsorship and pro bono work

Global Pragmatica LLC® offers professional services at no charge or reduced rates, at its discretion, to non-profit, music, educational, and similar organizations. We believe in servant leadership and make it a priority to join and support those who are actively imagining and creating a better world.

Blog archive

Tools

Artwork

Global Pragmatica's artwork includes paintings by Zsuzsi Saper and digital photographs by Erin Vang. Further notes on specific pieces of art are given at the bottom of pages in which they appear. All artwork is copyright 2009–2010 by Global Pragmatica LLC®. All rights reserved worldwide.