Choose Language Hide Translation Bar

## 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
Highlighted

## 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 in My Videos)

6 REPLIES 6
Highlighted

## 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 Jim
Highlighted

## 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.
Highlighted

## 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 desire 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 );`````` Jim
Highlighted

## 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 in My Videos)

Highlighted

## 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?

Highlighted

## 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 << 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 ) ) )
);