cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
lakepotter
Level II

Extracting parameter estimates from nonlinear (sigmoidal) curve fit - scripting

Hi all, 

 

To quickly orient you: I am working with ELISA data (dose-response curve) so my independent variable is dilution factor, my dependent variable is absorbance, and I have multiple time points I am looking at for multiple animals. I'd like to be able to find the EC50 - dilution at half maximal response - with a nonlinear, sigmoidal, curve fit. I am currently using a  4 parameter model (Probit 4P).

 

Basically, I'd like to write a script that can get the data from the parameter estimates into a table, find the midway point between the upper and lower asymptotes for each curve, and then use that value in a custom inverse prediction to get the EC50. I'm pretty sure I can do the second two parts if I could just get the dang parameter estimates! 

 

Here's what I have for the curve fitting:

 

For ( i = 1, i <= N items (Mice), i++, 
		FC = Fit Curve (
		Y ( :Data ), 
		X (:Dilution ), 
		Group (:Timepoint),
		By(:Animal)
		
		Fit Probit 4P, 
		Where (:Animal == eval(Mouse_names[i])), //thist isn't referencing the variable the way i expect but using either eval( ) or char( ) seems to be a work-around?...
	SendToReport(
		Dispatch(
			{"Plot"},
			"7",
			ScaleBox,
			{Format( "Fixed Dec", 12, 0 ), Min( 0 ), Max( 4 ), Inc( 2 ),
			Minor Ticks( 0 )}
		),
		Dispatch(
			{"Plot"},
			"6",
			ScaleBox,
			{Scale( "Log" ), Format( "Scientific", 12 ), Min( 0.0000001 ),
			Max( 0.1 ), Inc( 2 ), Minor Ticks( 0 )}
		),
		Dispatch(
			{"Plot"},
			"13",
			ScaleBox,
			{Format( "Fixed Dec", 12, 0 ), Min( 0 ), Max( 4 ), Inc( 2 ),
			Minor Ticks( 0 )}
		),
		Dispatch(
			{"Plot"},
			"16",
			ScaleBox,
			{Scale( "Log" ), Format( "Scientific", 12 ), Min( 0.0000001 ),
			Max( 0.1 ), Inc( 2 ), Minor Ticks( 0 )}
		),
		Dispatch(
			{"Probit 4P", "Plot"},
			"7",
			ScaleBox,
			{Format( "Fixed Dec", Use thousands separator( 1 ), 12, 0 ), Min( 0 ),
			Max( 4 ), Inc( 2 ), Minor Ticks( 0 )}
		),
		Dispatch(
			{"Probit 4P", "Plot"},
			"6",
			ScaleBox,
			{Scale( "Log" ), Format( "Scientific", 12 ), Min( 0.0000001 ),
			Max( 0.1 ), Inc( 2 ), Minor Ticks( 0 )}
		),
		Dispatch(
			{"Probit 4P", "Plot"},
			"13",
			ScaleBox,
			{Format( "Fixed Dec", Use thousands separator( 1 ), 12, 0 ), Min( 0 ),
			Max( 4 ), Inc( 2 ), Minor Ticks( 0 )}
		),
		Dispatch(
			{"Probit 4P", "Plot"},
			"16",
			ScaleBox,
			{Scale( "Log" ), Format( "Scientific", 12 ), Min( 0.0000001 ),
			Max( 0.1 ), Inc( 2 ), Minor Ticks( 0 )}
		)
	)
	

);


FC << journal;
FC << close window;);

That works fine for me and I have the output of a journal with each Fit Curve with the model comparison, plot of the data, model info (including prediction model, summary of fit, *~*parameter estimates*~*, correlation of estimates, covariance of estimate, and plots of the modeled curve).  I can manually right click on the parameter estimates and "Make Into Combined Data Table" but don't know how to do it in a script.  Ideally, i would only have one data table at the end with columns for Animal, Parameter (growth rate, inflection point, lower asymptote, upper asymptote) Group ( these are my time points), Estimate, Std Error, Lower 95%, Upper 95%. 

 

Any help would be greatly appreciated! Thanks!  

5 REPLIES 5
gzmorgan0
Super User (Alumni)

Re: Extracting parameter estimates from nonlinear (sigmoidal) curve fit - scripting

Here is an example, not exactly your specific example (this example uses By). I don't know your expertise in navigating a report window.

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Nonlinear Examples/Bioassay.jmp" );
obj = Fit Curve( Y( :Toxicity ), X( :log Conc ), By( :formulation ) );
obj << Fit Logistic 4P( Custom Inverse Prediction( Response( 0.9 ) ) );

//you can get one table using Make Combined Data Table
est_tbl= report(obj[1])["Parameter Estimates"][TableBox(1)] << Make Combined Data Table;
est_tbl << Set Name("Parameter Estimates");


inv_tbl = report(obj[1])["Inverse Prediction"]["Predicted Values"][TableBox(1)] << Make Combined Data Table;
inv_tbl << Set Name("Inverse Prediction");

Hope this helps.

Re: Extracting parameter estimates from nonlinear (sigmoidal) curve fit - scripting

Hello,

 

Once you have a handle to your journal, you can navigate the journal as shown below (similar to the post by @gzmorgan0) to generate the data table of combined Parameter Estimates.

jrn = Current Journal();
paramEst = jrn["Parameter Estimates"][Table Box( 1 )] << Make Combined Data Table;

I hope this is helpful!

Wendy
lakepotter
Level II

Re: Extracting parameter estimates from nonlinear (sigmoidal) curve fit - scripting

Awesome! Thanks so much for the answer - it defintely works for exactly what I need it for!! I'm just still trying to figure out what's going on underneath your code so I can use it in different applications in the future. 

 

Is this just indexing the journal by name, specifing that I do want the table box and making a new data table? 

 

I had seen other responses like 

dt2 = bivRep [1] [TableBox(3)]  << Make Combined Data Table;

but couldn't figure out what was really going on. Would this one take the third table box found in the first section (?) of bivRep and write out to a new dt? 

 

 

 

 

I am exploring a little but more and was able to get the Summary of Fit with

jrn["Summary of Fit"][Table Box (1)] << Make Combined Data Table;

but couldn't figure out how to do something like get the Correlation of Estimates for Week 5. 

 

I tried:

covar_pre = jrn["Covariance of Estimates"]["Week 5"][Table Box(1)] << Make Combined Table;

And got the error:

Cannot subscript Display Box{400} in access or evaluation of 'Subscript' , jrn["Covariance of Estimates"]["pre"][/*###*/Table Box( 1 )]

In the following script, error marked by /*###*/
paramEst = jrn["Covariance of Estimates"]["Week 5"][/*###*/Table Box( 1 )] <<
Make Combined Data Table

I guess *this* output is not a table box? I am not sure what sort of data it is and am not sure how to figure it out. 

 

 

lakepotter
Level II

Re: Extracting parameter estimates from nonlinear (sigmoidal) curve fit - scripting

My experience in navigating a report window is essentially zero. 

 

I searched the scripting guide for report window and didn't find much. Any resources you could point me towards? 

gzmorgan0
Super User (Alumni)

Re: Extracting parameter estimates from nonlinear (sigmoidal) curve fit - scripting

Use

 

jrn["Correlation of Estimates"][MatrixBox(1)] << Make Combined Data Table;

Go to Main Menu> Help >Books > JMP Scripting Guide then open the PDF and scroll to Chapter 11, Display Trees.

 

A JMP report is a list of nested display boxes.  This will show you how to find objects and send messages.

 

jrn << show tree structure;

//or right click on a reveal button to the left of an outline box
// then select Edit, Show Tree Structure