- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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;
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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:
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 ", "" ) );
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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:
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 ", "" ) );
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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.