Our World Statistics Day conversations have been a great reminder of how much statistics can inform our lives. Do you have an example of how statistics has made a difference in your life? Share your story with the Community!
Choose Language Hide Translation Bar
Highlighted
Brad_Park
Level I

Finding vertex of bivariate graph

Hi all, 

 

I'm trying to get a vertex point from bivariate graph

 

as so far, I get the extract the parameter with script and calculate it by excel sheet. 

 

I'm quite sure finding vertex function is included in JMP but I couldn't find it. 

 

Is there any way to get vertex directly?

 

Thank you

 

<script that I used to extract the parameter>

 

dt = Current data Table ();

biv=Bivariate(
Y( :contrast_100cm ),
X( :Offset_Z ),
Fit Polynomial( 2, {Line Color( {212, 73, 88} )} ),
Where( :site == "Para#4" )
);
rbiv = biv << report;
rbiv[tablebox(4)]<<make data table("Parameter table");

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted

Re: Finding vertex of bivariate graph

Or, another approach is to use Fit Model, use the Response Surface macro so that JMP sets the response surface attribute. Then you will get a response surface output that solves for the critical values.

 

I had JMP create this script with some data that I made up.

Fit Model(
	Y( :contrast_100cm ),
	Effects( :Offset_Z & RS, :Offset_Z * :Offset_Z ),
	Personality( "Standard Least Squares" ),
	Emphasis( "Effect Leverage" ),
	Run(
		:contrast_100cm << {Summary of Fit( 0 ), Analysis of Variance( 0 ),
		Parameter Estimates( 0 ), Lack of Fit( 0 ), Scaled Estimates( 0 ),
		Plot Actual by Predicted( 0 ), Plot Residual by Predicted( 0 ),
		Plot Studentized Residuals( 0 ), Plot Effect Leverage( 0 ),
		Plot Residual by Normal Quantiles( 0 ), Box Cox Y Transformation( 0 )}
	),
	SendToReport(
		Dispatch(
			{"Response contrast_100cm", "Whole Model"},
			"Summary of Fit",
			OutlineBox,
			{Close( 1 )}
		),
		Dispatch(
			{"Response contrast_100cm", "Whole Model"},
			"Analysis of Variance",
			OutlineBox,
			{Close( 1 )}
		),
		Dispatch(
			{"Response contrast_100cm", "Whole Model"},
			"Parameter Estimates",
			OutlineBox,
			{Close( 1 )}
		),
		Dispatch(
			{"Response contrast_100cm"},
			"Response Surface",
			OutlineBox,
			{Close( 0 )}
		)
	)
)

Here is the part of the output that finds the critical value.

Capture.JPG

Dan Obermiller

View solution in original post

Highlighted

Re: Finding vertex of bivariate graph

As I have posted many times, the Send to Report() and Dispatch() arguments are intended for JMP to save customization. They are not intended for users. Of course, you can use them. But there are better ways.

 

It appears that you want to add the answer to the plot. This example illustrates how to do that.

 

Names Default To Here( 1 );

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

// fit quadratic polynomial interpolating function
biv = dt << Bivariate(
	Y( :weight ),
	X( :height ),
	Fit Line
);

// get reference to report layer
rbiv = biv << Report;

// get parameter estimates
parm = rbiv["Parameter Estimates"][Number Col Box( 1 )] << Get As Matrix;

// compute x intercept
ans = -parm[1] / parm[2];

rbiv[FrameBox(1)] << Add Graphics Script(
	Text( { 52.5, 160 }, "X intercept is " || Char( ans ) )
);
Learn it once, use it forever!

View solution in original post

8 REPLIES 8
Highlighted

Re: Finding vertex of bivariate graph

JMP does not have a solver as such. But you are fitting a quadratic polynomial interpolating function so you only need to set the first derivative with respect to Offset_Z equal to zero and solve for Offset_Z. I assume that by "vertex" you mean the minimum or maximum of the function.

 

Names Default To Here( 1 );

// example of data
dt = Current Data Table();

// fit quadratic polynomial interpolating function
biv = dt << Bivariate(
	Y( :contrast_100cm ),
	X( :Offset_Z ),
	Fit Polynomial( 2, {Line Color( {212, 73, 88} )} ),
	Where( :site == "Para#4" )
);

// get reference to report layer
rbiv = biv << Report;

// get parameter estimates
parms = rbiv[NumberColBox( 1 )] << Get As Matrix;

// compute extremum
extremum = -parms[2] / (2*parms[3]);

Show( parms, extremum );
Learn it once, use it forever!
Highlighted
Brad_Park
Level I

Re: Finding vertex of bivariate graph

Thank you for kind answer.

 

Because you explained each code by remark, It was easy to understand.

 

I was trying to modify your code to find out the x intercept in linear function.

 

but nothing was come out.

 

Actually I really don't know how "show function" works.

 

Could you please help me to solve this?

 

Thank you

Highlighted

Re: Finding vertex of bivariate graph

The Show() function writes text based on its arguments to the Log window, which is not open by default. Select View > Log if you are using Windows or Window > Log if you are using Macintosh.

 

I modified the script to estimate the x-intercept, assuming that it exists in the real plane. It is just the quadratic solution for the roots.

 

Names Default To Here( 1 );

