Siguiendo el proceso de identificar algunas columnas que interactúan después de usar la plataforma de ajuste y buscar alguna interacción (factorial...). Quiero usar el término resultante (como cA*0.1+cB*0.3) de la interacción como punto de partida para crear automáticamente fórmulas de columna a partir de esos términos. Luché por encontrar una manera de usar el contenido de una cadena como "cA*0.1+cB*0.3" donde cA y cB representan los nombres de 2 columnas presentes en una tabla para crear nuevas fórmulas.
La última parte del script crea la fórmula, pero solo representa el contenido de la cadena en lugar de evaluar su contenido.
Cualquier sugerencia sería muy apreciada.
Sebastián
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] ) )