cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
shoffmeister
Level V

Save script for Fit Model with by group

Hi JMPers,

 

I'm having a problem when saving a script to create multiple models that have been generated by Fit Model using a by-group. What I do is basically the following:

 

Use Fit Model:

fitmodel.PNG

 

In the second step I will refine the different models for each group:

 

model.PNG

 

Now I have two models. I would then like to save a script that reproduces this report. Sadly when saving the script using the typical way (Hotspot => Save Script (All Objects) it gives me the following output:

model2.PNG

 

This is problematic because now I cannot righclick into the tables and "Save as Combined Data Table". I'm then missing the "Group"-Information. 

Would be very happy to learn how to do this. 

 

Best regards,

Sebastian

5 REPLIES 5
shoffmeister
Level V

Re: Save script for Fit Model with by group

I just found out I can split my table so that each group is a represented by an individual response column and then it works. 

 

Would still like to know if it is possible to do it the other way around.

ih
Super User (Alumni) ih
Super User (Alumni)

Re: Save script for Fit Model with by group

Not sure when this was introduced (which version) but I believe the By-Group script will do what you need:

 

ByGroup.PNG

cwillden
Super User (Alumni)

Re: Save script for Fit Model with by group

What JMP does with "To Data Table (All Objects)" when you have a By group is to basically create a separate report for each level of the By group and concatenate them all together within a vertical list box.  ih is right that at least with JMP 13 there is a "Save-By-Group Script" option. 

If you're not on 13 yet, then here's how I used to do it.  Save a script to a data table the regular way (not for all objects, you'll just have to do more modifications to the script if you do).  Then, edit the script to add a Group() statement within the Fit Model() statement.

For example, if saving the script to data table gets you something like this:

Fit Model(
	Y( :Y ),
	Effects( :X ),
	Personality( "Standard Least Squares" ),
	Emphasis( "Effect Screening" ),
	Run(
		Profiler( 0 ),
		:Y << {Summary of Fit( 1 ), Analysis of Variance( 1 ),
		Parameter Estimates( 1 ), Effect Details( 0 ), Lack of Fit( 0 ),
		Sorted Estimates( 0 ), Scaled Estimates( 0 ), Plot Actual by Predicted( 1 ),
		Plot Residual by Predicted( 1 ), Plot Residual by Row( 1 ),
		Plot Studentized Residuals( 0 ), Plot Effect Leverage( 0 ),
		Box Cox Y Transformation( 0 ), Show VIF( 1 )}
	),
	Where( :Group == "A" )
)

Delete the Where() clause and add a By() clause using the same column up by the other column specifications like so:

Fit Model(
	Y( :Y ),
	Effects( :X ),
	By( :Group ),
	Personality( "Standard Least Squares" ),
	Emphasis( "Effect Screening" ),
	Run(
		Profiler( 0 ),
		:Y << {Summary of Fit( 1 ), Analysis of Variance( 1 ),
		Parameter Estimates( 1 ), Effect Details( 0 ), Lack of Fit( 0 ),
		Sorted Estimates( 0 ), Scaled Estimates( 0 ), Plot Actual by Predicted( 1 ),
		Plot Residual by Predicted( 1 ), Plot Residual by Row( 1 ),
		Plot Studentized Residuals( 0 ), Plot Effect Leverage( 0 ),
		Box Cox Y Transformation( 0 ), Show VIF( 1 )}
	)
)

 You should now reproduce the Fit Model report broken out by each level of By() as desired.

 

 

-- Cameron Willden
shoffmeister
Level V

Re: Save script for Fit Model with by group

Thanks for the tips. I am on JMP 13.2.1 Sadly the "Save-By-Group-Script"-option disappears in the moment where I use the Effect Summary to remove individual effects from one model.

 

Kind of the same problem for the scripting approach. I will have a lot of individual fit-model statements and I don't know how to put them together. Especially as we are talking of more than 20 groups which would be a lot of work that I would like to avoid.

 

Best,

Sebastian

ian_jmp
Level X

Re: Save script for Fit Model with by group

Not sure exactly what workflow you envisage, but the thread implies a 'semi-automated' approach in which (someone!) refines each of the models 'by hand'.

But regarding: "This is problematic because now I cannot righclick into the tables and "Save as Combined Data Table". I'm then missing the "Group"-Information." (and as you know already) it would be easy enough to reinstate this column programaically.

Using 'Big Class', I made:

Screen Shot 2017-12-19 at 12.08.05.png 

so one could take the 'Intercept' cell as the indication that this and subsequent rows are for a new level of the 'By' group.