Hi all,
I'm trying to automate a nonlinear regression routine and part of that involves creating a custom model via column formulas.
I want to have an arbitrary number of parameters, and I think I've solved that by dumping an appropriately formatted list into the Parameter({}) section ("Parm_Start"). One problem I'm having is that I don't know how to arbitrarily set the term in Match(). I tried to do this with Match_List{}, which matches the format, but it gives odd outputs.
Secondly, I'm trying to sum a series of exponentials with "o" pre-exponential terms and "o" using the form A[o]*exp(-t/t[o]) -- see the code below. The A's are all fittable parameters, pulled from a column Mod_Parm; Time is a column of arbitrary length and the independent variable; and Timeconst is a column of the same length as Mod_Parm (both of which are shorter than Time).
I haven't gotten to the part where the JSL-based nonlinear modeling routine is called because need to fix this first.
Thanks!
Mod_Parm_list={};
Parm_start={};
Parm_list={};
Match_list={};
b=1;
for(m=1,m<=num_exp,m++,
Mod_Parm_list[m]="A"||char(m);
Parm_start[m]=parse("Parm_"||Mod_Parm_list[m]||" = -0.1");
Parm_list[m]="Parm_"||Mod_Parm_list[m];
Match_list[b]=Mod_Parm_list[m];
Match_list[b+1]=parse(Parm_list[m]);
b=b+2;
);
dt << NewColumn("I_model",Format ("Scientific"),Set Property( "Expand Formula", 1 ),
Formula
(Parameter(
{Parm_start},
I_DC - Summation(o=1,num_exp,
Match(:Mod_Parm,
"A1", Parm_A1,
"A2", Parm_A2,
"A3", Parm_A3,
"A4", Parm_A4,
"A5", Parm_A5,
"A6", Parm_A6
)*Exp(-:Time/:TimeConst[o])
)
)
)
);
For posterity, I wanted to add that part of the solution can be found here:
https://community.jmp.com/t5/Discussions/How-to-pass-a-variable-into-a-formula/td-p/52344
That is, part of my issue was not defining "I_DC" as a table variable and assuming the column formula would understand the expression. Here's the update for that part:
I_DC = 3; //Using only this value in the column formula is wrong
dt = Current Data Table();
dt << set Table Variable( "I_DC_form", I_DC ); //Allows the parameter to be used later in the col formula expression
Mod_Parm_list={};
Parm_start={};
Parm_list={};
Match_list={};
b=1;
for(m=1,m<=num_exp,m++,
Mod_Parm_list[m]="A"||char(m);
Parm_start[m]=parse("Parm_"||Mod_Parm_list[m]||" = -0.1");
Parm_list[m]="Parm_"||Mod_Parm_list[m];
Match_list[b]=Mod_Parm_list[m];
Match_list[b+1]=parse(Parm_list[m]);
b=b+2;
);
dt << NewColumn("I_model",Format ("Scientific"),Formula(
Parameter(
{T1 = 1, T2 = 1, T3 = 1, T4 = 1, T5 = 1, T6=1},
:I_DC_form + T1 * Exp( -:Time / 0.004 ) + T2 * Exp( -:Time / 0.01 ) + T3 * Exp( -:Time / 0.1 )
+ T4 * Exp( -:Time / 1 ) + T5 * Exp( -:Time / 10 ) + T6 * Exp( -:Time / 100 ))
)
);