cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
ih
Super User (Alumni) ih
Super User (Alumni)

Compare means test: graph probability by difference in means

Is there an interactive method in JMP to determine whether the means of two populations differ by at least a certain amount, or more generally to graph a p value or probability by the minimum difference in means?

 

Example: in the big class data set, show the likelihood that females are shorter than meals by at least X, similar to the table and chart below.

 

ih_0-1632240007194.png

This may or may not be the best way to quantify this, but here is a script to create the above table:

 

View more...
Names default to here(1);

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

// Column to adjust the difference in means between levels
nc = dt << New Column("height differenced", Numeric, "Continuous", Format("Best", 12), Formula(Parameter({b0 = 5}, If(:sex == "F", :height + b0, :height))));

distances = index(-2,7,incr=.5);
pvalless = {};
pvalmore = {};
for(d=1, d<= n items(distances), d++,
	dist = distances[d];
	Eval( Eval Expr( nc << Set Formula( Parameter({b0 = expr( dist ) }, If(:sex == "F", :height + b0, :height))) ) );
	ow = dt << Oneway(
		Y( nc ),
		X( :sex ),
		Means( 1 ),
		t Test( 1 ),
		Mean Diamonds( 1 ),
		SendToReport( Dispatch( {}, "t Test", OutlineBox, {Close( 1 )} ) )
	);
	
	//Extract the prob
	pvalless[d] = ((ow << XPath("//OutlineBox[text()='Pooled t Test']"))[1][NumberColBox(4)] << get as matrix)[2];
	pvalmore[d] = ((ow << XPath("//OutlineBox[text()='Pooled t Test']"))[1][NumberColBox(4)] << get as matrix)[3];
	
	ow << close window;
);


dtSum = New Table( "Results",
	Add Rows( n items(distances) ),
	New Column( "Distance",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( distances )
	),
	New Column( "pvalueless",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( pvalless )
	),
	New Column( "pvaluemore",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( pvalmore )
	)
);

gb = dtSum << Graph Builder(
	Size( 876, 379 ),
	Show Control Panel( 0 ),
	Variables( X( :Distance ), Y( :pvalueless ) ),
	Elements( Points( X, Y, Legend( 3 ) ), Line( X, Y, Legend( 5 ) ) ),
	SendToReport(
		Dispatch(
			{},
			"pvalueless",
			ScaleBox,
			{Add Ref Line( 0.05, "Solid", "Black", ".05", 1 )}
		),
		Dispatch(
			{},
			"400",
			ScaleBox,
			{Legend Model( 3, Base( -1, 0, 0, Item ID( "pvaluemore", 1 ) ) )}
		),
		Dispatch(
			{},
			"graph title",
			TextEditBox,
			{Set Text(
				"Likelihood of average heights of females being shorter than males by different amounts"
			)}
		),
		Dispatch(
			{},
			"X title",
			TextEditBox,
			{Set Text( "Minimum Distance Between Average Heights" )}
		),
		Dispatch( {}, "Y title", TextEditBox, {Set Text( "p value" )} ),
		Dispatch(
			{},
			"Graph Builder",
			FrameBox,
			{Add Line Annotation(
				Line( {233, 222}, {277, 286} ),
				Color( "Magenta" ),
				Thick( 1 ),
				Point to( 1 )
			), Add Text Annotation(
				Text(
					"6% chance that females are not 1 or more inches shorter than males"
				),
				Fixed Size( 0 ),
				Text Box( {43, 175, 332, 237} ),
				Filled( 0 ),
				Text Color( "Medium Dark Magenta" ),
				"Font"("Segoe UI", 12, "Bold")
			), Add Text Annotation(
				Text(
					"34% likelihood that females are not 2.5 or more inches shorter than males"
				),
				Fixed Size( 0 ),
				Text Box( {142, 101, 454, 163} ),
				Filled( 0 ),
				Text Color( "Medium Dark Magenta" ),
				Background Color( "White" ),
				"Font"("Segoe UI", 12, "Bold")
			), Add Line Annotation(
				Line( {353, 149}, {409, 203} ),
				Color( "Magenta" ),
				Thick( 1 ),
				Point to( 1 )
			), Add Text Annotation(
				Text(
					"Highly unlikely that females are 
6 or more inches shorter than males"
				),
				Fixed Size( 0 ),
				Text Box( {537, 98, 826, 152} ),
				Filled( 0 )
			), Add Line Annotation(
				Line( {678, 93}, {711, 27} ),
				Color( "Magenta" ),
				Thick( 1 ),
				Point to( 1 )
			)}
		)
	)
);

 Another way to calculate this in JMP 17 is using the superiority test:

View more...
Names default to here(1);

dt=open("$Sample_Data/Big class.jmp");
obj=Oneway( Y( :height ), X( :sex ));

//add an equivalence test for each distance and get p values for all
distances =index(0.5,7,0.5);
for each( {d}, distances,  obj << Equivalence Tests( d, 0.05, "Pooled Variance", "Noninferiority Greater" ));
pvalboxes = (obj << XPath("//NumberColBox[NumberColBoxHeader[contains(text(),'Lower Bound p-Value')]][NumberColBoxItem]"));

//convert p values to match other graph (maybe pulled wrong value from test or used wrong test..)
pvalmore = transform each( {b}, pvalboxes, b[1]);

dtSum = New Table( "Results Superiority Tests",
	Add Rows( n items(distances) ),
	New Column( "Distance",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( distances )
	),
	New Column( "pvaluemore",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( pvalmore )
	),
	New Column( "pvalueless",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula( 1 - :pvaluemore )
	)
);

gb = dtSum << Graph Builder(
	Size( 876, 379 ),
	Show Control Panel( 0 ),
	Variables( X( :Distance ), Y( :pvalueless ) ),
	Elements( Points( X, Y, Legend( 3 ) ), Line( X, Y, Legend( 5 ) ) ),
	SendToReport(
		Dispatch(
			{},
			"pvalueless",
			ScaleBox,
			{Add Ref Line( 0.05, "Solid", "Black", ".05", 1 )}
		),
		Dispatch(
			{},
			"400",
			ScaleBox,
			{Legend Model( 3, Base( -1, 0, 0, Item ID( "pvaluemore", 1 ) ) )}
		),
		Dispatch(
			{},
			"graph title",
			TextEditBox,
			{Set Text(
				"Likelihood of average heights of females being shorter than males by different amounts"
			)}
		),
		Dispatch(
			{},
			"X title",
			TextEditBox,
			{Set Text( "Minimum Distance Between Average Heights" )}
		),
		Dispatch( {}, "Y title", TextEditBox, {Set Text( "p value" )} )
	)
);
1 ACCEPTED SOLUTION

Accepted Solutions
ih
Super User (Alumni) ih
Super User (Alumni)

Re: Compare means test: graph probability by difference in means

It does not look like this is possible today, if anyone else is interested in producing similar graphs I added a wish-list item over here:

 

Add superiority test to oneway analyses indicating the probability of being superior by different ma... 

View solution in original post

1 REPLY 1
ih
Super User (Alumni) ih
Super User (Alumni)

Re: Compare means test: graph probability by difference in means

It does not look like this is possible today, if anyone else is interested in producing similar graphs I added a wish-list item over here:

 

Add superiority test to oneway analyses indicating the probability of being superior by different ma...