cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
aliegner1
Level IV

scripting t-test: picking favorite features from several ANOVA/t-tests; 2-sample vs 3+-sample?

So curious how to make this happen. I've got a long list of charts, some with 2 chambers, some with 3+ chambers. I'd like to script a t-test kind of script to standardize the output. Any advice? There's parts and pieces I like from several different options.

 

Goal:

- output a chart w/ student's t Circle Plots

- output a 'summary report' with sample count, mean, stDev

- output a p-value for the whole chart (Means/Anova/Pooled t")

- (nice to have: pair-wise p-value and labeling, but not that important).

 

I've noticed that the options and outputs are quite different if I have a 2-sample chart vs a 3+sample chart.

 

Any advice how to script this?

 

 

examples

 

aliegner1_0-1622568987779.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: scripting t-test: picking favorite features from several ANOVA/t-tests; 2-sample vs 3+-sample?

If you have an easy way to check the number of levels, you can use an IF() to check and bypass the statement.  Or, you can use a TRY() function to keep it from ending when the statement fails

try(report(ow[i])["Oneway Anova"]["Pooled t Test"] << visibility("Collapse"));
Jim

View solution in original post

4 REPLIES 4
aliegner1
Level IV

Re: scripting t-test: picking favorite features from several ANOVA/t-tests; 2-sample vs 3+-sample?

Edit/Update.

So I setup some JSL and edited as much as I can figure, but still hitting a roadblock. I can't seem to collapse/hide Student t Test subwindows.

 

Is there a BKM for simply outputting the YbyX chart, circles, histogram on upper level and then "Analysis of Variance, Summary, and Ordered Difference Report on lower level?

 

 

 

aliegner1_0-1622588024029.png

 

obj = Oneway(
	Y( :MEAN ),
	X( :TOOL_PROCESS_CHAMBER ),
	By(, :CHART_ID),
	
	Means( 1 ), //means/anova/pooled t
	Each Pair( //student's t-Test
		1,
		Difference Matrix( 0 ),
		Confidence Quantile( 0 ),
		LSD Threshold Matrix( 0 ),
		Connecting Letters Report( 0 ),
		Ordered Differences Report( 1 ),
		Detailed Comparisons Report( 0 )
	),
	
	//t Test ( 1), //standard t-test, only works on 2chamber charts
	//Means and Std Dev( 1 ), //extra table for count, Mean, StDev
	//Histograms( 1 ), // move this to the end so control position? obj << histograms(1);

	//Formatting
		Points Jittered( 1 ),
		Box Plots( 1 ),
		Mean Diamonds( 0 ),
		Mean Error Bars( 0 ),
		Std Dev Lines( 0 ),
		Grand Mean( 0 ),

	SendToReport(
		//x-axis formatting
		Dispatch(
			{},
			"2",
			ScaleBox,
			{Label Row(
				{Label Orientation( "Angled" ), Lower Frame( 1 ),
				Show Major Grid( 1 ), Tick Mark Style( "Long Divider" )}
				)
			}
		),
		//row legend by chamber
		Dispatch(
			{},
			"Oneway Plot",
			FrameBox,
			{Marker Size( 6 ), Marker Drawing Mode( "Normal" ),
			Row Legend(
				:TOOL_PROCESS_CHAMBER,
				Color( 1 ),
				Color Theme( "JMP Default" ),
				Marker( 0 ),
				Marker Theme( "" ),
				Continuous Scale( 0 ),
				Reverse Scale( 0 ),
				Excluded Rows( 0 )
				)
			}
		),
		//formatting the Summary table
		Dispatch({"Means and Std Deviations"},"",
			TableBox,
				{Set Column Borders( 1 ), 
				Set Row Borders( 1 ),
				Set Underline Headings( 1 ), 
				Set Shade Headings( 1 )}
		),
			Dispatch({"Means and Std Deviations"},"Mean",NumberColBox,{Set Format( "Fixed Dec", 9, 2 )}),
			Dispatch({"Means and Std Deviations"},"Std Dev",NumberColBox,{Set Format( "Fixed Dec", 9, 2 )}),
			Dispatch({"Means and Std Deviations"},"Std Err Mean",NumberColBox,{Visibility( "Collapse" )}),
			Dispatch({"Means and Std Deviations"},"Lower 95%",NumberColBox,{Visibility( "Collapse" )}),
			Dispatch({"Means and Std Deviations"},"Upper 95%",NumberColBox,{Visibility( "Collapse" )}),
		
		//formatting the "t Test"" tables
		Dispatch({"t Test"},"",
			TableBox,
				{Set Column Borders( 1 ), 
				Set Row Borders( 1 )}
		),
			Dispatch( {"t Test"}, "", StringColBox, {Visibility( "Collapse" )} ),
			Dispatch( {"t Test"}, "", ColStackBox, {Visibility( "Collapse" )} ),
		
		//formatting the "Each Pair, Student's t" tables
		Dispatch({"Means Comparisons", "Comparisons for each pair using Student's t","Ordered Differences Report"},"",
			TableBox,
				{Set Column Borders( 1 ), 
				Set Row Borders( 1 ),
				Set Underline Headings( 1 )}
		),
		Dispatch({"Means Comparisons", "Comparisons for each pair using Student's t","Ordered Differences Report"},"Difference",NumberColBox,{Set Format( "Fixed Dec", 9, 2 )}		),
		Dispatch({"Means Comparisons", "Comparisons for each pair using Student's t","Ordered Differences Report"},"Std Err Dif",NumberColBox,{Set Format( "Fixed Dec", 9, 2 )}),
		Dispatch({"Means Comparisons", "Comparisons for each pair using Student's t","Ordered Differences Report"},"Lower CL",NumberColBox,{Visibility( "Collapse" )}),
		Dispatch({"Means Comparisons", "Comparisons for each pair using Student's t","Ordered Differences Report"},"Upper CL",NumberColBox,{Visibility( "Collapse" )}),
		Dispatch({"Means Comparisons", "Comparisons for each pair using Student's t","Ordered Differences Report"},"~Difference",PlotColBox,{Visibility( "Collapse" )}),
		
		//formatting the "Means/Anova/Pooled t Test" tables
		Dispatch({"Oneway Anova", "Summary of Fit"},"",
			TableBox,
				{Set Column Borders( 1 ), 
				Set Row Borders( 1 )}
		),
		Dispatch({"Oneway Anova", "Pooled t Test"},"",StringColBox,{Visibility( "Collapse" )}),
		Dispatch({"Oneway Anova", "Pooled t Test"},"",ColStackBox,{Visibility( "Collapse" )}),
		Dispatch({"Oneway Anova", "Analysis of Variance"},"",
			TableBox,
				{Set Column Borders( 1 ), 
				Set Row Borders( 1 ),
				Set Underline Headings( 1 )}
		),
		Dispatch({"Oneway Anova", "Analysis of Variance"},"DF",NumberColBox,{Visibility( "Collapse" )}),
		Dispatch({"Oneway Anova", "Analysis of Variance"},"Sum of Squares",NumberColBox,{Visibility( "Collapse" )}),
		Dispatch({"Oneway Anova", "Analysis of Variance"},"Mean Square",NumberColBox,{Visibility( "Collapse" )}),
		Dispatch({"Oneway Anova", "Analysis of Variance"},"F Ratio",NumberColBox,{Visibility( "Collapse" )}),
		Dispatch({"Oneway Anova", "Means for Oneway Anova"},"",
			TableBox,
				{Set Column Borders( 1 ), 
				Set Row Borders( 1 ),
				Set Underline Headings( 1 )}
		),
		Dispatch({"Oneway Anova", "Means for Oneway Anova"},"Mean",NumberColBox,{Set Format( "Fixed Dec", 8, 2 )}),
		Dispatch({"Oneway Anova", "Means for Oneway Anova"},"Std Error",NumberColBox,{Set Format( "Fixed Dec", 7, 2 )}),
		Dispatch({"Oneway Anova", "Means for Oneway Anova"},"Lower 95%",NumberColBox,{Visibility( "Collapse" )}),
		Dispatch({"Oneway Anova", "Means for Oneway Anova"},"Upper 95%",NumberColBox,{Visibility( "Collapse" )})
	)
);
obj << histograms(1);
(current report() << xpath("//BoxPlotSeg")) << set line color(black); //sets boxplot to BLACK lines

 

txnelson
Super User

Re: scripting t-test: picking favorite features from several ANOVA/t-tests; 2-sample vs 3+-sample?

Because you are using a By() clause, the output report is actually a separate report for each level of the By().  Here is how I handle what you are asking for.  My example is probably not exactly what you want, but it should move you in the correct direction.

by.PNG

names default to here(1);
dt=open("$sample_data/big class.jmp");
//dt<<color by column(:sex);
ow = Oneway(
	Y( :height ),
	X( :sex ),
	by(:age),
	Box Plots( 1 ),Means( 1 ), //means/anova/pooled t
	Each Pair( //student's t-Test
		1,
		Difference Matrix( 0 ),
		Confidence Quantile( 0 ),
		LSD Threshold Matrix( 0 ),
		Connecting Letters Report( 0 ),
		Ordered Differences Report( 1 ),
		Detailed Comparisons Report( 0 )
	),
	Points Jittered( 1 ),
		Box Plots( 1 ),
		Mean Diamonds( 0 ),
		Mean Error Bars( 0 ),
		Std Dev Lines( 0 ),
		Grand Mean( 0 ),
		SendToReport(
		//x-axis formatting
		Dispatch(
			{},
			"2",
			ScaleBox,
			{Label Row(
				{Label Orientation( "Angled" ), Lower Frame( 1 ),
				Show Major Grid( 1 ), Tick Mark Style( "Long Divider" )}
				)
			}
		),
		//row legend by chamber
		Dispatch(
			{},
			"Oneway Plot",
			FrameBox,
			{Marker Size( 6 ), Marker Drawing Mode( "Normal" ),
			Row Legend(
				:TOOL_PROCESS_CHAMBER,
				Color( 1 ),
				Color Theme( "JMP Default" ),
				Marker( 0 ),
				Marker Theme( "" ),
				Continuous Scale( 0 ),
				Reverse Scale( 0 ),
				Excluded Rows( 0 )
				)
			}
		)
	));

ow << histograms(1);
For(i=1,i<=nitems(ow),i++,
	report(ow[i])["Oneway Anova"]["Summary of Fit"] << visibility("Collapse");
	report(ow[i])["Oneway Anova"]["Pooled t Test"] << visibility("Collapse");
	report(ow[i])["Oneway Anova"]["Means for Oneway Anova"] << visibility("Collapse");
	report(ow[i])["Means Comparisons"] << visibility("Collapse");
)

 

Jim
aliegner1
Level IV

Re: scripting t-test: picking favorite features from several ANOVA/t-tests; 2-sample vs 3+-sample?

Thank you. This is kinda working. One problem is that a graph with 3+ chambers does not have a Pooled t Test section, then it errors out and stops. 

 

How to move past to next row while still staying in its i iteration?

 

aliegner1_0-1622601524787.png

 

txnelson
Super User

Re: scripting t-test: picking favorite features from several ANOVA/t-tests; 2-sample vs 3+-sample?

If you have an easy way to check the number of levels, you can use an IF() to check and bypass the statement.  Or, you can use a TRY() function to keep it from ending when the statement fails

try(report(ow[i])["Oneway Anova"]["Pooled t Test"] << visibility("Collapse"));
Jim