cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
Djtjhin
Level IV

Subscript reference wrong display box

In the script below, I was expecting the returned title to be "Fitted Weibull Distribution" but I get "Fitted Normal Distribution" instead. I'm not sure what's wrong, really appreciate the help. 

 

names default to here(1);

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

db = dt << Distribution(
	Stack( 1 ),
	Continuous Distribution(
		Column( :height ),
		Horizontal Layout( 1 ),
		Vertical( 0 )
	)
);

db << fit all;

Title_1 = report(db)[Outlinebox("Fitted?")] << get title;
print(Title_1);
Capture1.PNG
2 ACCEPTED SOLUTIONS

Accepted Solutions
jthi
Super User

Re: Subscript reference wrong display box

You seem to be missing some whitespace from your outline search inside the for loop (there should be space after "Fitted" -> "Fitted ").

 

Regarding the indices: most likely it is getting them in "original" order 

jthi_0-1712204007168.png

Below is an example which tries to avoid that checkbox mess using XPath

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");

db = dt << Distribution(Stack(1), Continuous Distribution(Column(:height), Horizontal Layout(1), Vertical(0)));
db << fit all;
rpt = db << Report;

rpt["Compare Distributions"][CheckBoxBox(1)] << set(3, 1); //make additional random selection
Wait(0);

tb = rpt[Outline Box("Compare Distributions"), Table Box(1)];
items = tb[1] << XPath("//CheckBoxBoxItem");
selections = {};
For Each({item, idx}, items,
	If(Contains(item, "\[isChecked="true"]\"),
		Insert Into(selections, idx);
	);
);

dists = (tb[2] << Get)[selections];

For Each({distname}, dists,
	ob = rpt[Outline Box("Fitted " || distname || " ?")];
	show(ob << get title);
);
-Jarmo

View solution in original post

jthi
Super User

Re: Subscript reference wrong display box

I used << Get XML on the Table Box reference to see if there was anything interesting I could use to get what I wanted to

jthi_0-1712570002398.png

 

-Jarmo

View solution in original post

8 REPLIES 8
txnelson
Super User

Re: Subscript reference wrong display box

My guess is that JMP creates in memory all of the Fitted outputs so when you ask for 

Title_1 = report(db)[Outlinebox("Fitted?")] << get title;

The Fitted Normal is the first one in Memory, and therefore it is the one returned.  You can bypass this issue with 

Title_1 = report(db)[Outlinebox("Fitted Weibull?")] << get title;

Or

Title_1 = report(db)[Outlinebox( 6 )] << get title;
Jim
jthi
Super User

Re: Subscript reference wrong display box

I think all the different fits are still there even if they aren't visible (they are under If Boxes), report subscripting will still match those and finally using ? wildcard search will match the first outline box which satisfies your search (in this case Fit Normal Distribution)

jthi_2-1711953471049.png

You can use JMP to build the path from Show Properties menu (box path)

Report(platform)["height","Fitted Weibull Distribution"]

You could write longer search term (I would avoid ? whenever possible)

Title_1 = report(db)[Outlinebox("Fitted W?")] << get title;

Or use XPath and get all the titles and get what you want from that

fit_obs = Report(db) << XPath("//OutlineBox[contains(text(), 'Fitted ')]");
fit_obs << get title;
-Jarmo
Djtjhin
Level IV

Re: Subscript reference wrong display box

Ah you are right. I didn't knw this before that all the possible fits are stored in the background. Good to know!

Re: Subscript reference wrong display box

I would use the table of sorted fits to make the reference.

Names Default To Here( 1 );

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

db = dt << Distribution(
	Stack( 1 ),
	Continuous Distribution(
		Column( :height ),
		Horizontal Layout( 1 ),
		Vertical( 0 )
	)
);

db << fit all;

rpt = db << Report;
dist = rpt["Compare Distributions"][String Col Box( "Distribution" )] << Get;
Title_1 = rpt[Outline Box( "Fitted" || dist[1] || "?" )] << get title;
Print( Title_1 );
Djtjhin
Level IV

Re: Subscript reference wrong display box

I think this is getting close to what I'm looking for. What I'm trying to do is get the user-selected distribution(s) and the respective parameters. I tried to modify the script to below but it doesn't necessarily give the right output. Could you help point out where I did wrong ?

Additional, this also raised few other doubts: 

- why does the << get selected indices as matrix message returns the result in reverse order ?

Names Default To Here( 1 );

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

db = dt << Distribution(
	Stack( 1 ),
	Continuous Distribution(
		Column( :height ),
		Horizontal Layout( 1 ),
		Vertical( 0 )
	)
);

db << fit all;

rpt = db << Report;

rpt["Compare Distributions"][CheckBoxBox( 1 )]<<set(3,1); //make additional random selection
wait(1);

dist = rpt["Compare Distributions"][String Col Box( "Distribution" )] << Get;
matrix = rpt["Compare Distributions"][CheckBoxBox( 1 )] << get selected indices as matrix();
matrix = reverse(matrix);
index = loc(matrix,1);
for(i=1,i<=nitems(index), i++,
	Title_1 = rpt[Outline Box( "Fitted" || dist[index[i]] || "?" )] << get title;
	Print( Title_1 );
);

Appreciate the help so far

jthi
Super User

Re: Subscript reference wrong display box

You seem to be missing some whitespace from your outline search inside the for loop (there should be space after "Fitted" -> "Fitted ").

 

Regarding the indices: most likely it is getting them in "original" order 

jthi_0-1712204007168.png

Below is an example which tries to avoid that checkbox mess using XPath

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");

db = dt << Distribution(Stack(1), Continuous Distribution(Column(:height), Horizontal Layout(1), Vertical(0)));
db << fit all;
rpt = db << Report;

rpt["Compare Distributions"][CheckBoxBox(1)] << set(3, 1); //make additional random selection
Wait(0);

tb = rpt[Outline Box("Compare Distributions"), Table Box(1)];
items = tb[1] << XPath("//CheckBoxBoxItem");
selections = {};
For Each({item, idx}, items,
	If(Contains(item, "\[isChecked="true"]\"),
		Insert Into(selections, idx);
	);
);

dists = (tb[2] << Get)[selections];

For Each({distname}, dists,
	ob = rpt[Outline Box("Fitted " || distname || " ?")];
	show(ob << get title);
);
-Jarmo
Djtjhin
Level IV

Re: Subscript reference wrong display box

Thanks @jthi!  That works!

Btw, for my learning, I wouldn't have come to using 'ischecked = "true"' syntax as I didn't find this in scripting index nor in displaybox properties themselves. Could you share how you derive this? Would be nice for me to learn this process for future references.

jthi
Super User

Re: Subscript reference wrong display box

I used << Get XML on the Table Box reference to see if there was anything interesting I could use to get what I wanted to

jthi_0-1712570002398.png

 

-Jarmo