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
learning_JSL
Level IV

need script that computes the statistical parameters shown below in my post

Hi - I am still new at jsl scripting and am trying to write a script that creates and saves four new columns based on my linear regression fit:

- lower 95% mean confidence interval

- upper 95% mean confidence interval

- lower 95% individual confidence interval

- upper 95% individual confidence interval

Finally, each of the above are computed in terms of log 10 and I would instead like them converted to antilog terms (e.g. My x-y fit produces 2.78, but I need to show the antilog of 2.78 which is 2489).  A portion of my current jsl code is shown below.

Thank you!

obj = Fit Model(
	Y( :LOG_ECOLI_PEAR ),
	Effects( :LOG_TURB_PEAR_FNU),
	Personality( "Standard Least Squares" ),
	Emphasis( "Effect Leverage" ),
	Run(:LOG_ECOLI_PEAR 
	))	;
 
  obj << Prediction Formula;

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: need script that computes the statistical parameters shown below in my post

If you do not need the platform for interaction, then you might use the Minimal Report for Emphasis and the Invisible option in the Fit Model call. (Then remember to close it.

 

I suggest that you use the Scripting Index to explore the other messages for Fit Least Squares platform instead of << Prediction Formula. Here is one example:

 

Screen Shot 2022-01-25 at 11.33.49 AM.png

 

The column formulas are actually JSL expressions. As such, they may be manipulated as data. That is to say, you can apply the anti-log transformation after these expressions are saved to result in an updated formula. So use the << Get Formula message with the new column to obtain the current expression. Insert it into the anti-log function expression as its argument,  and then save the new expression with the << Set Formula message to replace the original formula.

 

Here is an example using the approach that I suggested:

Names Default to Here( 1 );

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

// create a transformed response
dt << New Column( "Log weight", Numeric, Continuous,
	Values( Log10( :weight << Get As Matrix ) )
);

// fit model for transformed response
fit = dt << Fit Model(
	Y( :Log weight ),
	Effects( :height ),
	Emphasis( "Minimal Report" ),
	Run
);

// save formulas for transformed response
fit << Mean Confidence Limit Formula( 0.05 ) << Indiv Confidence Limit Formula( 0.05 );

// back-transform prediction formulas
n = N Col( dt );
For( col = n, col > n - 3, col--,	// start at end and work back
	old formula = Column( dt, col ) << Get Formula;
	new formula = Substitute(
		Expr( Power( 10, yyy ) ),
		Expr( yyy ), Name Expr( old formula )
	);
	Eval(
		Substitute(
			Expr( Column( dt, col ) << Set Formula( fff ) ),
			Expr( fff ), Name Expr( new formula )
		)
	);
	col name = Column( dt, col ) << Get Name;
	Column( dt, col ) << Set Name( Substitute( col name, "Log ", "" ) );
);

View solution in original post

6 REPLIES 6

Re: need script that computes the statistical parameters shown below in my post

If you do not need the platform for interaction, then you might use the Minimal Report for Emphasis and the Invisible option in the Fit Model call. (Then remember to close it.

 

I suggest that you use the Scripting Index to explore the other messages for Fit Least Squares platform instead of << Prediction Formula. Here is one example:

 

Screen Shot 2022-01-25 at 11.33.49 AM.png

 

The column formulas are actually JSL expressions. As such, they may be manipulated as data. That is to say, you can apply the anti-log transformation after these expressions are saved to result in an updated formula. So use the << Get Formula message with the new column to obtain the current expression. Insert it into the anti-log function expression as its argument,  and then save the new expression with the << Set Formula message to replace the original formula.

 

Here is an example using the approach that I suggested:

Names Default to Here( 1 );

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

// create a transformed response
dt << New Column( "Log weight", Numeric, Continuous,
	Values( Log10( :weight << Get As Matrix ) )
);

// fit model for transformed response
fit = dt << Fit Model(
	Y( :Log weight ),
	Effects( :height ),
	Emphasis( "Minimal Report" ),
	Run
);

// save formulas for transformed response
fit << Mean Confidence Limit Formula( 0.05 ) << Indiv Confidence Limit Formula( 0.05 );

// back-transform prediction formulas
n = N Col( dt );
For( col = n, col > n - 3, col--,	// start at end and work back
	old formula = Column( dt, col ) << Get Formula;
	new formula = Substitute(
		Expr( Power( 10, yyy ) ),
		Expr( yyy ), Name Expr( old formula )
	);
	Eval(
		Substitute(
			Expr( Column( dt, col ) << Set Formula( fff ) ),
			Expr( fff ), Name Expr( new formula )
		)
	);
	col name = Column( dt, col ) << Get Name;
	Column( dt, col ) << Set Name( Substitute( col name, "Log ", "" ) );
);
learning_JSL
Level IV

Re: need script that computes the statistical parameters shown below in my post

Thank you for the response Mark.  I am working through the solution now.  As I am still learning JSL, much of what I do is trila and error so it may take me a while to sort through this.  In any case, I have gotten a portion of it to work and will circle back once I am successful or have a follow up question.  Thanks!

learning_JSL
Level IV

Re: need script that computes the statistical parameters shown below in my post

I got the confidence intervals to work and I am now trying to get the anti log (i.e.back transform) portion working.  Can you briefly explain the following lines of code?  (I think it is looking for a certain column in my data table for back transforming?)

 

n = N Col( dt );
For( col = n, col > n - 3, col--, // start at end and work back

Re: need script that computes the statistical parameters shown below in my post

Your understanding is correct. Immediately prior to this iteration, the Fit Least Squares platform saved two sets of limits as column formulas. The new data columns appear at the end (right side) of the data table. So the relative referencing works fine.

learning_JSL
Level IV

Re: need script that computes the statistical parameters shown below in my post

Thanks again Mark.  I was able to get it working.  I appreciate it!

Re: need script that computes the statistical parameters shown below in my post

I hope that you study this example, because you are learning to script JMP and the language. Take it slowly, piece by piece. It uses several common approaches that will likely help you when you write new scripts. Of course, post your questions here, too.