cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
dozyme
Level I

Automate saving of prediction formula using JMP script?

Greetings all,

Hoping that someone with more JMP script-writing experience can offer some suggestions here.  What I'd like to do is fit a simple linear regression using the "Fit Model" option, then save the prediction formula for the subsequent model to my current data table automatically through the script.  I've been able to do the first part (fit the model), but the second part is proving difficult to figure out. 

Any advice would be much appreciated. I'm more familiar with programming in R or STATA, so it's been a process getting used to JSL.  Actually, if there are any recommendations for good JSL references (other than the JMP scripting guide, which I find incredibly lacking), that would also be fantastic.

Dan

1 ACCEPTED SOLUTION

Accepted Solutions
MTOF
Level III

Re: Automate saving of prediction formula using JMP script?

Hi Dan

Does this solve your problem? It saves the predicted values in a column with a formula attached.

linfit=Fit Model(

      Y( :Yvar ),

      Effects( :Xvar ),

      Personality( Standard Least Squares ),

      Run model

);

linfit<<prediction formula;

BR, Marianne

View solution in original post

10 REPLIES 10
MTOF
Level III

Re: Automate saving of prediction formula using JMP script?

Hi Dan

Does this solve your problem? It saves the predicted values in a column with a formula attached.

linfit=Fit Model(

      Y( :Yvar ),

      Effects( :Xvar ),

      Personality( Standard Least Squares ),

      Run model

);

linfit<<prediction formula;

BR, Marianne

dozyme
Level I

Automate saving of prediction formula using JMP script?

Fantastic - thanks much!

D

pmroz
Super User

Re: Automate saving of prediction formula using JMP script?

Any advice would be much appreciated. I'm more familiar with programming in R or STATA, so it's been a process getting used to JSL.  Actually, if there are any recommendations for good JSL references (other than the JMP scripting guide, which I find incredibly lacking), that would also be fantastic.

This forum is a great place to learn about JSL.  It's not an easy language but it's pretty addicting once you get the hang of it.

The JMPer Cable newsletters have some good JSL examples.  JMP | JMP Newsletters

The scripting index in JMP 10 has been beefed up considerably with a ton of example code (Help > Scripting Index).

Also I would recommend going to the JMP conference held in September - great value for the money.

mredford
Level II

Re: Automate saving of prediction formula using JMP script?

How would this be modified if a flexible spline fit was to be used

txnelson
Super User

Re: Automate saving of prediction formula using JMP script?

It is the same method as the previous response

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\semiconductor capability.jmp" );
FM=Fit Model(
	Y( :NPN1 ),
	Effects( :PNP1 & Knotted( 5 ) ),
	Personality( "Standard Least Squares" ),
	Emphasis( "Minimal Report" ),
	Run(
		:NPN1 << {Summary of Fit( 1 ), Analysis of Variance( 1 ),
		Parameter Estimates( 1 ), Lack of Fit( 0 ), Plot Actual by Predicted( 0 ),
		Plot Residual by Predicted( 0 ), Plot Effect Leverage( 0 )}
	),
	SendToReport(
		Dispatch( {"Response NPN1"}, "Effect Details", OutlineBox, {Close( 0 )} )
	)
);
fm << prediction formula;
Jim
astep_
Level I

Re: Automate saving of prediction formula using JMP script?

Hi everybody,

I am looking for to save predicted values of a fit model(Stepwise). Do you can help myself ?

txnelson
Super User

Re: Automate saving of prediction formula using JMP script?

Here is a sample script for automation of a Stepwise regression

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\semiconductor capability.jmp" );
fm = Fit Model(
	Y( :NPN1 ),
	Effects(
		:PNP1,
		:PNP2,
		:NPN2,
		:PNP3,
		:IVP1,
		:PNP4,
		:NPN3,
		:IVP2,
		:NPN4,
		:SIT1,
		:INM1,
		:INM2,
		:VPM1,
		:VPM2,
		:VPM3,
		:PMS1,
		:SNM1,
		:SPM1,
		:NPN5,
		:EP2,
		:ZD6,
		:PBA,
		:PLG,
		:CAP
	),
	Personality( "Stepwise" ),
	Run
);
fm << Finish;
nfm = fm << run model;
nfm << prediction formula;
Jim
JPKO
Level III

Re: Automate saving of prediction formula using JMP script?

Hi all,

 

Can I do the same with Fit Curve instead of Fit Model? Below code gives me nothing:

nl = Fit Curve(
	Y( :Response ),
	X( :Dose ),
	Fit Logistic 4P Hill( ),
);

nl << prediction formula;
ian_jmp
Level X

Re: Automate saving of prediction formula using JMP script?

Because (like some other platforms), 'Fit Curve' allows multiple fits in the same report window, you have to tell JMP which curve you want (even if there is only one):

NamesDefaultToHere(1);
// Sample data
dt = Open("$SAMPLE_DATA/Nonlinear Examples/Chemical Kinetics.jmp");
// Fit a curve with Nonliear
fc = Fit Curve( Y( :Name( "Velocity (y)" ) ), X( :Concentration ), Fit Logistic 4P Hill );
Wait(2);
// The fitted curve is 'Fit[1]': Save the prediction formula
fc << fit[1](savePredictionFormula);