Following the process of identifying some interacting columns after using the fit platform and looking for some interaction (factorial...). I want to use the resulting term (such as cA*0.1+cB*0.3) from the interaction as the starting point to automatically create column formulas from those terms. I struggling to find a way to use the content of a string such as"cA*0.1+cB*0.3" where cA and cB represent the names of 2 columns present in a table to build new formulas.
The last portion of the script create the formula but is just representing the content of the string instead of evaluating its content.
Any suggestion would be greatly appreciated.
Sebastien
names default to here(1);
clear log();
dtinit=Open( "$SAMPLE_DATA/Bands Data.jmp" );
// Make TableBox into a Data Table
// → Data Table( "Untitled 3" )
//terms tables resulting from a generalized regression taking into consideration term interaction.
dtfeat = New Table( "features",
Add Rows( 14 ),
New Column( "Term",
Character,
"Nominal",
Set Property( "ID Column", 1 ),
Set Values(
{"press speed", "(roller durometer-34.5151)*(anode space ratio-102.914)", "(proof cut-44.9671)*(blade pressure-30.8904)",
"(anode space ratio-102.914)*(chrome content-99.6164)", "(humidity-78.6849)*(press speed-1851.21)", "roller durometer",
"(roller durometer-34.5151)*(current density-39.0164)", "(humidity-78.6849)*(wax-2.4037)", "(wax-2.4037)*(chrome content-99.6164)",
"(viscosity-50.7836)*(press speed-1851.21)", "(wax-2.4037)*(hardener-0.96014)", "(roughness-0.71969)*(current density-39.0164)",
"(humidity-78.6849)*(ink pct-55.6473)", "(blade pressure-30.8904)*(press speed-1851.21)"}
)
),
Set Label Columns( :Term )
);
//Identifies interacting terms
// New column: interaction
dtfeat << New Column( "interaction", Character, "Nominal", Formula( If( Starts With( :term, "(" ), :term, "" ) ) ) <<
Move Selected Columns( {:interaction}, after( :term ) );
value = dtfeat:interaction << get values();
uniqueinteraction = Associative Array( value ) << get keys;
nvinteract = N Items( uniqueinteraction );
//Will create a column named after the interacting terms
//Should apply a formula based on the interacting terms
//However, not sure how to extract the string from the list 'uniqueinteraction' so that is it not seen as a string but rather as 'formula instruction' where some portion of the term is recognized as a column namealready present in the original table
For( i = 1, i <= nvinteract, i++,
dtinit << New Column( uniqueinteraction[i], Numeric, "Continuous", Format( "Best", 12 ), Formula( Eval( uniqueinteraction[i] ) )