I quickly looked at this, do note that I'm using JMP16 and For Each() instead of For().
Question1:
I think you need to get separate references to the outline boxes, one option is too use XPath and then loop over the list of lists. Also
//creates a report and maximizes desirability
//doesn't work if there is anything in the by() field
pf_obs = fit << XPath("//OutlineBox[text()='Prediction Profiler']"); // list of lists so easiest to loop over them
For Each({pf_ob}, pf_obs,
pf = pf_ob << Get Scriptable Object;
pf << Maximize and Remember;
);
//create a data table with the parameters from the prediction profile
//in my other version (with the for loop a Where( :x = y[i]) in the model, I than had some code to concatenate tables together and change some formatting
dtout[1] = Report(fit[1])["Prediction Profiler"]["Remembered Settings"][Table Box(1)] << Make Combined Data Table

Question2:
I would do a bit larger refactor to this part of code to make it more clean, but you can do also "quick fix" one for this. Use Insert Into to add Response Limits to Profiler expression
jslExprProfiler = expr(
Profiler( 1,
Confidence Intervals( 1 ),
Desirability Functions( 1 ),
//sets desirability target of the crit response
_Y2_ << Response Limits(
{Lower( ytarg-1, 0.0183 ), Middle( ytarg, 1 ), Upper( ytarg+1, 0.0183 ),
Goal( "Match Target" ), Importance( 1 )}
)
);
);
For Each({mod}, ModList,
Insert Into(
jslExprProfiler, EvalExpr(
Expr(mod) << Response Limits({Lower(1, 1), Middle(2, 1), Upper(3, 1), Goal("None"), Importance(1)})
)
)
);
jslExprProfiler = Substitute(
Expr(fit << _prof_),
Expr(_prof_), Name Expr(jslExprProfiler)
);
jslExprProfiler = Substitute(
Name Expr(jslExprProfiler),
expr(_Y2_), nameexpr(yList[1])
);
Full code:
View more... Hello,
I'm working on a script that will allow users to
- Select columns to fit into a model
- Identify the primary variable and specify the goal value
- Identify what column to split the model by
- Allow JMP to create the model, optimize desirability to hit the intended target, then output the model results
- Copy the results from a convenient output table
I have functional scripts that do what I want without allowing for user input or selection, but making the script interactive has been challenging. I think I'm mostly there, but I have a few specific things I'm struggling with
- Question 1: in a previous version of this script, I used a different window for each model using a for loop with a While( x == "y[i]") line. I'd rather use By( :x ) because it is more flexible and gives one output window. However using By( :x ) breaks the later script to get a scriptable object from the report. Is it possible to create a different report for each sub-box in the model window? Or a better way to code lines 173-181? I build those lines based on these other two threads: thread 1, thread 2.
- Question2: I need the option to be able to have a variable number effects that are modeled without having desirability functions (later the full script will also have effects that are minimized but this simplified demo script was getting too complicated. On lines 122-126 I am able to created the desired expression in ModExpr, but because it's a list it didn't work when I tried to directly substitute it into the profile. My workaround is having a number of placeholders greater than the number of variables I expect to model and the code seems to just ignore the nonsense parts if I have fewer than 6 modeled effects... but this seems super janky. Is there a way to fix the commented code in lines 130-134 such that the list is combined into as single expression that will work? I Couldn't get Concatenation to play nice either, but I bet there is something simple that I missed.
Here is a sample script using sample data. The model is a terrible fit, but that's not really important for the demo. When running, if you clear the selection for "by", things will run fine and output results. If anything is left in the "by" section, then line 174 will break.
Thank you for any help!
Names Default To Here( 1 );
//sample data for demo
dt = Open( "$SAMPLE_DATA/Football.jmp" );
xvar = {};
yvar = {};
byvar = {};
ytarg = 60;
dtout = {};
//let users select the columns to model
win = New Window( "Model Variable Selection",
<<MODAL></MODAL>