cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
Choose Language Hide Translation Bar
Juli
Level III

Reporting of data from LSMeans Differences Student's t

Hi all,

I am trying to make a report with specific data from the table of LSMeans Differences Student's t:

Juli_0-1731921303275.png

I would like a table with one of the formats as below: 

Juli_1-1731921761984.png

Juli_0-1731923239812.png

 

 

Sadly, I cannot get it to print correctly for the mean and it cannot take data from the bigger table. I get the below

Juli_3-1731922050015.png

 

I have tried the following code, where I have altered the '17' to numbers from 1-30 and nothing works - 17 is for a different outline box:

 

 

sd = Open( "test_table.jmp" );

Fitmod = Fit Model(
Y( :"Test value"n ),
Effects( :Person ),
Random Effects( :Day[:Person] ),
NoBounds( 0 ),
Personality( "Standard Least Squares" ),
Method( "REML" ),
Emphasis( "Effect Leverage" ),
Run(
:"Test value"n << {Summary of Fit( 1 ),
Analysis of Variance( 0 ), Parameter Estimates( 1 ), Scaled Estimates( 0 ),
Plot Actual by Predicted( 1 ), Plot Regression( 0 ),
Plot Residual by Predicted( 1 ), Plot Studentized Residuals( 0 ),
Plot Effect Leverage( 1 ), Plot Residual by Normal Quantiles( 0 ),
{:Person << {LSMeans Student's t( 0.05 )}}}
),
Where( :ID == "A1" ),
SendToReport(
Dispatch(
{"Test value ID=A1"},
"Whole Model",
OutlineBox,
{Close( 1 )}
),
Dispatch(
{"Test value ID=A1", "Person"},
"Leverage Plot",
OutlineBox,
{Close( 1 )}
)
)
);

report(Fitmod) [Outline Box( 2 )] << Close( 0 );
reportFitmod = Fitmod << Report;

sumfit = reportFitmod[Outline Box( 17 )][Number Col Box( 1 )] << Get as Matrix; meandiff = sumfit[1]; lowerCL = sumfit[3]; upperCL = sumfit[4];

term = reportFitmod[Outline Box( 13 )][String Col Box( 1 )] << Get();

est = reportFitmod[Outline Box( 13 )][Number Col Box( 1 )] << Get as Matrix;

dvalues = [];
dvalues = meandiff |/ lowerCL |/ upperCL ;
sfactor = term[2];

dlg = New Window( "Custom Report",
Outline Box( "Selected Values",
Lineup Box( N Col( 2 ),
Text Box( "Factor of Interest: " ),
Text Box( sfactor ), ),
tb = Table Box(

String Col Box( " ",
{"Mean difference: ", "Upper limit: ", "Lower limit: "}
),
Spacer Box( Size( 30, 30 ) ),
,
Spacer Box( Size( 0, 30 ) ),
,
Table Box(
CloneTerm,
Spacer Box( Size( 10, 0 ) ),
,
Number Col Box( "Estimate", est ),
Spacer Box( Size( 10, 0 ) ),
,
Number Col Box( "Mean difference", meandiff)
)
)
);

tb << Set Shade Headings( 0 ); // Turn off shaded table headings.
tb << Set Heading Column Borders( 0 ); // Turn off table column borders.

 

 

How do you report the data from the bigger table?

 

Best regards

 

 

 

 

Best regards,
Julie
26 REPLIES 26
txnelson
Super User

Re: Reporting of data from LSMeans Differences Student's t

You can change the value of the report output by adjusting the Display Tree objects.

txnelson_0-1736512595784.png

By adding

		report(fm)[OutlineBox(1)]<<set title(
			report(fm)[OutlineBox(1)]<<get title || ", ID=" || BG);

prior to 

// Save the pointer to the results in the Fitmod list
		Insert Into( Fitmod, Fm );

it will change the title to the value you want it to be

Jim
Juli
Level III

Re: Reporting of data from LSMeans Differences Student's t

Dear Jim,

 

Thank you so much for all your help! I truly appreciate it and it has been an immense learning for me as well. The script is now fully functional and can be used with lots of datasets. 

 

Best regards,

Julie

Best regards,
Julie
Juli
Level III

Re: Reporting of data from LSMeans Differences Student's t

Dear Jim,

 

I have been using the script and then I noticed, when I print the data, then the Parameter list is not giving me all the different test value parameters, but only Test value 1:

Juli_0-1737444028655.png

I realize it is from the following part of the script:

// Get the Response variable name
	Insert Into( testValue, (Substr( (reportFitmod << topparent)[Outline Box( 1 )] << get title, 10 )) );

I have tried altering it, but it either still just prints the single parameter, give an error or prints something I have no clue where comes from. 

 

Best regards,
Julie

 

Best regards,
Julie
txnelson
Super User

Re: Reporting of data from LSMeans Differences Student's t

I can no longer reconstruct the complete script that you are using.  Please attach the complete script that you are using.

Jim
Juli
Level III

Re: Reporting of data from LSMeans Differences Student's t

Hi Jim,

 

I have attached a working data table and the script. 

 

BR/
Julie

Best regards,
Julie
txnelson
Super User

Re: Reporting of data from LSMeans Differences Student's t

I took a shortcut in solving the issue.  I added a JMP list called "titles" that is populated after each is run and immediately after the Outline Box() title is set.  I then just use the titles list in the Table Box() in your dlg section.

txnelson_0-1737464740337.png

Names Default To Here( 1 ); // will ignore normal JSL naming
sd = currentdatatable(); // call upon open data table

// Define that Fitmod is empty. We will fill this with our information in the loop 
Fitmod = {}; 

// Determine the levels in the ID column
summarize( sd, ByGroups = By( :Batch ) ); 

// Determine the result columns 
colList = sd << Get Column Names( Continuous, String );
sum = 0; // Prepare getting the total number of result columns. Will be updated in the loop 
titles = {};
// Loop across each level of Batch 
nw_means = New Window("My Report", 
	For( i = 1, i <= Nitems( colList ), i++,
		For Each( {BG, group}, ByGroups,
			Fm = Fit Model(
				Y( colList[i] ),
				Effects( :Laboratory ),
				Random Effects( :Day[:Laboratory] ),
				NoBounds( 0 ),
				Personality( "Standard Least Squares" ),
				Method( "REML" ),
				Emphasis( "Effect Leverage" ),
				Run(
					colList[i] << {Summary of Fit( 1 ), Analysis of Variance( 0 ),
					Parameter Estimates( 1 ), Scaled Estimates( 0 ), Plot Actual by Predicted( 1 ),
					Plot Regression( 0 ), Plot Residual by Predicted( 1 ),
					Plot Studentized Residuals( 0 ), Plot Effect Leverage( 1 ),
					Plot Residual by Normal Quantiles( 0 ), {:Person << {LSMeans Student's t( 0.05 )}}}
				),
				Where( :Batch == ByGroups[group] ),
				SendToReport(
					Dispatch( {"" }, "Whole Model", OutlineBox, {Close( 1 )} ), 
					Dispatch(
						{"", "Laboratory"},
						"Leverage Plot",
						OutlineBox,
						{Close( 1 )}
					)
				)
			);
			report(fm)[OutlineBox(1)] << set title(report(fm)[OutlineBox(1)] << get title || ", ID=" || BG);

		// Save the pointer to the results in the Fitmod list
			Insert Into( Fitmod, Fm );
			insert into(titles, report(fm)[OutlineBox(1)] << get title);
		);
		sum = sum + 1
	);
);

// Set the lists for the storage of the data from the by groups
testValue = dif = sumfit1 = sumfit2 = {};


// Loop across each by group and gather the data
For Each( {rpt, group}, Fitmod, 
	// Point to the current report
	reportFitmod = Fitmod[group] << Report;
	
	// Get the means for the 2 levels
	sumfit = reportFitmod[Outline Box( "Least Squares Means Table" )][Number Col Box( 1 )] << Get as Matrix;
	Insert Into( sumfit1, sumfit[1] );
	Insert Into( sumfit2, sumfit[2] );
	term = reportFitmod[Outline Box( "Least Squares Means Table" )][String Col Box( 1 )] << Get();
	
	// Get By Group column
	whereCol = Word( 2, ((reportFitmod << parent)[Text Box( 1 )]) << get text, ":=)" );
		
	// Get data from CrossTab table
	crossTab = reportFitmod[Outline Box( "LSMeans Differences Student's t" )][CrosstabBox( 1 )] << get as matrix;
	meandiff = Round( crossTab[1, 2] , 4 );
	lowerCL = Round( crossTab[3, 2] , 3 );
	upperCL = Round( crossTab[4, 2] , 3 );
	
	// Get the Response variable name
	Insert Into( testValue, (Substr( (reportFitmod << topparent)[Outline Box( 1 )] << get title, 10 )) );

	// Create the Difference in mean and CL string
	Insert Into( dif, Char( meandiff ) || " [" || Char( lowerCL ) || " ; " || Char( upperCL ) || "]" );
);


// Create the table
dlg = New Window( "Custom Report",
	Outline Box( "Selected Values",
		Lineup Box( N Col( 2 ), Text Box( "Factor of Interest: " ), Text Box( term[1] ) ),
		Spacer Box( size( 0, 10 ) ),
		tb = Table Box(
			String Col Box( "Paramenter", titles ),
			String Col Box( whereCol, repeat(ByGroups, sum) ),
			Number Col Box( "Mean, " || term[1], sumfit1 ),
			Number Col Box( "Mean, " || term[2], sumfit2 ),
			String Col Box( "Difference in mean and CI", dif )
			
		)
	)
);

tb << Set Shade Headings( 0 ); // Turn off shaded table headings.
tb << Set Column Borders( 1 ); // Turn off table column borders.
tb << Set row Borders( 1 );
tb << border( 1 );

Jim
Juli
Level III

Re: Reporting of data from LSMeans Differences Student's t

Perfection! Thanks

Best regards,
Julie