I am trying to find the best way to report a nonlinear model fit to my experimental data.
I have managed to write a script that fits a nonlinear model and finds the parameters estimates using the loss function. It then reports each parameter estimates and the non linear errors.
However, I would like to get the RMSE or R-square of the resulting fit also. Is this not available for nonlinear models? or do I need to add an extra analysis step?
When running the nonlinear analysis platform interactively the resulting plot shows both the experimental data and the model curve. However, when running the script automatically only the experimental data is shown. Does anyone know why this happens? Am I missing anything on the script below?
Could someone provide some literature/books/links to be able to get the graphs of the data vs resulting model fit and report the R-square of the fit?
The script I am using for the nonlinear model fit is the one below at the moment:
col1 = New Column( "Model" );
col1 << set formula(
Parameter(
{Y1_Y1_0 = 0.2, K1_K1_0 = 0.01, P1_P1_0 = 0.004, Y2_Y2_0 = 0.15, K2_K2_0 = 0.06, P2_P2_0 = 0.3},
If( :Days > 0,
Y1_Y1_0 * Exp( -Exp( ((K1_K1_0 * Exp()) / Y1_Y1_0) * (P1_P1_0 - :Days) ) ) + Y2_Y2_0 *
Exp( -Exp( ((K2_K2_0 * Exp()) / Y2_Y2_0) * (P2_P2_0 - :Days) ) ),
0
)
)
);
col2 = New Column( "Err" );
col2 << set Formula( Sum( (:Average - :Model) ^ 2 ) );
col2 << Evalformula;
col2 << Get formula;
obj = Nonlinear( Y( :Methane Yield ), X( :Model ), Loss( :Err ), Iteration Limit( 600 ), By( :Sample ) );
obj << go;
//returns a list of vectors where each vector, contains the parameters estimates
obj << get estimates;
//also see Get SSE, Get Parameter Names, Get CI
//Alternately, make a table
_xx = obj << Xpath( "//OutlineBox[@helpKey='Nonlinear Solution']" );
//only 2 groups so only 2 are found; each contains two sub tables
fit_dt = (_xx[1] << Find( Table Box( 1 ) )) << Make Combined Data Table;
est_dt = (_xx[1] << Find( Table Box( 2 ) )) << Make Combined Data Table;
fit_dt << set Name( "NonLin Fit Errors" );
est_dt << set Name( "NonLin Fit Estimates" );