cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Register to attend Discovery Summit 2025 Online: Early Users Edition, Sept. 24-25.
  • New JMP features coming to desktops everywhere this September. Sign up to learn more at jmp.com/launch.
Choose Language Hide Translation Bar
lala
This widget could not be displayed.
" alt = "Level IX"/> lala
Level IX

How can show the slope in the graph?

Thanks!

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
Graph Builder(
	Variables( X( Transform Column( "rows", Formula( Row() ) ) ), Y( :height ) ),
	Elements( Points( X, Y, Legend( 3 ) ), Line Of Fit( X, Y, Legend( 5 ) ) )
);

2024-07-06_10-31-27.png

3 REPLIES 3
jthi
Super User

Re: How can show the slope in the graph?

What do you mean by slope in this case and where you wish to see it? You can for example enable equation for line of fit

jthi_0-1720243785600.png

 

-Jarmo
lala
This widget could not be displayed.
" alt = "Level IX"/> lala
Level IX

Re: How can show the slope in the graph?

Thanks!

  • How is this value obtained in JSL?

0.2326

2024-07-06_15-29-00.png

jthi
Super User

Re: How can show the slope in the graph?

If you just need that value I would use Fit Y by X platform or Linear Regression matrix function

Names Default To Here(1);

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

rows = (1::N Rows(dt))`;
ys = dt[0, "height"];

{Estimates, Std_Error, Diagnostics} = Linear Regression(ys, rows);

slope = Estimates[2];

 

Edit: Added other options

View more...
Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp", Invisible);
dt << New Column("R", Numeric, Continuous, Formula(Row()));


// Linear Regression()
{Estimates, Std_Error, Diagnostics} = Linear Regression(dt[0, "height"], dt[0, "R"],);
// lr_eq = Eval Insert("height = ^Estimates[1]^ + ^Estimates[2]^ * R");
lr_s1 = Estimates[2];


// Bivariate + Fit Line
biv = dt << Bivariate(Y(:height), X(:R), << Fit Line, Invisible);
biv_eq = Report(biv)[Outline Box("Linear Fit"), Text Edit Box(1)] << get text;
biv << close window;
biv_s1 = Regex(biv_eq, "\s([0-9\.]+)*\D+$", "\1");
//biv_s2 = Word(-2, eq, " +*");


// Graph Builder + Line Of Fit + Equation(1)
gb = dt << Graph Builder(
	Size(525, 454),
	Show Control Panel(0),
	Variables(X(:R), Y(:height)),
	Elements(Points(X, Y, Legend(3)), Line Of Fit(X, Y, Legend(5), Equation(1))),
	Invisible
);
tseg = Report(gb)[FrameBox(1)] << Find Seg(Text Seg(1));
gb_eq = tseg << get text;
gb << Close Window;
gb_s1 = Regex(gb_eq, "\s([0-9\.]+)*\D+$", "\1");
//gb_s2 = Word(-2, eq, " +*");

Close(dt, no save);
Show(lr_s1, biv_s1, gb_s1);
-Jarmo

Recommended Articles