cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
rlangsner
Level II

Saving Prediction Equations into Data Table Automatically

Hi all,

I am using the fit model tool to create fit equations for a certain subset of data that I would then like to apply back to a larger set and measure the RMS value between the predicted and actual value. I have 231 unique samples (labeled as RunID) and within each sample I have 2 different channels that I am evaluating. This leads to 436 total fit equations. I use the Fit Model tool to create the 436 equations and I can manually go through each output and save each of the equations to a column in the data table. I then copy and paste the formula for that column back into my larger data set and measure the "predicted vs actual". I would like to not manually insert the equations and it seems like there are a couple of solutions that have been posted here and here, but I can't seem to get either of these to work. 

 

Here is what I have:

JMP Version: 16

I am trying to predict the Zoffset from the Xoffset and Yoffset positions, so I should be getting an equation for each "RunID/Channel" combination. 

When I run the script below I get this:

rlangsner_0-1662664451338.png

I was just copying the approaches linked above, but there must be somethign different in my code that does not quite line up. 

 

obj = Fit Model(
	Y(:ZOffset),
	By(:RunID, :Channel Only Location),
	Effects(
		:XOffset, :XOffset * :XOffset, :XOffset * :XOffset * :XOffset, :YOffset, :YOffset * :YOffset,
		:YOffset * :YOffset * :YOffset, :XOffset * :YOffset
	),
	Personality("Standard Least Squares"),
	Emphasis("Minimal Report"),
	Run(
		:ZOffset << {Summary of Fit(1), Analysis of Variance(1), Parameter Estimates(1), Lack of Fit(0), Scaled Estimates(0),
		Plot Actual by Predicted(0), Plot Regression(0), Plot Residual by Predicted(0), Plot Studentized Residuals(0),
		Plot Effect Leverage(0), Plot Residual by Normal Quantiles(0), Box Cox Y Transformation(0)}
	)
);
obj << (Fit[1] << Save Prediction Formula);
3 REPLIES 3
jthi
Super User

Re: Saving Prediction Equations into Data Table Automatically

You might have to use different message. Check what options you get from red triangle menu

jthi_0-1662665619097.png

 

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Animals.jmp");

obj = dt << Fit Model(
	Y(:miles),
	Effects(:species, :subject[:species] & Random, :season, :species * :season),
	Personality(Standard Least Squares),
	Run(
		:ZOffset << {Summary of Fit(1), Analysis of Variance(1), Parameter Estimates(1), Lack of Fit(0), Scaled Estimates(0),
		Plot Actual by Predicted(0), Plot Regression(0), Plot Residual by Predicted(0), Plot Studentized Residuals(0),
		Plot Effect Leverage(0), Plot Residual by Normal Quantiles(0), Box Cox Y Transformation(0)}
	)
);

obj << Prediction Formula;
-Jarmo
rlangsner
Level II

Re: Saving Prediction Equations into Data Table Automatically

Hi Jarmo,

Thank you. I updated the scripto just say "obj << Prediction Formula" and that saved the information to a new column in my data set.  Here is what the options were in my dropdown:

rlangsner_0-1662668359052.png

 

Georg
Level VII

Re: Saving Prediction Equations into Data Table Automatically

Dear @rlangsner , in addition to Jarmo, please notify, that the return of run model is a list in case of using a by group, see below example.

Names Default To Here( 1 );

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

obj = dt << fit model( Y( :weight ), effects( :age, :height ), Personality( "Standard Least Squares" ));
mod1 = obj << run;
mod1 << prediction formula;

obj_by = dt << fit model( Y( :weight ), by( :sex ), effects( :age, :height ), Personality( "Standard Least Squares" ) );
mod2 = obj_by << run;
For Each( {value}, mod2, value << prediction formula );
Georg