cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar

Build Error Bars with 3 standard deviations from the mean using 'Graph Builder'

How do I build a line graph with a 3 standard deviation from mean instead of 1 standard deviation?

 

 

 

4 REPLIES 4
txnelson
Super User

Re: Build Error Bars with 3 standard deviations from the mean using 'Graph Builder'

The only way I know  new how to do this is by adding in the error bars using the graphic primitives available in JSL. 

@Florian_Vogt has provided a pointer to how to do the custom error bars in his response.  His response is the correct way to handle the issue.

 Below is a very simple example, using very basic structured code to illustrate what is going on how to add graphic elements to an existing graph.  It is a good technique to know about, but not the correct answer to this Discussion Question unless you are using JMP 13 or earlier.

txnelson_0-1705806766207.png

Names Default To Here( 1 );
dt = 
// Open Data Table: Big Class.jmp
// → Data Table( "Big Class" )
Open( "$SAMPLE_DATA/Big Class.jmp" );
dt:age << modeling type( continuous );

gb = Graph Builder(
	Size( 528, 450 ),
	Show Control Panel( 0 ),
	Variables( X( :age ), Y( :height ), Overlay( :sex ) ),
	Elements( Line( X, Y, Legend( 4 ), Error Interval( "None" ) ) )
);
dtSum = dt << Summary(
	invisible,
	Group( :sex, :age ),
	Mean( :height ),
	Std Dev( :height ),
	Freq( "None" ),
	Weight( "None" ),
	statistics column name format( "stat" ),
	Link to original data table( 0 )
);
sexList = dtSum:sex << get values;
ageMat = dtSum:age << get values;
meanMat = dtSum:Mean << get values;
stdMat = dtSum:Std Dev << get values;

close( dtSum, nosave );

gbf = Report( gb )[FrameBox( 1 )];

gbf << add graphics script(
	
ymin=999999999999;
ymax=-999999999999;
	ls = {0, 0};
	le = {0, 0};
	For Each( {row, i }, ageMat,
		If( sexList[i] == "F",
			Pen Color( "Blue" ),
			Pen Color( "red" )
		);
		Pen Size( 1 );
		ls[1] = ageMat[i];
		ls[2] = meanMat[i] - 3 * stdMat[i];
		if(ls[2]<ymin, ymin=ls[2]);
		le[1] = agemat[i];
		le[2] = meanMat[i] + 3 * StdMat[i];
		if(le[2]>ymax, ymax=le[2]);
		Line( ls, le );
		// bottom line
		ls[1] = ageMat[i] - .1;
		le[1] = ageMat[i] + .1;
		ls[2] = meanMat[i] - 3 * stdMat[i];
		le[2] = meanMat[i] - 3 * StdMat[i];
		Line( ls, le );
		// bottom line
		ls[2] = meanMat[i] + 3 * StdMat[i];
		le[2] = meanMat[i] + 3 * StdMat[i];
		Line( ls, le );
	);
)
;
// Set the Y axis to max and min range
report(gb)[AxisBox(2)] << Max( ymax ) << Min(ymin);

 

Jim

Re: Build Error Bars with 3 standard deviations from the mean using 'Graph Builder'

Hi @PowerPlatypus37 ,

 

you should be able to get this by manually calculating the value you'd like to have as error bar range.

 

To do so, use column formulas and the "Group by" function, in order to calculate the respective ranges.

Then in Graph Builder, you can build the graph first. And then select the error bar and drag the columns containing the values of the range into the "interval" drop zone on the right side. (see here: https://www.jmp.com/support/help/en/17.2/index.shtml#page/jmp/graph-zones.shtml#)

 

Florian_Vogt_0-1705915342617.png

(Note I haven't calculated different values for the error bars in this example = they are the same width here).

 

Hope this helps!

 

Best

Florian

 

txnelson
Super User

Re: Build Error Bars with 3 standard deviations from the mean using 'Graph Builder'

I learn something new about JMP almost every day. Thanks @Florian_Vogt 

Jim

Re: Build Error Bars with 3 standard deviations from the mean using 'Graph Builder'

I am very honored YOU say that @txnelson  - has only taken 4 years