cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
ram
ram
Level IV

Adding a regression line with known slope in Graph Builder

Hi All,

I like to use Graph builder for  X-Y correlation charts instead of using Bivariate. Does someone knows weather in graph builder we can do a regression line or fit line with known slope?  can user define the slope of fit? i want to use graph builder since i want to have multiple charts separated in GX and GY groupes.

 

Thank you very much for your inputs.

Ram

1 ACCEPTED SOLUTION

Accepted Solutions
julian
Community Manager Community Manager

Re: JMP Graph Builder regression line with known slope (slope user defined)

Hi @ram,
Yes, you can do this with a custom graphics script. In graph builder, or any graph for that matter, right click > customize. Then, click the plus sign to add a new graphics script. There is a template for a y function that will work for you, and you can customize/change the slope (or anything else you like) about the y function. Below is a brief video showing that. Is this what you were looking for?

 

I hope this helps!

Julian

View solution in original post

6 REPLIES 6
txnelson
Super User

Re: JMP Graph Builder regression line with known slope (slope user defined)

Line of Fit is one of the items that can be placed onto a Graph Builder graph

graph builder line of fit.PNG

Jim
ram
ram
Level IV

Re: JMP Graph Builder regression line with known slope (slope user defined)

How can i adjust slope or how i can change the slope of fit line.
txnelson
Super User

Re: JMP Graph Builder regression line with known slope (slope user defined)

While there is nothing as straight forward as in the Bivariate graph, for adding functions, you can use the Customize capability in Graph Builder, and get any kind of function displayed you desiregraph builder line of fit special.PNG

Here is a very simple linear equasion added to Graph Builder using the following addition to the Customize ability 

Pen Color( "red" );
Pen Size( 3 );
intercept = 50;
beta = .2;
Y Function( intercept + beta * x, x );

graph builder simple line.PNG

Jim
julian
Community Manager Community Manager

Re: JMP Graph Builder regression line with known slope (slope user defined)

Hi @ram,
Yes, you can do this with a custom graphics script. In graph builder, or any graph for that matter, right click > customize. Then, click the plus sign to add a new graphics script. There is a template for a y function that will work for you, and you can customize/change the slope (or anything else you like) about the y function. Below is a brief video showing that. Is this what you were looking for?

 

I hope this helps!

Julian

Core
Level I

Re: JMP Graph Builder regression line with known slope (slope user defined)

How about the situation where I know only the intercept but not the slope? 

ian_jmp
Staff

Re: JMP Graph Builder regression line with known slope (slope user defined)

You could use 'Fit Special' in 'Fit Y By X', then the approach of @txnelson:

NamesDefaultToHere(1);

// Example data
dt = Open("$SAMPLE_DATA/Big Class.jmp");
// Plot data
biv = dt << Bivariate(Y( :height ), X( :weight ), Invisible);
// Fit Special
myIntercept = 0;
biv << Fit Special( Intercept( myIntercept ));
// Save formula to table
biv << (Curve[1] << savePredicteds);
// Close Bivariate
Report(biv) << closeWindow;
// Get the formula
form = Column(dt, "Predicted Height") << getFormula;
// Express the formula as a function of x so 'YFunction()' will work
SubstituteInto(form, Expr(:weight), Expr(x));
// Use Graph Builder
gb = dt << Graph Builder(
						Show Control Panel( 0 ),
						Variables( X( :weight ), Y( :height ) ),
						Elements( Points( X, Y, Legend( 3 ) ) )
					);
// Add the graphics script
gbRep = Report(gb);
addScript = Expr(gbRep[FrameBox(1)] << addGraphicsScript(PenColor("Red"); YFunction(formTBD, x)));
SubstituteInto(addScript, Expr(formTBD), NameExpr(form));
addScript;