// example of data
x = -5::5;
dt = New Table( "Non-Linear Data",
	New Column( "X", Numeric, Continuous, Values( x ) ),
	New Column( "Y", Numeric, Continuous, Values( x^2 - x - 12 ) )
);

// fit quadratic polynomial interpolating function
biv = dt << Bivariate(
	Y( :Y ),
	X( :X ),
	Fit Polynomial( 2 )
);

// get reference to report layer
rbiv = biv << Report;

// get parameter estimates
parm = rbiv["Parameter Estimates"][NumberColBox( 1 )] << Get As Matrix;

// compute x intercept
ans = parm[2]^2 - 4*parm[3]*parm[1];
x intercepts = If( ans > 0,
	(-parm[2] + { -1, 1 } * Sqrt( ans )) / (2*parm[3]);
);

Show( parm, x intercepts );
Learn it once, use it forever!
Highlighted
Brad_Park
Level I

Re: Finding vertex of bivariate graph

Hi Makrbailey,

 

Can I ask for more things?

 

I slightly changed the script to solve linear function and it worked properly.

 

however, I found myself that checking the result through log is not convenient as much as checking through tree-box.

 

as for as I know, dispatch function is the right one to make a tree-box to report. 

 

so I  changed the script as follows. however, it's not working. 

 

and I want to get the ans for each site (there's 4 sites). so I've tried to do it but it also didn't work. 

 

Could you please give me your hand to solve it

 

Thank you so much

 

-> My purpose 

1. add ans of each site.

2. add ans to report. 

 

-> My script

 

Names Default To Here( 1 );

dt = Current Data Table();

// fit quadratic polynomial interpolating function
biv = dt << Bivariate(
Y( :CALU_CALU_intr_cy ),
X( :OC offset Y um ),
Fit Line( {Line Color( {212, 73, 88} )} ),
by(:site),
);

// get reference to report layer
rbiv = biv << Report;

// get parameter estimates
parm = rbiv["Parameter Estimates"][Number Col Box( 1 )] << Get As Matrix;

// compute x intercept
ans = -parm[1] / parm[2];

rbiv<<dispatch(
{"ans"},
"ans",
framebox,
{marker size(3)}
);

 

Thank you

 

 

 

 

 
Highlighted

Re: Finding vertex of bivariate graph

As I have posted many times, the Send to Report() and Dispatch() arguments are intended for JMP to save customization. They are not intended for users. Of course, you can use them. But there are better ways.

 

It appears that you want to add the answer to the plot. This example illustrates how to do that.

 

Names Default To Here( 1 );

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

// fit quadratic polynomial interpolating function
biv = dt << Bivariate(
	Y( :weight ),
	X( :height ),
	Fit Line
);

// get reference to report layer
rbiv = biv << Report;

// get parameter estimates
parm = rbiv["Parameter Estimates"][Number Col Box( 1 )] << Get As Matrix;

// compute x intercept
ans = -parm[1] / parm[2];

rbiv[FrameBox(1)] << Add Graphics Script(
	Text( { 52.5, 160 }, "X intercept is " || Char( ans ) )
);
Learn it once, use it forever!

View solution in original post

Highlighted
Brad_Park
Level I

Re: Finding vertex of bivariate graph

It worked
Thank you so much
Highlighted

Re: Finding vertex of bivariate graph

Or, another approach is to use Fit Model, use the Response Surface macro so that JMP sets the response surface attribute. Then you will get a response surface output that solves for the critical values.

 

I had JMP create this script with some data that I made up.

Fit Model(
	Y( :contrast_100cm ),
	Effects( :Offset_Z & RS, :Offset_Z * :Offset_Z ),
	Personality( "Standard Least Squares" ),
	Emphasis( "Effect Leverage" ),
	Run(
		:contrast_100cm << {Summary of Fit( 0 ), Analysis of Variance( 0 ),
		Parameter Estimates( 0 ), Lack of Fit( 0 ), Scaled Estimates( 0 ),
		Plot Actual by Predicted( 0 ), Plot Residual by Predicted( 0 ),
		Plot Studentized Residuals( 0 ), Plot Effect Leverage( 0 ),
		Plot Residual by Normal Quantiles( 0 ), Box Cox Y Transformation( 0 )}
	),
	SendToReport(
		Dispatch(
			{"Response contrast_100cm", "Whole Model"},
			"Summary of Fit",
			OutlineBox,
			{Close( 1 )}
		),
		Dispatch(
			{"Response contrast_100cm", "Whole Model"},
			"Analysis of Variance",
			OutlineBox,
			{Close( 1 )}
		),
		Dispatch(
			{"Response contrast_100cm", "Whole Model"},
			"Parameter Estimates",
			OutlineBox,
			{Close( 1 )}
		),
		Dispatch(
			{"Response contrast_100cm"},
			"Response Surface",
			OutlineBox,
			{Close( 0 )}
		)
	)
)

Here is the part of the output that finds the critical value.

Capture.JPG

Dan Obermiller

View solution in original post

Highlighted
Brad_Park
Level I

Re: Finding vertex of bivariate graph

Thank you for reply.

 

I tested the script and found that this is exactly what I was looking for. 

 

(Even though I didn't understand the whole code )

 

but I found that the Offset_Z value which is calculated by response surface is slightly different from my manual calculation (by differential)

the difference was under 0.0003 so it was no big deal 

 

Thank you again for your help 

Article Labels