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
Juli
Level II

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

 

 

 

 

21 REPLIES 21
Juli
Level II

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

Hi Jim,

 

Thank you so much!

 

Best regards,

Julie

Juli
Level II

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

Hi Jim,

 

I have an additional question. If I want to run the analysis with many test values, would I be able to either:

 

1. Make a loop with FitModel and then continue as in the script above?

2. Do the analysis separately where I get the report in one report, and then run a script which saves the data like the script above?

 

Or is there another way that I should try to look into?

 

Best regards,

Julie 

txnelson
Super User

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

Julie,

Either approach would probably work.

Making this decision seems to me to be an awfully big decision to make at the beginning.  I would first come up with what you want the final product to look like, and then take the script, and modify it to give you that result on just 2 test values.  That will give you both a little more information on what the approach should be, and also expose what areas in JSL that you need to learn more about, in order to expand the script to your final product.

Jim
Juli
Level II

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

Hi Jim,

 

Great to know that both approaches are possible to do in JSL.

 

Would it be possible to alter the code to also have Y( :"Test value"n ) to go through all the continuous columns? 

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

// Loop across each level of ID 
For Each( {BG, group}, ByGroups,
	Fm = 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 == ByGroups[group] ),
		SendToReport(
			Dispatch( {"Test value ID=A1"}, "Whole Model", OutlineBox, {Close( 1 )} ),
			Dispatch(
				{"Test value ID=A1", "Person"},
				"Leverage Plot",
				OutlineBox,
				{Close( 1 )}
			)
		)
	);

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

I have looked at many other loops and tried to alter it to the following:

Names Default To Here( 1 );
sd = Open( "test_table_002.jmp" );
Data Table( "test_table_002" );
Fitmod = {};

// Determine the levels in the ID column
summarize( sd, ByGroups = By( :ID ) );
colList = sd << Get Column Names( Continuous, String );

// Loop across each level of ID 
For Each( i = 1, i <= Nitems( colList ), i++,
	For Each( {BG, group}, ByGroups,
		Fm = Fit Model(
			Y( colList ),
			Effects( :Person ),
			Random Effects( :Day[:Person] ),
			NoBounds( 0 ),
			Personality( "Standard Least Squares" ),
			Method( "REML" ),
			Emphasis( "Effect Leverage" ),
			Run(
				colList << {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 == ByGroups[group] ),
			SendToReport(
				Dispatch( {"Test value ID=A1"}, "Whole Model", OutlineBox, {Close( 1 )} ),
				Dispatch(
					{"Test value ID=A1", "Person"},
					"Leverage Plot",
					OutlineBox,
					{Close( 1 )}
				)
			)
		);

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

However, I get an error code that I do not fully understand.

 

I have attached a test table and I double checked that I attached the correct one. 

 

Best regards,

Julie

txnelson
Super User

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

What is the error message?

Jim
Juli
Level II

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

Here is the error message:

Juli_0-1736405390225.png

 

I only have 43 lines in the script for now

txnelson
Super User

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

You script modification is very close to working.  In Line 11 you are specifying 

For Each( i = 1, i <= Nitems( colList ), i++,

It should be

For( i = 1, i <= Nitems( colList ), i++,

There is a big difference between the function For Each() and For(). Definition and Examples of the 2 different functions can be found in the Scripting Index.

You will also need to change your references to 

     colList 

in lines 15 and 23 to specify which of the items in colList you are referencing.

Since you are using the variable "i" as your looking index value, you will need to specify

colList[i]

In the sample data table you provided, you only have the column Test Value as your numeric(continous)  columns, so you will only loop once with your For() function.  However, if you add more numeric(continuous) columns you code with the modifications to the syntax I have mentioned will run for each of the numeric(continuous) column

Jim
Juli
Level II

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

Thank you. That makes a lot of sense! 

 

One final question, if I want to alter the text in the Dispatch that is sent to the report - how would this be done?


It is currently "Test value ID=A1" and what is printed is fx Test value 1 or Test value 2. When I tried to change to "Test value ID=colList", the same was printed so I do not understand how it works.

 

I would like it to print the following text for fx test value 1 with ID A1: "Test value 1, ID=A1". I have tried with different strings and functions but either I get an error or it just prints the same as previously. 

 

Best regards,

Julie

txnelson
Super User

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

I am not understanding what you are saying.  I will approach it from a different direction.  Here is the output from your data table for column Test Value 1

txnelson_0-1736455242002.png

what do you want to change from this output?

Jim
Juli
Level II

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

Dear Jim,

 

I have written it to the picture where I want it changed and to what: 

Juli_0-1736497805280.png

If it does not specify the ID, then I do not know how to differentiate between the different windows that pop up when there are multiple IDs.

 

I hope this makes more sense

 

Best regards,

Julie