- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Extract or return correlation values using density ellipse from a graph builder plots in JSL
Hello,
I am kind a new to JSL. I am plotting a graph of numerical vs categorical data using graph builder function in JMP and adding ellipse to see a correlation as well. I am using the scripts for my future plots but I want customize a bit by storing the correlation(pointed with red arrow in figure) values somewhere in a variable so that I can use it in some logical operations. For example if I want to plot graphs only which has correlation more than 0.45. Any JSL script, help or leads would be appreciated. Following I tried some but no success yet.
Thank you!
gb = dt << Graph Builder(
Variables( X( :"A_column"n ), Y( :"B_column"n ) ),
Elements(
Points( X, Y, Legend( 3 ) ),
Ellipse( X, Y, Legend( 4 ), Correlation( 1 ), Mean Point( 1 ) )
),
SendToReport(
Dispatch( {"Ellipse"}, "", OutlineBox, {Close( 0 )} ),
Dispatch( {"Pairwise Correlations"}, "", TableBox, {Sort By Column( 7, 1 )} )
)
);
thing_report = gb << report;
Show Properties( thing_report );
corr = biv << Get Correlation Matrix;
Show( corr );
Store the correlation pointed in with the red arrow.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Extract or return correlation values using density ellipse from a graph builder plots in JSL
I'm not sure if you should be checking for correlation like this between Continuous and Nominal columns, but... you can export the correlation from graph builder with something like this (not sure how easily this will break):
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(
Size(535, 457),
Show Control Panel(0),
Variables(X(:height), Y(:weight)),
Elements(Points(X, Y, Legend(3)), Ellipse(X, Y, Legend(5), Correlation(1)))
);
ts = Report(gb)[Frame Box(1)] << Find Seg("TextSeg");
corr = ts << get text;
How I got there:
1. Created graph builder and opened Customize menu. Noticed that I could change the Text elements color, so I did
2. Got the script for my graph builder with red text and found out that the color change affects TextSeg()
Graph Builder(
Size(617, 457),
Show Control Panel(0),
Variables(X(:height), Y(:weight)),
Elements(Points(X, Y, Legend(3)), Ellipse(X, Y, Legend(5), Correlation(1))),
SendToReport(
Dispatch(
{},
"Graph Builder",
FrameBox,
{DispatchSeg(TextSeg(1), {Fill Color("Medium Dark Red")})}
)
)
)
3. Checked Scripting Index for Text Seg and found one way to get the value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Extract or return correlation values using density ellipse from a graph builder plots in JSL
Hi,
I'm not sure if there is a way to extract this number from a Graph Builder report, but it is quite simple to do it using Multivariate (see script below). Does this work for you?
Names Default To Here(1);
dt=open("$SAMPLE_DATA/Tablet Production.jmp");
mul=dt<<Multivariate(
Y( :Dissolution, :Mill Time ),
Estimation Method( "Row-wise" ),
Scatterplot Matrix( 1 )
);
corr_matrix=report(mul)[MatrixBox(1)]<<get;
show(corr_matrix);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Extract or return correlation values using density ellipse from a graph builder plots in JSL
Hi HadelyMyers,
Thank you so much for the solution. In my data one column is numerical and the other one is categorical(Mostly characters). I am not sure how to use multivariate with this type of data. That is the reason I am using graph builder and density ellipse plot to see the correlation over there. Unfortunately, the solution you provide didn't work on my data. Hoping for your response.
Thank you again!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Extract or return correlation values using density ellipse from a graph builder plots in JSL
I'm not sure if you should be checking for correlation like this between Continuous and Nominal columns, but... you can export the correlation from graph builder with something like this (not sure how easily this will break):
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(
Size(535, 457),
Show Control Panel(0),
Variables(X(:height), Y(:weight)),
Elements(Points(X, Y, Legend(3)), Ellipse(X, Y, Legend(5), Correlation(1)))
);
ts = Report(gb)[Frame Box(1)] << Find Seg("TextSeg");
corr = ts << get text;
How I got there:
1. Created graph builder and opened Customize menu. Noticed that I could change the Text elements color, so I did
2. Got the script for my graph builder with red text and found out that the color change affects TextSeg()
Graph Builder(
Size(617, 457),
Show Control Panel(0),
Variables(X(:height), Y(:weight)),
Elements(Points(X, Y, Legend(3)), Ellipse(X, Y, Legend(5), Correlation(1))),
SendToReport(
Dispatch(
{},
"Graph Builder",
FrameBox,
{DispatchSeg(TextSeg(1), {Fill Color("Medium Dark Red")})}
)
)
)
3. Checked Scripting Index for Text Seg and found one way to get the value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Extract or return correlation values using density ellipse from a graph builder plots in JSL
Hi Jthi,
Thank you so much! It worked!!!
Based on my limited understanding, I thought this is one of the way to see correlation between numerical and categorical(which includes numbers and characters) data. I maybe wrong and I would love to explore any suggestions if you have.
Thanks again!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Extract or return correlation values using density ellipse from a graph builder plots in JSL
I am not sure why I have started getting this error
too many arguments in access or evaluation of 'Contains'
Here is my code..
ts = Report( gb1 )[Frame Box( 1 )] << Find Seg( "TextSeg" );
corr = ts << get text;
corr_num = Num( Contains( corr, "\D", "", GLOBALREPLACE ) );
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Extract or return correlation values using density ellipse from a graph builder plots in JSL
Seems like you would like to use Regex() instead of Contains().
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Extract or return correlation values using density ellipse from a graph builder plots in JSL
The definition of the Contains() function is
Your implementation of the function has 4 elements, where the Contains() function only handles 3 elements. You will need to take a different approach.